Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

unexpected validate error when dealing with exploded query params #91

Open
TristanSpeakEasy opened this issue Jan 29, 2024 · 0 comments

Comments

@TristanSpeakEasy
Copy link

Consider this spec:

openapi: 3.1.0
info:
  title: Test
  version: 0.1.0
security:
  - apiKeyAuth: []
paths:
  /anything/queryParams/form/camelObj:
    get:
      x-speakeasy-test: true
      operationId: formQueryParamsCamelObject
      tags:
        - parameters
      parameters:
        - name: obj_param_exploded
          in: query
          explode: true
          schema:
            type: object
            properties:
              search_term:
                type: string
                example: foo
              item_count:
                type: string
                example: "10"
          required: true
        - name: obj_param
          in: query
          explode: false
          schema:
            type: object
            properties:
              encoded_term:
                type: string
                example: bar
              encoded_count:
                type: string
                example: "11"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                title: res
                type: object
                properties:
                  url:
                    type: string
                    example: http://localhost:35123/anything/queryParams/form/camelObj?item_count=10&obj_param=encoded_count%2C11%2Cencoded_term%2Cbar&search_term=foo
                    x-speakeasy-test-internal-directives:
                      - sortQueryParameters: {}
                  args:
                    type: object
                    properties:
                      search_term:
                        type: string
                        example: "foo"
                      item_count:
                        type: string
                        example: "10"
                    required:
                      - search_term
                      - item_count
                required:
                  - url
                  - args
components:
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Authenticate using an API Key generated via our platform.

And a url to call it like http://localhost:35123/anything/queryParams/form/camelObj?item_count=10&obj_param=encoded_count%2C11%2Cencoded_term%2Cbar&search_term=foo

This request fails with the below error from wiretap:

{
  "type": "https://pb33f.io/wiretap/errors#validation_failed_and_spec_insufficient_error",
  "title": "Invalid request, specification is insufficient (500)",
  "status": 500,
  "detail": "The request failed validation, and the specification does not contain a '422' or '400' response for this operation. Check payload for validation errors.",
  "payload": [
    {
      "message": "Query array parameter 'obj_param_exploded' failed to validate",
      "reason": "The query parameter (which is an array) 'obj_param_exploded' is defined as an object, however it failed to pass a schema validation",
      "validationType": "parameter",
      "validationSubType": "query",
      "specLine": 1066,
      "specColumn": 13,
      "howToFix": "Ensure that the object being submitted, matches the schema correctly",
      "validationErrors": [
        {
          "reason": "expected string, but got number",
          "location": "/properties/item_count/type"
        }
      ]
    }
  ]
}

This should be a valid request and I wouldn't expect it to fail, especially as the validation error doesn't really seem to be calling out anything valid

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants