OpenAPI - Get arbitrary query parameters

609 views Asked by At

I have an endpoint like this :

api/employees?limit=2&name=Palani&age=20

Here, the limit is keyword that is publicised to the users. But name and age are arbitrary parameters. For another resource, like Organization, an arbitrary parameter could be foundIn.

In openapi spec, I have

   api/employees :
    get:
      parameters:
        - in: query
          name: limit
          required: false
          schema:
            type: integer

I am using codegen plugin openapi-generator-maven-plugin where in the server controller, I want to capture all the arbitrary parameter. How can I extend my openapi spec to get the params apart from limit. If there is a way to get all the query params in a single array, that would be a help as well.

1

There are 1 answers

0
Christopher Reece On

If I understand your question correctly, I think you can extend the parameters like this.

api/employees :
get:
  parameters:
    - name: limit
      in: query
      required: false
      schema:
        type: integer
    - name: name
      in: query
      nullable: true
      schema:
        type: string
    - name: age
      in: query
      nullable: true
      schema:
        type: integer