1.4.1 • Published 3 years ago

@skybackend/nestjs-swagger-api-exception-decorator v1.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@nanogiants/nestjs-swagger-api-exception-decorator

Node.js CI Quality Gate Status Coverage npm npm downloads

NestJS Swagger decorator for API exceptions

Installation

$ npm install @nanogiants/nestjs-swagger-api-exception-decorator

Example usage

import { ApiException } from '@nanogiants/nestjs-swagger-api-exception-decorator';

@ApiException(() => UnauthorizedException)
export class Controller {
  @ApiOperation({ summary: 'Changes the users password' })
  @ApiException(() => [PasswordsDidNotMatchException, OldAndNewPasswordMatchException, CredentialsNotValidException])
  @Patch('/password')
  async changeUserPassword(@Res() res: Response): Promise<void> {
    return res.sendStatus(HttpStatus.OK);
  }
}

Documentation

Please visit our documentation for examples and information on how to use this decorator.