Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare query object in the parameters?

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?

like image 871
yantrab Avatar asked Dec 04 '25 10:12

yantrab


1 Answers

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

like image 98
Helen Avatar answered Dec 07 '25 20:12

Helen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!