Assume I have a URL which takes a path of: ?filter[id]=1&filter[name]=bob&order[][name]=asc&order[][age]=desc
How would one be able to convert this into swagger documentation, specifically, array of objects and arrays as the query parameter.
Your example is not an array of objects but two separate object parameters - filter and order[], each serialized using the deepObject style (supported in OpenAPI 3.0). You can describe these parameters as follows:
openapi: 3.0.2
...
paths:
/something:
get:
# ?filter[id]=1&filter[name]=bob&order[][name]=asc&order[][age]=desc
parameters:
- in: query
name: filter
schema:
type: object
properties:
id:
type: integer
example: 1
name:
type: string
example: bob
style: deepObject
- in: query
name: order[]
schema:
type: object
properties:
name:
type: string
example: asc
age:
type: string
example: desc
style: deepObject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With