Reputation: 87
Is it possible to provide a response example that is an object with an array attribute and a string attribute?
I have the following OpenAPI 3 definition:
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"examples": {
"results": [
{
"abc": 20
}
],
"totalCount": 69
},
"schema": {
"results":"array",
"totalCount": "integer"
}
}
}
}
}
But Swagger UI shows an error when I put "totalCount": 69
inside the examples
object.
Upvotes: 3
Views: 6773
Reputation: 97677
Change examples
(plural) to example
(singular), and also provide a proper schema
for the response.
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"example": {
"results": [
{
"abc": 20
}
],
"totalCount": 69
},
"schema": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"abc": {
"type": "integer"
}
}
}
},
"totalCount": {
"type": "integer"
}
}
}
}
}
}
}
Upvotes: 3