Skip to content

Explode doesn't seem to work as expected for query string parameters #446

@breis-sa

Description

@breis-sa

First and foremost, thank you for the great gem, it really speed things up when it comes to API request validation.

Now about the issue I found - which might not be an issue and just my misunderstanding of how to use the gem/OpenAPI spec correctly - it seems that the explode option is not working correctly for query string parameters.

According to the OpenAPI spec, when style is form and explode is true, objects should generate separate parameters for each array item or object property as seen in the example below:

Image

So I declared the following definition for my endpoint. I'm basically trying to build an endpoint that accepts mutually exclusive query string parameters (like in this example)

  /my-endpoint/foo/bar/baz:
    parameters:
      # path parameters here
    get:
      summary: Lorem ipsum
      operationId: myEndpointFooBarBaz
      parameters:
        - in: query
          name: id
          style: form
          explode: true
          required: true
          schema:
            type: object
            oneOf:
              - properties:
                  role:
                    type: string
                required: [role]
              - properties:
                  firstName:
                    type: string
                required: [firstName]
      responses:
        # responses here

If I send the request as: /my-endpoint/foo/bar/baz?role=1234&firstName=John, I would expect to get back an error informing that request should match one of the valid schemas, but instead, I get back an error saying something like request is missing required parameters: id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions