Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable query parameter names in OpenAPI

Does anyone have an ideal how to model that in OpenAPI specification? :-/

https://api.example.de/search?facet=key1&facet=key2&key1=value1&key2=value2

key1, key2 etc. are given values from an enumeration. It there a way to describe them more detailed?

/search:
    get:
      parameters:
        - in: query
          name: facet
          required: false
          schema:
            type: array
            items:
              type: string
              enum:
                - key1 # Description?
                - key2
        - in: query
          name: {facet_name}
          required: false
          ???

Is that the only solution:

/search:
    get:
      parameters:
        - in: query
          name: facet
          required: false
          schema:
            type: array
            items:
              type: string
              enum:
                - key1 # Description ?
                - key2
        - in: query
          name: key1
          required: false
          schema:
            type: string
          description: Key1 is that...
like image 661
Michael Avatar asked Mar 31 '26 20:03

Michael


1 Answers

All values in an enum must adhere to the specified type. If you need to specify descriptions for enum items, you can do this in the description of the parameter or property,

Description supports Markdown CommonMark for rich text representation, Like below example:

description: >
  **Your Title**:
    * `key1` - description for key1
    * `key2` - description for key2

It will look:

enter image description here

Hope this help.

like image 109
turivishal Avatar answered Apr 03 '26 16:04

turivishal