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.

External Dtos (i.e. in node_modules) do not keep Api Property options

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

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: image

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:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Feb 21, 2020

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 of tsc. TypeScript compiler won’t generate & modify AST for your JS files from node_modules, this would be ridiculous.

0reactions
lock[bot]commented, Jun 24, 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

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 >

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