The OpenAPI specification is a language-agnostic definition format used to describe RESTful APIs. Nest provides a dedicated module that allows generating such a specification by leveraging decorators.
Questions tagged [nestjs-swagger]
152 questions
2
votes
2 answers
How to pass nested class to type in @ApiOkResponse or create appropriate custom decorator?
Background:
I used nestjs interceptor to put returned data from controller inside data property and add some other properties. Now I'd like to use @ApiOkResponse that would reflect the nested properties.
Controller returns
{
prop1: 'val1',
…

Max
- 93
- 3
- 7
2
votes
0 answers
Nestjs Swagger - import types wrong node module
I have a package A that exports some types and functions and a package B that use package A as a dependency and export also other types and functions.
I import package A and package B in a package C as dependencies. When I use a type from package A,…

bpAphilia
- 21
- 3
1
vote
0 answers
Nest Js Swagger Circular Dependency Issue while using generic typed class
While I am having a generic class (a class taking a generic type as its input) as the type in a swagger @ApiResponse decorator, I am seeing a circular dependency issue as follows:
throw new Error(`A circular dependency has been detected…

Pradip
- 509
- 1
- 5
- 22
1
vote
0 answers
Nestjs Swagger - introspectComments - How to pass @ApiTags, @ApiOperation and @ApiResponse responses in the comments?
Nestjs Swagger - introspectComments - How to pass following options in plain comments?
@ApiTags
@ApiOperation - Especially the operationId
@ApiResponse
@Controller()
export class MyController {
@ApiTags('MyController')
@ApiOperation({
…

Dinesh
- 1,711
- 2
- 20
- 41
1
vote
0 answers
Nest js Swagger UI not loading
in the browser I'm getting this error and the UI is not loading
enter image description here.
This is my swagger document config (main.ts)
const config = new DocumentBuilder()
.setTitle('Truffles API')
.setDescription('Truffles API…

Auralshin
- 13
- 1
1
vote
1 answer
Unable to add '[]' to @Query name. Tried multiple ways
I am using @nestjs/swagger for API documentation. I want my queryParam to be features[] and not features when swagger makes the request.
Nest searches for @Query in route handlers and documents automatically.
The SwaggerModule searches for all…

Kaustubh Chaturvedi
- 13
- 2
1
vote
0 answers
Hide specific route from different Swagger documents with NestJS
Introductory: have a NestJS app with 2 different swagger routes(api/test1 and api/test2).
In main.ts construct swagger with
const app = await NestFactory.create(AppModule, {
logger: new CustomLogger(),
});
await constructSwagger(app,…

Nikitonu4
- 41
- 2
1
vote
0 answers
How to hide particular Schemas/models that are shown in end of swagger documentation page in NestJS?
I want to hide some schemas from the Swagger documentation page in NestJS. I have already checked the issue but it is for hiding all the schemas.
I want to show only few schemas in the documentation page. I have tried renaming the DTO from file name…

Suhail Akhtar
- 1,718
- 15
- 29
1
vote
0 answers
Nest JS swagger API response body from third party package
I am writing a REST API swagger in Nest JS.
My code snippet looks like this:
@Get()
@ApiOperation({
summary: `Something`,
description: `Something`,
})
@ApiOkResponse({
description: 'The resources were returned successfully',
…

Pradip
- 509
- 1
- 5
- 22
1
vote
2 answers
Is it possible to Inject the NestJS app created in main.ts into a module service?
Assuming you have the basic NestJS setup:
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors(corsOptions);
app.useGlobalPipes(
new ValidationPipe({
validateCustomDecorators: true,
…

diegoolavarriau
- 71
- 6
1
vote
1 answer
Prevent default response code in Swagger/OpenAPI definition with NestJS
What I'm trying
I'm implementing a DELETE route using NestJS.
Since the route is only ever supposed to return a HTTP 204 No Content on successful deletion, utilizing the @nestjs/swagger decorators, I've annotated it as follows:
@ApiParam({
name:…

MaxRumford
- 175
- 10
1
vote
3 answers
How to add nested dto in nestjs?
I'm trying to create a DTO that has another DTO as array, but when sending the body, nestjs/swagger not detecting the body content.
My DTOs are:
export class CreatePageDto {
@ApiHideProperty()
createAt: Date;
@ApiHideProperty()
updateAt:…

Álex Goia
- 15
- 4
1
vote
1 answer
NestJS - ApiProperties not applied by swagger when nested more than 1 level
I'm trying to apply @ApiProperty({ format: "date-time" }) to a nested field in a class. If I do this this at the first level, this works fine. Same If I do it in a field nested within an object. But If I go a level deeper the formatting stops…

Jorge Rodriguez RV
- 61
- 1
- 3
1
vote
1 answer
NestJs/Swagger: How to add `additionalProperties: false` on an existing DTO class
Hello I am new to Nestjs and trying to implement additionalProperties: false on a DTO class that already has properties on it. I see that the additionalProperties key can be added inside @ApiProperty({ schema: ... { additionalProperties : false} })…

ttemple
- 1,825
- 2
- 17
- 12
1
vote
1 answer
NestJS Open API nested DTOs and PartialType
I have a setup like this:
export class RequestDTO {
@ApiProperty()
mainObj: MainObjDTO;
}
export class MainObjDTO {
@ApiProperty()
latLong: LatLongDTO
}
export class LatLongDTO {
@ApiProperty()
lat: string;
@ApiProperty()
long:…

MB.
- 4,167
- 8
- 52
- 79