API Designer Collection Validation Incorrect with Body field value

When I have an API spec in OpenAPI 3.0 in yml format, with the following section defined, the collection validation indicates an error that the body parameters in JSON format should be removed from the collection even though the API Spec and Collection both show that it should be there. The ‘username’ field’s value is showing up with a random value, different value in each request that this issue is showing up in.

The collection was generated from the API Spec without modification before validating through API Designer.

API Spec Snippet:

      summary: Reset Password
      operationId: resetPassword
        - authorizer: []
              $ref: "#/components/schemas/ResetPasswordRequest"
              username: "{{USER_NAME}}"
              oldPassword: "{{PASSWORD}}"
              newPassword: "{{NEW_PASSWORD}}"
        required: true
          description: "200 response"
                $ref: "#/components/schemas/ResetPasswordResponse"
                status: 200
                code: 2003
                message: "Password reset successfully."
          title: "Reset Password Request Schema"
          - "username"
          - "oldPassword"
          - "newPassword"
          type: "object"
              pattern: "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+$"
              type: "string"
              type: "string"
              type: "string"

Collection Request for ResetPassword Body:

    "username": "<string>",
    "oldPassword": "<string>",
    "newPassword": "<string>"

Environment with variable defined for:
with value as email format.

Collection Validation Web Page for ResetPassword:

Thank you for your time and help.

Hi @darren.capner

Current suggested change you see is due to body not adhering to schema. As username has pattern defined in schema which is being violated in collection request.

You can Import your API and tweak generated collection based on some option from Import flow. You can start by following Import button on top left corner and choose corresponding method.

Once you select schema, you will be able to select options in Configuration model. Choose example for Request parameter generation and Example parameter generation options. This will use example adhering to schema as value instead of default type placeholders (which are useful for documentation purpose).

We are working on Configuration model in Generate Collection flow from API tab. But for now you can link API and Imported Collection from API tab and validate again.

Yes, you are right in that the request body attribute ‘username’ is not following pattern defined in API schema. I can change the value to a string with the right format and the validation passes. This is good.

The problem that I see when I set the ‘username’ JSON body attribute value to reference an Environment variable “{{USER_NAME}}”. the validation fails with the same message. This issue has been reported in this post. Collection Validation errors when request contains variables

Reset Password Request Body:

    "username": "{{USER_NAME}}",
    "oldPassword": "{{PASSWORD}}",
    "newPassword": "{{NEW_PASSWORD}}"

I click validate on the collection in the API Designer and receive this message.

Yes, this is something that we are working on where collection/environment variables will not result in validation error. This is something that is already available in header, query params and path variable, while request/response body is still in progress.

Thanks for reporting this.

1 Like