@hodfords/nestjs-swagger-helper
TypeScript icon, indicating that this package has built-in type declarations

10.0.2 • Public • Published

Nest Logo

Swagger Helper

Description

Configuration

  • Create file a file named swagger-helper.config.ts with this code below and then add to app.module.ts file
// APP_PREFIX is optional, if your application doesn't have this one you can skip
export const swaggerConfig = SwaggerHelperModule.forRoot(APP_PREFIX);
  • Initialize SwaggerHelper: Import the SwaggerHelper and pass these params to initialize it
import { SwaggerHelper } from '@hodfords/nestjs-swagger-helper';

type SwaggerInitialization = {
    app: NestExpressApplication;
    appEnv: string;
    path: string;
    title: string;
    description: string;
    version: string;
    disablePrivateDocument: boolean;
};

buildSwagger() {
    new SwaggerHelper({
        app: this.app,
        appEnv: env.APP_ENV,
        path: `${env.APP_PREFIX}/documents`,
        title: 'Document for usdol',
        description: 'The usdol API description',
        version: '1.0',
        disablePrivateDocument: env.APP_ENV === 'production',
    }).buildDocuments();
} 

Decorators

The library has 2 decorators that you can import to your project

  • @ApiPublic (mark which APIS are for public)
  • @ApiSetValue (usually add to login/signin API to automatically add jwt-token to swagger when requesting successfully)

Readme

Keywords

none

Package Sidebar

Install

npm i @hodfords/nestjs-swagger-helper

Weekly Downloads

43

Version

10.0.2

License

ISC

Unpacked Size

153 kB

Total Files

33

Last publish

Collaborators

  • nguyentiendung-dev