swagger: openapi does not display nullable schemas
Bug Report
Current behavior
When using the openapi feature i noticed, that some of my nested DTOs are not correctly shown when it is nullable:

when removing nullable: true - the DTO is displayed correctly.
Input Code
@ApiProperty({ type: LogisticsPartnerDTO, nullable: true })
customer!: Nullable<LogisticsPartnerWithLocationRes>;
Expected behavior
I would expect, that the type is shown in the Swagger Docs even though it is nullable.
Environment
"@nestjs/common": "7.6.12",
"@nestjs/core": "7.6.12",
"@nestjs/swagger": "^4.7.13",
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 17 (4 by maintainers)
We’ll bump as soon as the underlying packages (https://www.npmjs.com/package/swagger-ui-dist or
fastify-swagger) support it as well!@kamilmysliwiec I added a test repro repo here
you can see, the reference is broken in this screenshot when looking at the api documentation
For anyone having this same issue, I worked around it by manually specifying the type through the annotation:
@kamilmysliwiec oas 3.1 for swagger has already been released: https://swagger.io/blog/swagger-support-for-openapi-3-0-and-openapi-3-1/. any plans to support the 3.1 format in @nestjs/swagger? you can also see swagger-ui supports 3.1: https://github.com/swagger-api/swagger-ui/tree/v5.0.0
Hi @kamilmysliwiec , is there any plan to bump this package to OAS 3.1?
Looks like progress is being made on the new Swagger editor to support OpenAPI 3.1 https://github.com/swagger-api/swagger-ui/issues/5891#issuecomment-1240769951
https://swagger.io/blog/introducing-the-new-swagger-editor/
Ah I haven’t noticed the explicit type definition in the annotation @zaunermax. Let me reopen this issue.
Can you please provide a minimal reproduction repository?