@xmotion/nestjs-redoc
v1.0.7
Published
Redoc wrapper on NestJS
Downloads
91
Maintainers
Readme
NestJS - Redoc
This project is a simple example of how to use Redoc with NestJS.
Installation
You can install the module using npm or yarn:
npm install @xmotion/nestjs-redoc
or
yarn add @xmotion/nestjs-redoc
How to use
You need to install the Swagger Module first if you want to get definitions updated with your project.
In future versions you will be able to pass a URL parameter as document, but for the moment you need this document object from the swagger module
const options = new DocumentBuilder()
.setTitle('Look, i have a title')
.setDescription('A very nice description')
.setBasePath('/api/v1')
.build();
const document = SwaggerModule.createDocument(app, options);
Then add the following example code.
Note: All properties are optional, if you don't specify a title we will fallback to the one you used in your DocumentBuilder instance.
const redocOptions: RedocOptions = {
title: 'Hello Nest',
logo: {
url: 'https://redocly.github.io/redoc/petstore-logo.png',
backgroundColor: '#F0F0F0',
altText: 'PetStore logo'
},
sortPropsAlphabetically: true,
hideDownloadButton: false,
hideHostname: false,
auth: {
enabled: true,
user: 'admin',
password: '123'
},
tagGroups: [
{
name: 'Core resources',
tags: ['cats'],
},
],
};
// Instead of using SwaggerModule.setup() you call this module
await RedocModule.setup('/docs', app, document, redocOptions);
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request on the GitHub repository.
License
This module is licensed under the MIT License.