schema of the responses when response parameters are repeated itself
Hi!
i want to ask about the responses like: If the api returns the list of all the users then in the response there is a list of users and each user having the same parameters like this:
then in the schema of this response how i can write in the yaml?
i had wriiten it as:
getallUsers:
properties:
properties:
id:
type: integer
code:
type: string
if i make the objects and arrays then it shows the error of duplicated key etc. If anyone have any idea kindly guide me
If you mean array examples with multiple items, that's supported in OpenAPI 2.0 too. The "example" keyword needs to be alongside "type: array", like so:
responses: '200': description: A list of users schema: type: array items: $ref: '#/definitions/User' example: # <--- on the same level as "type: array" - id: 1 code: 2y1 - id: 2 code: 2y1
If you mean multiple different examples for the same response or parameter, that's only supported in OpenAPI 3.0.