0

I'm trying to define OpenAPI for a query parameter that uses a simple type for a deepObject.

According to the OpenAPI spec, the following should work:

openapi: 3.0.3
info:
  title: OpenAPI definition
  version: 0.0.1
paths:
  /example:
    get:
      parameters:
        - name: foo
          in: query
          required: false
          schema:
            type: object
            minProperties: 1
            style: deepObject
            explode: true
            example: >
              {
                "bar": "baz"
              }
      responses:
        "200":
          description: OK
        "400":
          description: Bad request
        "401":
          description: Authorization info missing or invalid
        "403":
          description: Unauthorized
        "404":
          description: Not found

Should result in a query such as http://localhost:9080/example?foo[bar]=baz if you use the same input as the given example. However, what I'm getting is http://localhost:9080/example?bar=baz. I've searched around and quadruple checked my syntax to make sure I am doing what I think is being described around the web, but it still doesn't result in the output I think the OpenAPI spec is describing. I feel like I must be doing something wrong and am just not seeing it. Can anyone identify what I am doing wrong?

Note, I also posted this question to the discussion on the swagger-ui GitHub project.

1 Answer 1

0

Move style and explode outside the schema, to the parameter level:

      parameters:
        - name: foo
          in: query
          required: false
          style: deepObject  # <-------
          explode: true      # <-------
          schema:
            type: object
            ...
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I had a feeling it had to be something really simple, but I wasn't seeing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.