1

There is a path in api with an arbitrary number of optional parameters of approximately this kind:

/orders/123/get-payment-link/provider?customerId=123&amount=2000&custom1=custom1&custom2=custom2...

The api description looks something like this:

paths:
  /orders/{orderId}/get-payment-link/{providerName}:
    get:
      operationId: order_get_payment_link
      tags:
        - /orders
      parameters:
        ...
        - name: customerId
          in: query
          required: true
          example: 123
          schema:
            type: string
        - name: amount
          in: query
          required: true
          example: 2000
          schema:
            type: string
        ...

I can’t understand how can I describe arbitrary optional parameters of type custom, which can be any number and which can be called anything?

GT-Volk
  • 21
  • 5

1 Answers1

1

I honestly don't think you can do this. I double checked the specification and I don't see a way of having custom names.

JSON Schema allows this with keywords like patternProperties but that doesn't fit into a Parameter Object!

Hunting for issues on the spec GitHub I did find this issue, which helps if you are using foo[custom1]=a&foo[custom2]=b

      - in: query
        name: filter
        required: false
        schema:
          type: object
          additionalProperties: true
          example:
            foo: bar
            inputs.datetime.gte: 242839744
        style: deepObject

        # The example translates to:
        # ?filter[foo]=bar&filter[inputs.datetime.gte]=242839744

As for arbitrary top level query parameters? There's no way. At least not in v3.0 or v3.1.

Phil Sturgeon
  • 30,637
  • 12
  • 78
  • 117