@marxlnfcs/nest-swagger-decorators
v0.4.2
Published
Extended decorators for the @nestjs/swagger module
Downloads
47
Readme
Installation
npm i @marxlnfcs/nest-swagger-decorators
Usage
Controller
@ApiController('/', {
tags: [ ... ],
tagGroups: [ ... ],
header: { ... },
params: { ... },
query: { ... },
})
export class AppController {}
@ApiController({
path: '/',
tags: [ ... ],
tagGroups: [ ... ],
header: { ... },
params: { ... },
query: { ... },
})
export class AppController {}
// Controller will not be added to the documentation. Equals to @ApiExcludeController
@ApiController('/', false)
export class AppController {}
Routes
@ApiController('/')
export class AppController {
@ApiGet('/', { ... })
@ApiGet({ path: '/', ... })
@ApiGet('/', false) // Endpoint will not be added to the documentation. Equals to @ApiExcludeEndpoint
ping(){ ... }
}
Exceptions
@ApiController('/')
export class AppController {
@ApiGet('/')
@ApiNotFoundException()
@ApiUnauthorizedException()
ping(){ ... }
}
TagGroups
@ApiController('/')
@TagGroups(...)
export class AppController {
@ApiGet('/', { ... })
@ApiTagGroups(...)
ping(){ ... }
}
Retrieve TagGroups
import {getApiTagGroups} from "@marxlnfcs/nest-swagger-decorators";
const tagGroups = getApiTagGroups();
/**
* RETURNS:
* [
* {
* name: string,
* tags: string[]
* },
* ...
* ]
*/