api中有一个路径,具有任意数量的近似这种类型的可选参数:
/ orders / 123 / get-payment-link / provider?customerId = 123&amount = 2000& custom1 = custom1&custom2 = custom2 ...
api描述看起来像这样:
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
...
我不明白如何描述custom类型的任意可选参数,该参数可以是任意数字,可以称为任何东西?
答案 0 :(得分:0)
老实说,我认为您不能做到这一点。我仔细检查了规格,但看不到使用自定义名称的方法。
JSON模式允许使用诸如patternProperties之类的关键字,但这不适用于参数对象!
我确实找到了this issue的规范GitHub上的问题,如果您使用的是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
对于任意顶级查询参数?不可能。至少在v3.0或v3.1中没有。