External Dtos (i.e. in node_modules) do not keep Api Property options
See original GitHub issueI’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
This behaviour: https://github.com/nestjs/swagger/issues/529
Dtos from within the src
folder are rendered with optional properties as optional. Dtos from outside the src
folder (that have been created and compiled with nest) are rendered as required:
Expected behavior
Since the js of the compiled EXTERNAL dtos have references to IsOptional
, and also have the language specifc ‘?’ syntax before them, they should be shown as optional.
Minimal reproduction of the problem with instructions
Attached is a repo: https://github.com/cjancsar/regression-external-dto-nestjs Note: it pulls the external DTO from the published package here:
What is the motivation / use case for changing the behavior?
This is a bug.
Environment
Nest version: 6.11.8 (common)
Others:
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Modules | NestJS - A progressive Node.js framework
Modules. A module is a class annotated with a @Module() decorator. The @Module() decorator provides metadata that Nest makes use of to organize...
Read more >Getting started with continuous integration for Nest.js APIs
Learn how to build RESTful APIs with Nest.js, a Node.js framework built with TypeScript, and automate testing using CircleCI.
Read more >How to make node.js require absolute? (instead of relative)
And what about: var myModule = require.main.require('./path/to/module');. It requires the file as if it were required from the main js file, ...
Read more >Part 1: Developing Backend APIs with Nest.js
Part 1: Developing the backend API with Nest.js. ... To keep things simple, you are not going to interact with any external database, ......
Read more >How to fix "The following module is missing from the file ...
However with Drupal 8 being so young, things don't go as planned always). Write an update hook in a custom module. You can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve already replied to this issue and you ignored my response.
This is not a bug - Plugin won’t run for
node_modules
. If you have external packages which export DTOs, all its files should be already compiled with Nest CLI, and hence, have the metadata in the generated JS files. Thus,@nestjs/swagger
will use this pregenerated metadata. Just ensure to compile packages with Nest CLI (and plugin enabled) instead oftsc
. TypeScript compiler won’t generate & modify AST for your JS files from node_modules, this would be ridiculous.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.