How do you define an array of different examples in a Swagger spec? -
i'm trying document api static swagger file can return json contains array looks this:
[ { "type": "type a", "field a": "this field specific type a" }, { "type": "type b", "field b": "this field specific type b" } ]
i've tried few different ways of defining spec using either polymorphism or explicitly defining multiple examples. examples have either ended looking like:
[ { "type": "type a", "field a": "this field specific type a", "field b": "this field specific type b" } ]
or just:
[ { "type": "type a", "field a": "this field specific type a" } ]
is there way define example in swagger spec example payload shown swagger-ui contain array containing example of type , example of type b first json wrote?
you can't.
you can define 1 example per mime-type per response :
{ "description": "a response", "schema": { "type": "string" } }, "examples": { "application/json": { "name": "dog" }, "application/xml": { "name": "cat" } } }
if want add complete scenario, suggest write (or generate) full scenario example in html page , link externaldocs. can define externaldocs in root, operations, tags , schemas.
Comments
Post a Comment