Skip to main content

Responses

It is possible to create or complement automatically detected responses. Use the #swagger.reponses[statusCode] to create a new response or to complete an existing response (automatically detected).

All optional parameters:

/* #swagger.responses[<number>] = {
description: <string>,
content:
"<content-type>" application/json, application/xml, etc
schema: <object> or <Array>
} */

description: The parameter description.
schema: See section Schemas and Components

Example #1
app.get('/path', (req, res, next) => {
...
/* #swagger.responses[200] = {
description: "Some description...",
content: {
"application/json": {
schema:{
$ref: "#/components/schemas/User"
}
}
}
}
*/
...
})
Example #2 (without declaring the content)
app.post('/path', (req, res) => {
...
/* #swagger.responses[200] = {
description: 'Some description...',
schema: { $ref: '#/components/schemas/someSchema' }
} */
...
});

NOTE: The response content in the Example #2 will be generated automatically with application/json and application/xml.

For more information about schema, see the section Schemas and Components