0

I'm using Swagger OpenApi 3.0.3 and want to use an array field with objects in it. My field definition is the following:

 *          -   name: filter_query
 *              in: query
 *              schema:
 *                  type: array
 *                  items:
 *                      type: object
 *                      properties:
 *                          value:
 *                              type: string
 *                          field_id:
 *                              type: string
 *              description: Filter

If y add two objects to the array a get an array but if I just send one object I receive an object. Am I missing something?!

Enrique
  • 361
  • 4
  • 13
  • Ok I'm checking now the typeof the query and in case it is a string I push it to an array. If there is some better solution please let me know. – Enrique Feb 18 '21 at 22:51
  • OpenAPI 3.0/3.1 [don't support](https://stackoverflow.com/a/52894157/113116) arrays of objects in the query string. The serialization behavior is only defined for primitives, arrays of primitives, and simple non-nested objects. This is probably why it doesn't work. – Helen Feb 19 '21 at 10:25
  • Is redesigning the API an option? One solution would be to make `filter` a free-form object/dictionary ([example](https://stackoverflow.com/q/56279024/113116)) instead of an array of objects. Another would be to use a POST request and send the filter data in the request body. – Helen Feb 19 '21 at 10:28

0 Answers0