warspite
5 years agoNew Contributor
Response mixing object and number in an array
I am trying to model the following structure (taken from Paypal API guidelines) into openapi 3.0.0 I have no problem getting the object users in the array, but I cannot get the total_items and to...
- 5 years ago
"users" is an array of objects. Those individual objects are currently defined with the given_name and surname properties, but you can define additional properties as required.
Maybe if you replace inline schemas with named schemas it will be easier to understand.
paths: /results: get: responses: "200": description: OK content: application/json: schema: $ref: '#/components/schemas/Results' components: schemas: User: type: object properties: given_name: type: string maxLength: 50 example: James surname: type: string maxLength: 50 example: Greenwood ... # <---- Define other user properties here Results: type: object properties: total_items: type: integer example: 116 total_pages: type: integer example: 12 users: description: An array of users type: array items: $ref: '#/components/schemas/User' example: - given_name: James surname: Greenwood ... # <---- Add example values here - given_name: David surname: Brown ... # <---- Add example values here