10.1.2 • Published 10 months ago

@hodfords/nestjs-swagger-helper v10.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Installation 🤖

Install the nestjs-swagger-helper package with:

npm install @hodfords/nestjs-swagger-helper --save

Next, create a file named swagger-helper.config.ts and add the following code. Then, include it in your 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);

Import the SwaggerHelper and use it to initialize Swagger

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();
}

Usage 🚀

Decorators

The library provides two decorators you can use:

  • @ApiPublic: Marks APIs as public.
  • @ApiSetValue: Typically used for login/signin APIs to automatically add a JWT token to Swagger when the request is successful.

License 📝

This project is licensed under the MIT License

10.1.0

11 months ago

10.1.1

10 months ago

10.1.2

10 months ago

10.0.1

1 year ago

10.0.2

1 year ago

10.0.0

1 year ago

8.0.0

2 years ago

1.0.0

3 years ago