Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger + URI Versioning #1495

Closed
ayuhito opened this issue Aug 12, 2021 · 4 comments
Closed

Swagger + URI Versioning #1495

ayuhito opened this issue Aug 12, 2021 · 4 comments

Comments

@ayuhito
Copy link

ayuhito commented Aug 12, 2021

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

Using the new versioning featuring, specifically the URI option, Swagger fails to detect whether the controller has a version associated with it or not. When I'm on the Swagger UI, my endpoints return with 404's as none of the endpoints are using the versioned URI. When executing an option in Swagger, it tests with api.com/test when it should be testing with api.com/v1/test for example.

Expected behavior

Swagger UI should seamlessly work with the new Versioning feature, or even a dropdown per endpoint to select different versions of the API could be added.

Minimal reproduction of the problem with instructions

NestJS + Swagger/OpenAPI setup with controllers using URI versioning.

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

Seamless integration between Swagger and the new versioning feature.

Environment


Nest version: 8.0.6
@nestjs/swagger: 5.0.9
fastify-swagger: 4.8.4


 
For Tooling issues:
- Node version: 16
- Platform:  Linux

Others:

@kamilmysliwiec
Copy link
Member

This should work as expected.

Please provide a minimum reproduction repository.

@lolo32
Copy link

lolo32 commented Aug 13, 2021

@kamilmysliwiec Because I got the same issue, I add a POC to describe the problem.

I made a simple POC here:
https://github.com/lolo32/poc-nest-swagger-versioning-error

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : macOS Catalina
NodeJS Version : v14.17.4
NPM Version    : 7.20.5

[Nest CLI]
Nest CLI Version : 8.1.1

[Nest Platform Information]
platform-express version : 8.0.6
schematics version       : 8.0.2
swagger version          : 5.0.9
testing version          : 8.0.6
common version           : 8.0.6
core version             : 8.0.6
cli version              : 8.1.1

@kamilmysliwiec
Copy link
Member

app.enableVersioning(); should be called before SwaggerModule.createDocument(...)

@lolo32
Copy link

lolo32 commented Aug 13, 2021

Nice, it works if I do that.

Please write a note into the documentation about this requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants