Skip to main content

Produces and Consumes

Use the #swagger.produces or #swagger.consumes to add a new produce or a new consume, respectively.

Produces example

Example #1
app.get('/path', (req, res) => {
...
// #swagger.produces = ['application/json']
...
});

Consumes example

In the examples below, the two endpoints will have the same result in the documentation.

Example #2
app.get('/path', (req, res) => {
...
// Recognizes the 'consumes' automatically
res.setHeader('Content-Type', 'application/json');
...
});
Example #3
app.get('/path', (req, res) => {
...
// #swagger.consumes = ['application/json']
...
});