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
6
votes
1 answer
FileInterceptor and Body Issue in NestJS (upload a file and data in a request)
I have the following controller :
createCollection(
@UploadedFile() file,
@Body() createCollectionDto: CreateCollectionDto,
@GetUser() user: User,
): Promise {
this.logger.verbose(
`User "${
user.username
…

Ratatinator97
- 109
- 1
- 1
- 12
6
votes
1 answer
Nestjs Swagger - Publishing different API docs on separate routes
I am building an app that has public API and internal one. I would like to publish docs for these to different routes. I thought this would be accomplished by adding only certain tags to document (addTag) but after further reading and experiments it…

PeS
- 3,757
- 3
- 40
- 51
5
votes
0 answers
How to handle the production build of a typescript monorepo (NestJS) with common librairies?
I'm struggling with the production build of a typescript monorepo. The company I'm working for has a mono repository with multiple APIs (nestJS) and few common libraries (mainly typescript source code built using tsc) which I can't sadly share…

Banana Bash
- 85
- 1
- 4
5
votes
1 answer
NestJs + Swagger documentation based on versioning
I have built a nestjs webapi and implemented versioning at controller and action level as per https://docs.nestjs.com/techniques/versioning
The solution i am looking into is, i want to generate 2 different swagger based on the controller…

Sathish
- 159
- 1
- 4
- 18
5
votes
1 answer
NestJS Mapped Types and DTO usage
I'm confused about the mapped types in NestJS.
The documentation says that PartialType create a new class making its validation decorators optional.
So, we use it in our validation pipes as we do with the original classes.
I'm wondering if it's the…

jbdemonte
- 667
- 1
- 7
- 15
4
votes
2 answers
How can I display multiple ResponseDTOs' schemas in Swagger/NestJS?
I have this route which can return one of these two different DTOs:
@Get()
@ApiQuery({ name: 'legacy', description: "'Y' to get houses legacy" })
async findAllHouses(
@Query('legacy') legacy: string,
): Promise

Daisy Jess
- 41
- 1
- 3
4
votes
1 answer
OpenAPI Swagger reusable schema parts
I'm having some challenges while creating the swagger reusable schema components.
I have a lot of APIs in the project and most of them have the same headers and common error responses, of course, every API has its different response schema, to…

Ali Hussnain - alichampion
- 559
- 1
- 5
- 17
4
votes
0 answers
NestJS Swagger oAuth2 (oAuth0) to bearer token in header
this is my code:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerCustomOptions, SwaggerModule } from '@nestjs/swagger';
import * as config from 'config';
import * as crypto from…

Mor Bargig
- 198
- 1
- 7
4
votes
3 answers
Is there a way to hide all the end-point in the controller.ts using a single decorator?
Currently, I am using @ApiExcludeEndpoint() ### on top of all methods to hide the end-point in the swagger-ui, like this:
import { Controller, Get, Query, Param } from '@nestjs/common';
import { ResourceService } from './resource.service';
import…

Vignesh
- 234
- 1
- 3
- 12
4
votes
1 answer
Configure swagger with Nestjs + Azure functions
I am trying to develop my nestjs using azure functions following this article:
https://trilon.io/blog/deploy-nestjs-azure-functions
I have configured Swagger in my application as follows:
...
const options = new DocumentBuilder()
.setTitle('App…

Jacobdo
- 1,681
- 2
- 18
- 38
4
votes
2 answers
How to change query parameters serialization using nestjs/swagger?
Recently I have updated nestjs/swagger package in my project to ^4.0.0. Previously Swagger serialized my query parameters as follows:
/resources?parameter=1,2,3
Now it looks like this:
/resources?parameter=1¶meter=2¶meter=3
DTO object for…

always_bloo
- 165
- 5
- 13
3
votes
1 answer
NestJS: Mongoose timestamp properties in generated OpenAPI spec
I'm using @Schema({ timestamps: true }) to add createdAt & updatedAt to my records and returning these with the response. But seems the OpenAPI spec getting generated by the NestJs's Swagger plugin is not adding the createdAt or updatedAt. How can I…

Milindu Sanoj Kumarage
- 2,714
- 2
- 31
- 54
3
votes
1 answer
Cannot resolve dependencies for @nestjs/swagger
I am trying to install @nestjs/swagger using npm i @nestjs/swagger as per documentation.
I get the following error:
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^9.0.0" from @nestjs/swagger@6.0.3
Any idea what is the issue?I…

Yuvals
- 3,094
- 5
- 32
- 60
3
votes
1 answer
How to install Swagger in Nestjs?
i can't install swagger in my nestjs application. When I try, I get a Error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: test.api@0.0.1
npm ERR! Found: @nestjs/common@8.4.7
npm ERR!…

kowalskijakub
- 45
- 6
3
votes
0 answers
How do I set additionalProperties: false using nestjs/swagger
The Schema was implemented using @ApiBody({type:CreateUserInput})
I need need to be able to prevent it from accepting additional properties according OPENAAPI specification by setting additionalPropeerties:false but i dont know how to implement…

Alvanxl
- 150
- 1
- 6