如何传递 1 个或多个包含 4 个字符串的数组以大摇大摆地请求?
How to pass 1 or more arrays of 4 strings to request in swagger?
基本上,我想设置 swagger 以在请求中接受这样的内容
[
{
"input_id": "",
"city": "",
"state": "",
"zipcode": "20500"
},
{
"input_id": "",
"city": "Cupertino",
"state": "CA",
"zipcode": ""
},
{
"input_id": "",
"city": "",
"state": "",
"zipcode": "95014"
},
{
"input_id": "Apple",
"city": "Cupertino",
"state": "ca",
"zipcode": "90210"
}
]
我当前的设置有一些问题
- name: testing
in: query
description: 'zip request info'
type: array
items:
type: object
properties:
input_id:
type: string
city:
type: string
state:
type: string
zipcode:
type: string
这会设置 POST
url 像这样访问这些项目
...testing[0][city]=burbank&testing[0][state]=ca
...
当我想像这样访问它们时
...city=burbank&state=ca
...每 city/state/zipcode/input_id 对。
更新:
除了 swagger 抛出的错误外,我的新设置工作正常。虽然它有效!
- name: City/State pair or ZIP Code
in: body
description: 1 or more
type: array
items:
minimum: 1
type: object
properties:
input_id:
type: string
description: A unique identifier for this address used in your application; this field will be copied into the output
city:
type: string
description: The city name
state:
type: string
description: State name or abbreviation
zipcode:
type: string
description: The 5-digit ZIP Code
如果有人能找到比这更好的解决方案(没有错误)让我知道
我的编辑几乎是正确的。我只需要在添加 type: array
之前在行中添加 schema:
name: 'City/State pair or ZIP Code'
in: body
description: 1 or more
schema:
type: array
items:
type: object
properties:
input_id:
type: string
description: A unique identifier for this address used in your application; this field will be copied into the output
city:
type: string
description: The city name
state:
type: string
description: State name or abbreviation
zipcode:
type: string
description: 'The 5-digit ZIP Code'
这有效并且没有错误。我可以将多个对象添加到我的数组中,这样它将 post 以我想要的格式
基本上,我想设置 swagger 以在请求中接受这样的内容
[
{
"input_id": "",
"city": "",
"state": "",
"zipcode": "20500"
},
{
"input_id": "",
"city": "Cupertino",
"state": "CA",
"zipcode": ""
},
{
"input_id": "",
"city": "",
"state": "",
"zipcode": "95014"
},
{
"input_id": "Apple",
"city": "Cupertino",
"state": "ca",
"zipcode": "90210"
}
]
我当前的设置有一些问题
- name: testing
in: query
description: 'zip request info'
type: array
items:
type: object
properties:
input_id:
type: string
city:
type: string
state:
type: string
zipcode:
type: string
这会设置 POST
url 像这样访问这些项目
...testing[0][city]=burbank&testing[0][state]=ca
...
当我想像这样访问它们时
...city=burbank&state=ca
...每 city/state/zipcode/input_id 对。
更新:
除了 swagger 抛出的错误外,我的新设置工作正常。虽然它有效!
- name: City/State pair or ZIP Code
in: body
description: 1 or more
type: array
items:
minimum: 1
type: object
properties:
input_id:
type: string
description: A unique identifier for this address used in your application; this field will be copied into the output
city:
type: string
description: The city name
state:
type: string
description: State name or abbreviation
zipcode:
type: string
description: The 5-digit ZIP Code
如果有人能找到比这更好的解决方案(没有错误)让我知道
我的编辑几乎是正确的。我只需要在添加 type: array
schema:
name: 'City/State pair or ZIP Code'
in: body
description: 1 or more
schema:
type: array
items:
type: object
properties:
input_id:
type: string
description: A unique identifier for this address used in your application; this field will be copied into the output
city:
type: string
description: The city name
state:
type: string
description: State name or abbreviation
zipcode:
type: string
description: 'The 5-digit ZIP Code'
这有效并且没有错误。我可以将多个对象添加到我的数组中,这样它将 post 以我想要的格式