Object of object of array in Swagger

Viewed 98

I have an input in the below format:

{"value" : {"codes": ["123","234"]} }

I have a swagger document as below but it does not yield the above result

/v1/search:
 post:
  summary: Get values
  description: Get values
  parameters:
    - name: value
      in: body
      schema:
        properties:
          value:
            type: array
            items:
              $ref: "#/definitions/Values"
definitions:
  Values:
   type: object
   properties:
     codes:
       type: string

Any leads would be appreciated.

1 Answers

Try this. I used Value and Codes as schema names, but feel free to change them as you see fit.

    - name: value
      in: body
      schema:
        $ref: '#/definitions/Value'

definitions:
  Value:
    type: object
    properties:
      value:
        $ref: '#/definitions/Codes'

  Codes:
    type: object
    properties:
      codes:
        type: array
        items:
          type: string
Related