Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hodfords-solutions/nestjs-swagger-helper
A tool for enhancing Swagger documentation in NestJS applications
https://github.com/hodfords-solutions/nestjs-swagger-helper
documentations-generator nestjs nodejs swagger
Last synced: 6 days ago
JSON representation
A tool for enhancing Swagger documentation in NestJS applications
- Host: GitHub
- URL: https://github.com/hodfords-solutions/nestjs-swagger-helper
- Owner: hodfords-solutions
- Created: 2022-11-02T13:44:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-24T04:08:39.000Z (5 months ago)
- Last Synced: 2025-01-30T06:08:47.173Z (14 days ago)
- Topics: documentations-generator, nestjs, nodejs, swagger
- Language: TypeScript
- Homepage: https://opensource.hodfords.uk/nestjs-swagger-helper
- Size: 126 KB
- Stars: 44
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
nestjs-swagger-helper streamlines the integration of Swagger documentation in NestJS applications. It provides utilities and decorators to simplify the creation and management of API documentation, making it easier to keep your API specs up-to-date and accessible.
## 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:
```typescript
// 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
```typescript
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