0

I want to write a API that would respond with an array. My OpenAPI description looks like this:

definitions:
  DeviceArray:
    type: array
    items:
      type: string
    example:
      - {"DeviceID": 103609131103,"NetworkName": "nzp-20007-gnd-rt-01","RelativeName": "NZP-20007-GND-RT-01.PST.SYTECNMS.NET","Type": null}
      - {"DeviceID": 105621398103,"NetworkName": "nzp-20007-gnd-as-01","RelativeName": "NZP-20007-GND-AS-01.PST.SYTECNMS.NET","Type": null}
      - {"DeviceID": 122403148102,"NetworkName": null,"RelativeName": "BEAS/U_NTU_001","Type": "NTU"}
      - {"DeviceID": 165002297102,"NetworkName": null,"RelativeName": "BEAS/G_HSNS SDP_001","Type": "Alcatel MSAP"}
      - {"DeviceID": 165002320102,"NetworkName": "10.6.194.126","RelativeName": "BEAS/G_ONEA1424X_001","Type": "OneAccess IAD/Router"}
      - {"DeviceID": 160885080102,"NetworkName": null,"RelativeName": "BEAS/U_CISCO_1921_001","Type": "Cisco Packet Switch"}

But the response I get is:

[
""
]

How do I solve this problem?

1
  • What do you mean by "response I get" - the actual response from your API, the rendered model examples, something else? Btw, you are using an old version of the editor, try editor.swagger.io. Commented Nov 10, 2017 at 8:17

1 Answer 1

1

This is not type: string obviously, you need to set the type to type: object and either define it directly:

type: array
items:
  type: object
  properties:
    DeviceID:
      type: string
    NetWorkName:
      type: string
    RelativeName:
      type: string

or reference an object if you have already defined it:

type: array
items:
  $ref: '#/yourObjectReference'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.