Reputation: 780
I have some problem with swagger. When I think I understand how it works, there's always something that doesn't work
What's wrong in thoses line
responses:
'200':
allOf:
- $ref: '../index.yaml#/components/responses/200Ok'
content:
application/json:
schema:
allOf:
- $ref: '../index.yaml#/components/schemas/Pagination'
properties:
data:
type: array
items:
schema:
$ref: '../index.yaml#/components/schemas/Client'
The "data" property should be an array of the schema type given in the $ref, but this is the result
"data": [
null
]
Ok, it seems that the right way is tu put the $ref directly under the items key, my problem was the use of a reserved key "status" So, how can I use a reserved key in a object schema?
in my Client schema I put the property status two times, I didn't see that it was already there, so when I changed the property name it worked and I was thinking that maybe "status" was a reserved keyword.
Upvotes: 0
Views: 4291
Reputation: 97540
You are almost there. There are two issues:
1) You can't have allOf
directly under a response code. You can $ref
the whole response definition though.
2) You don't need schema
under items
.
Also, while putting allOf
alongside other keywords is perfectly fine, some tools may like it better if all schemas being combined are listed inside allOf
.
Try this version:
responses:
'200':
description: OK
content:
application/json:
schema:
allOf:
- $ref: '../index.yaml#/components/schemas/Pagination'
- properties:
data:
type: array
items:
$ref: '../index.yaml#/components/schemas/Client'
Upvotes: 1