typescript-rest-swagger
typescript-rest-swagger copied to clipboard
Add description and externalDocs to @Tags decorator
Hi, how can I add description and externalDocs to Tags?
I saw the Tag interface:
export interface Tag {
name: string;
description?: string;
externalDocs?: ExternalDocs;
}
How can I use it?
Thanks
You can use the spec property of swaggerconfig.json to define your tags, then use the @Tags decorator on your controllers and methods . Example swaggerconfig.json:
{
"swagger": {
"name": "My API",
"version": "1.0.0",
"description": "The best API ever",
"spec": {
"info": {
"termsOfService": "http://example.com/",
"contact": {
"email": "[email protected]"
},
"license": {
"name": "License Agreement",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"tags": [
{
"name": "Person",
"description": "Description of Person tag",
"externalDocs": {
"description": "More info",
"url": "http://example.com/api-info/person"
}
}
]
}
}
}
@ngraef, I've tried change the swaggerConfig.json and didn't work, cause I've forgotten the spec and written the "tags" one level ahead. Thanks, it's working now.
Maybe it should be describe in README.md file. How to use @Tags decorator with description and externalDocs.
Reopening to remind me to add this to the docs.