3

I'm trying to define a query object in OpenAPI 3:

      parameters:
        - name: query
          in: query
          schema:
            type: object
            properties:
              id:
                type: number
            required:
              - id

But the example value and schema is not shown in Swagger UI.

enter image description here

Is there a bug or am I missing something?

Reactgular
  • 52,335
  • 19
  • 158
  • 208
yantrab
  • 2,482
  • 4
  • 31
  • 52
  • Related: [Use object type query param in Swagger documentation](https://stackoverflow.com/q/38187187/113116) – Helen Jan 13 '21 at 10:12

1 Answers1

2

Your definition is correct.

but example value and schema was not shown in swaager ui.

The example is actually shown, in the JSON key/value format:

{
  "id": 0
}

"Try it out" will serialize this parameter according to the defined serialization method, in this case as the ?id=<value> query string.


The issue with the schema not being displayed for query parameters of type: object is a known limitation, it's tracked here:
https://github.com/swagger-api/swagger-ui/issues/4581

Helen
  • 87,344
  • 17
  • 243
  • 314