Basically, I want to set up swagger to accept something like this in the request
[
{
"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"
}
]
I am having some issues with my current setup
- 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
This sets the POST
url to access these items like this
...testing[0][city]=burbank&testing[0][state]=ca
...
When I want to access them like this
...city=burbank&state=ca
... for each city/state/zipcode/input_id pair.
UPDATE:
my new setup is working, besides errors thrown by swagger. It works though!
- 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
If anyone can find a better solution than this (without errors) let me know
I was almost correct in my edit. I just needed to add in
schema:
on the line before addingtype: array
This works and has no errors. I can add multiple objects to my array so it will post in the format I want