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.

Using `type: () => TYPE` in `@ApiOperation` decorator results in invalid swagger generation

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

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

github_iconTop GitHub Comments

1reaction
lobancommented, Nov 4, 2019

@nartc Well, I instead just made a fix so that @ApiOperation can now properly handle lazy-evaluated-type-functions. PR at #375 .

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

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 >

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