swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Ability to specify dto paths in swagger cli plugin options

Open joeybenenati opened this issue 6 years ago • 2 comments

I'm submitting a...


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

Current behavior

DTO classes referenced in swagger decorators that are imported from node modules are not observed by the plugin when generated the swagger spec.

Expected behavior

proposal: allow plugin options to take a dtoFilePaths parameter to include files outside of the src directory.

"plugins": [
      {
        "name": "@nestjs/swagger/plugin",
        "options": {
          "dtoFileNameSuffix": [
            ".dto.ts",
            ".entity.ts"
          ],
          "dtoFilePaths": [
            "node_modules/@org/dtos"
          ]
        }
      }
    ]

Minimal reproduction of the problem with instructions

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

We share an entities package across multiple projects and are unable to leverage the plugin to define swagger api properties in the APIs that consume that package.

Environment


Nest version: 7.1.0
@nestjs/swagger: 4.5.12

 
For Tooling issues:
- Node version: 12.14.1
- Platform:  Mac

Others:

joeybenenati avatar Aug 07 '20 20:08 joeybenenati

I would say it would be good if plugin followed tsconfig paths

kjocevicius avatar Aug 10 '20 09:08 kjocevicius

DTO classes referenced in swagger decorators that are imported from node modules are not observed by the plugin when generated the swagger spec.

Why do you want TS compiler to compile TypeScript from node_modules? These files should already be precompiled and published to NPM as .js files. You can compile @org/dtos with Nest CLI (and plugin enabled) to store the metadata that can be read by Nest runtime.

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

kamilmysliwiec avatar Aug 19 '20 12:08 kamilmysliwiec