OAuth2
The security example below was taken from the original Swagger documentation.
const doc = {
...
components: {
securitySchemes:{
OAuth2: {
type: 'oauth2',
flows: {
authorizationCode: {
authorizationUrl: 'https://example.com/oauth/authorize',
tokenUrl: 'https://example.com/oauth/token',
scopes: {
read: 'Grants read access',
write: 'Grants write access',
admin: 'Grants access to admin operations'
}
}
}
}
}
}
};
To see more about the properties of the doc
object, see the Advanced Usage section.
At the endpoint, add the #swagger.security
tag, for example:
Example endpoint:
app.get('/path', (req, res) => {
...
/* #swagger.security = [{
"OAuth2": [
'read',
'write'
]
}] */
...
});