NestJs Redoc
This is the documentation for the JuicyLlama NestJs Redoc package.
This package works with Express and is not currently supporting Fastify
Install
Install the package into your project:
pnpm install @juicyllama/core
Usage
- Setup the main
DocumentBuilder
in your application root (normallymain.ts
):
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { RedocModule, RedocOptions } from '@juicyllama/core'
const swagger_document = new DocumentBuilder()
.setTitle('Look, i have a title')
.setDescription('A very nice description')
.setVersion(process.env.npm_package_version)
.setBasePath('/api/v1')
.build()
const document = SwaggerModule.createDocument(app, options)
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,
tagGroups: [
{
name: 'Core resources',
tags: ['cats'],
},
],
}
await RedocModule.setup('/docs', app, document, redocOptions)
Redoc Options
Click here for a full list of the redoc options you can pass.
- Controllers
You can specify inside your controller that a tag
should be added by putting the @ApiTags('cats')
above the @Controller
import { ApiTags } from '@nestjs/swagger'
@ApiTags('cats')
@Controller('cats')
- Abstracted Decorators
As part of the JuicyLllama core package we have made available a number of abstracted decorators to handle the most common CRUD operations.
Example Project
If you are just getting started, we recommend setting up our quickstart client project. This will get you up and running quickly adopting framework best practise.