question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ApiProperty not working with swagger plugin on DTO classes

See original GitHub issue

I’m submitting a…


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using the plugin @nestjs/swagger/plugin is not possible to override the api properties in a DTO class that is used with a @Body decorator in a controller. This causes the error Uncaught SyntaxError: Unexpected identifier when trying to use swagger ui

Expected behavior

Being able to override the api properties of the class while using the plugin

Minimal reproduction of the problem with instructions

Add @ApiProperty() to one of the properties in the class CreateCatDto from the sample https://github.com/nestjs/nest/tree/master/sample/11-swagger

What is the motivation / use case for changing the behavior?

Being able to be more descriptive on specific endpoints (description, examples, etc…)

Environment


Nest version:
- platform-express version : 6.10.14
- passport version         : 6.1.1
- swagger version          : 4.1.2
- typeorm version          : 6.2.0
- common version           : 6.10.14
- core version             : 6.10.14
- jwt version              : 6.1.1

 
For Tooling issues:
- OS Version     : Linux 5.0
- NodeJS Version : v10.18.0
- NPM Version    : 6.13.4

Others:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, Jan 7, 2020

Fixed in 4.1.4

0reactions
lock[bot]commented, Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to avoid to write `@ApiProperty()` in each dto for NestJs ...
I know there is exist a way to create file nest-cli.json , and if you specify Promise<DTO> in your controller in nest-swagger it...
Read more >
CLI Plugin - OpenAPI - A progressive Node.js framework
The Swagger plugin will automatically: annotate all DTO properties with @ApiProperty unless @ApiHideProperty is used; set the required property depending on ...
Read more >
Using a dynamic DTO property in a NestJS API
The dynamic meta data issue. The interesting problem here is how do we store and retrieve different classes for different TriggerTypeEnum values ...
Read more >
API with NestJS #60. The OpenAPI specification and Swagger
We can use the @ApiProperty() decorator to annotate class properties. register.dto ...
Read more >
Integrating Swagger/OpenAPI with NestJS - codeburst
Here, we add the @nestjs/swagger/plugin to the plugins array. That's it. We can also remove the @ApiProperty() decorator from the task DTO, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found