Using `type: () => TYPE` in `@ApiOperation` decorator results in invalid swagger generation
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
The documentation states to change type: TYPE
to type: () => TYPE
to avoid cyclic dependency errors. However, this only works in @ApiProperty()
and @ApiPropertyOptional()
decorators. It does NOT work in @ApiOperation()
and related decorators.
Expected behavior
It should work for @ApiOperation()
decorators.
Minimal reproduction of the problem with instructions
Check out the change in the test-case I made in my fork that exposes this error when you run npm run test:e2e
. The generated openapi schema is broken.
https://github.com/nestjs/swagger/compare/next...loban:loban-another-schema-error
What is the motivation / use case for changing the behavior?
This is necessary for the library to be usable.
Environment
Nest version: 4.0.0-next.3
For Tooling issues:
- Node version: 12.12.0
- Platform: Mac
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Describing Responses - Swagger
An API operation can return a file, such as an image or PDF. In this case, define the response schema with type: file...
Read more >OpenAPI Specification - Version 2.0 - Swagger
Primitive data types in the Swagger Specification are based on the types supported by the JSON-Schema Draft 4. Models are described using the...
Read more >Customizing your auto-generated Swagger Definitions in 1.5.x
Let's have a quick look at these to see how they can help you provide more complete API metadata when using a bottom-up...
Read more >ApiOperation (swagger-annotations 1.5.0 API)
Annotation Type ApiOperation ... Describes an operation or typically a HTTP method against a specific path. Operations with equivalent paths are grouped in...
Read more >Authentication - Swagger
HTTP authentication schemes (they use the Authorization header): ... Follow the links above for the guides on specific security types, or continue reading ......
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
@nartc Well, I instead just made a fix so that
@ApiOperation
can now properly handle lazy-evaluated-type-functions. PR at #375 .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.