rsiena
6 years agoNew Contributor
Solved
What is the correct way to define a result type of array of objects
1. is this definition correct to return a variable size array of list items? responses: 200: description: List Returned schema: type: object format: array properties: ListID: type: integer ...
- 6 years ago
Thanks for the example. In this case, you'd describe it as follows:
responses: 200: description: List Returned schema: type: array items: type: object properties: ListID: type: integer format: int64 description: ID of the list ListName: type: string description: List name ListItem: type: string description: List Item Text Abbreviation: type: string description: Abbreviation text if applicable
Notice that you describe the type as 'array', and then under 'item' you describe the type that you want the array to have - in this case it's an object. Just like in other places in the definition, you can also use a $ref to reference a 'Language' definition, and reuse that elsewhere if needed.