Reputation: 10324
While using swagger-editor I create the below YAML that shows an example of the response object. It's properly displaying in the swagger-editor. When I then download the JSON and display it in swagger-ui, the example is completely missing.
/person/{email}/create:
post:
summary: Create a new account
tags:
- Person
parameters:
...
responses:
201:
description: The new SQL ident and sport details
examples:
application/json: |
[
12,
[
{
"sql_idnet" : 12,
"name" : "Basketball"
},
{
"sql_ident" : 13,
"name" : "Ice Hockey"
}
]
]
Upvotes: 8
Views: 20199
Reputation: 1
First I have added schema, second there was no main key so i added "response" key word to show in example drop down I followed this documentation added content and application/json under responses
Try this one,
/person/{email}/create:
post:
summary: Create a new account
tags:
- Person
parameters:
...
responses:
201:
description: The new SQL ident and sport details
content:
application/json:
schema:
type: array
examples:
response:
value:
[
12,
[
{
"sql_idnet" : 12,
"name" : "Basketball"
},
{
"sql_ident" : 13,
"name" : "Ice Hockey"
}
]
]
Upvotes: 0
Reputation: 1
Swagger UI and Swagger Editor currently do not support multiple examples. You can follow this issue for updates.
Upvotes: 0
Reputation: 97697
This might be because the response does not have a schema
- in Swagger this means the response does not have a body.
That said, Swagger UI 3.0 displays this example correctly.
Upvotes: 2