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
3
votes
0 answers
nestjs-swagger - issue in generating client code with generics
I have a nestjs project in which I am using nestjs-swagger for generating open API spec. I am using that to auto-generate client code for typescript-axios. The issue is that the client code is not generating generics properly. In the attached github…

optimus
- 76
- 3
3
votes
0 answers
NestJs: Combining swagger and class-transformer with mapped types
Is there a way of using mapped-types with swagger and class-transformer
Got a example of whats going wrong here:
https://stackblitz.com/edit/nestjs-starter-demo-aq1sw2?file=src/dtos/user-descriptor.dto.ts
The DTOs:
ProjectDescriptorDto
// import {…

JDU
- 31
- 3
3
votes
3 answers
NestJs Swagger: How to define Api Property for dynamic classes
I have below class
export class DocumentsSteps {
@ApiProperty({type: ???})
[type: string]: DocumentStep;
}
How should I define ApiProperty type?

Reza
- 18,865
- 13
- 88
- 163
3
votes
2 answers
Is there a way to declare a default value when using @ApiQuery with nestJS and swagger?
EDIT: found a solution thanks to the comment suggesting to use a DTO. Answer detailed at the bottom.
The NestJS website has documentation to [declare default values][1] when using @ApiBody(), is there a way to do so with @ApiQuery()? (i.e. show in…

Cris
- 209
- 2
- 10
3
votes
2 answers
How do I annotate an endpoint in NestJS for OpenAPI that takes Multipart Form Data
My NestJS server has an endpoint that accepts files and also additional form data
For example I pass a file and a user_id of the file creator in the form.
NestJS Swagger needs to be told explicitly that body contains the file and that the endpoint…

auerbachb
- 857
- 11
- 25
3
votes
2 answers
Add Swagger base path field in Nest.js project
I am trying to use nestjs/swagger to create a swagger file from my back-end and I am facing a problem related to the base path. What I want to achieve is to show version as base path instead of showing it in all the methods available, which is ugly…

msolefonte
- 153
- 1
- 11
2
votes
0 answers
Swagger Docs multipart/form-data array format (NestJs)
I've the following dto:
export class CreatePersonDto {
@IsString()
@ApiProperty({
description: 'Person name',
example: 'Jhon Doe',
})
readonly name: string;
@ValidateIf((object, value) => value)
@IsString({ each: true })
…

JuanDa237
- 276
- 3
- 16
2
votes
0 answers
How can I provide multiple Swagger examples inside a DTO with NestJS?
I have a DTO that has several properties, including creditCard, creditCardToken, googlePay, applePay. Only one of these properties can exist at a time, so I would like to provide four…

uPaymeiFixit
- 153
- 1
- 11
2
votes
2 answers
Swagger UI route giving 404 Not found error - NestJs Swagger Module
On my localhost, swagger-ui document API route is working fine - http:://localhost:3000/api.
But, when I deployed the nestjs build on server (AWS with Apache server), the same route is not working.
In nestjs "main.ts" file, following code is written…

Rhythm
- 41
- 6
2
votes
2 answers
How to authorize multi api keys using @nestjs/swagger and @UseGuards?
I'm using @UseGuards to validate two api keys in header.
@Injectable()
export class AuthGuard implements CanActivate {
canActivate(context: ExecutionContext): boolean {
// check two api keys('some' and 'thing') in header at once
}
Also, I'm…

rin
- 65
- 1
- 7
2
votes
2 answers
Using @nestjs/swagger swagger-ui-express, my setup was ok, but each time I run the app, I get TypeError: shared_utils_1.validatePath is not a function
Here is my configuration
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule} from "@nestjs/swagger";
async function bootstrap() {
const app = await…

Fjay
- 77
- 9
2
votes
2 answers
Nestjs + Swagger: How to add a custom option to @ApiProperty
Is it possible to add a custom option to @ApiProperty decorator?
import { ApiProperty } from '@nestjs/swagger';
class Animal {
@ApiProperty({
type: String,
description: 'animal name',
'x-description': 'some information' // how to add…

KDI
- 81
- 1
- 7
2
votes
1 answer
How to use type (typescript type) in swagger @ApiProperty type
I'm facing a problem.
I need to expose a 'type' in an @ApiProperty of swagger on my API.
But swagger don't accept it. I looked in many website to find solution but I did not find any.
Here is the error I get:
TS2693: 'testTest' only refers to a…

G. Frx
- 2,350
- 3
- 19
- 31
2
votes
0 answers
Nestjs/swagger: Avoid some Dtos to be shown on list schemas
I'm using some auxiliary Dtos on my rest API, mainly when occurs some error and I use an @ApiResponse, but I don't want to show them as available schemas on the list at the end of the doc.
I have for example:
@ApiConflictResponse({
type:…

MML1357
- 137
- 10
2
votes
0 answers
NestJS OpenAPI TS types missing entities
I've got a NestJS app with Mikro-ORM and I'm generating OpenAPI TS types using openapi-typescript for the front-end. I'm using the @ApiProperty decorator to add types to the entity relations, but only one of the two identical relations is being…

SimpleJ
- 13,812
- 13
- 53
- 93