Closed benjidotsh closed 1 year ago
I could be wrong here, but from a cursory look, your Nest application makes use of the common and prisma packages through a workspace protocol. The common and prisma have separate build steps from the nest build
/nest start --watch
commands, and so when nest start --watch
is ran, it sees that there's js packages for the common
package, and it doesn't need to be compiled. Because of this, there's no swagger plugin to be ran, as there's no Typescript metadata to make use of, so when you use the type at runtime, it uses the JS type that was created by tsup, not the nest compiler with the swagger plugin, and so you have no output data on the swagger ui.
To actually have the swagger plugin work, you'd need to compile the common project using @nestjs/cli
so that the swagger plugin can read the Typescript type data, and provide the correct _OPENAPI_METADATA_FACTORY
to the transpiled type
Please, use our Discord channel (support) for further questions. We are using GitHub to track bugs, feature requests, and potential improvements.
Is there an existing issue for this?
Current behavior
I'm trying to get the Swagger CLI plugin working with a NestJS project that is part of a Turborepo project, but it doesn't seem to work.
The schemas remain empty, even though they have a property. I also checked the built DTO file, but I could not find a
_OPENAPI_METADATA_FACTORY
.I tried reproducing this with a new NestJS project, which I couldn't, so I feel like this might be related to the usage of Turborepo.
Minimum reproduction code
https://github.com/icapps/NestKit/tree/swagger
Steps to reproduce
npm install
npx prisma generate
in theexample
folder.env.example
file to.env
npm run dev
example/dist/todos/dto/create-todo.dto.js
Expected behavior
The schemas should be automatically generated and
example/dist/todos/dto/create-todo.dto.js
should contain an_OPENAPI_METADATA_FACTORY
.Package version
7.1.12
NestJS version
10.0.0
Node.js version
20.7.0
In which operating systems have you tested?
Other
No response