@marxlnfcs/nest-swagger-decorators
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

NestJS OpenApi Extended Decorators

Extended decorator functions for the @nestjs/swagger module

NPM Version Package License NPM Downloads Package Size

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[]
 *  },
 *  ...
 * ]
 */

Readme

Keywords

none

Package Sidebar

Install

npm i @marxlnfcs/nest-swagger-decorators

Weekly Downloads

3

Version

0.4.2

License

MIT

Unpacked Size

242 kB

Total Files

133

Last publish

Collaborators

  • marxlnfcs