API Versioning: Multiple versions for controller not displayed properly in Swagger
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
When enabling API Versioning in Nest and adding multiple versions to a controller, the correspondig Swagger Docu only shows routes for the first entry of the versions array (https://github.com/jalorenz94/api-versioning).
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
@Controller({
version: ['1', '2'],
})
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
getHello(): string {
return this.appService.getHello();
}
}
Expected behavior
The swagger docu shows the following endpoints: /v1
and /v2
.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
Nest version: 8.0.0
Nest Swagger version: 5.0.9
For Tooling issues:
- Node version: 16
- Platform: Linux
Others:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Swagger not working correctly with multiple versions of ASP ...
I'm trying to setup API versioning for a ASP.NET WebApi project, along with Swagger. The API versioning works fine, calling different versions ......
Read more >C# .net Swagger API Versioning – Show versions in your ...
C# .net Swagger API Versioning – Show versions in your Swagger page · STEP 1: THE NUGET PACKAGES · STEP 2: DECORATE THE...
Read more >API versioning with ASP.NET Core and Swashbuckle
ApiVersion : Lets you define in which versions of your API this controller and all of it's methods is supported. You can add...
Read more >How to use API versioning in .NET Core Web APIs using .NET 6
Underneath the [ApiController] attribute you find the Route for the controller accepting versions.
Read more >Set up Swagger and API versioning in .NET 5 web API
If you are developing any API, having good documentation and proper versioning is absolutely crucial. In this blog post I will show how...
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
Hi @kamilmysliwiec I am experiencing a related issue and happy to address this in PR but wanted to make sure I am doing it correct.
I am adding
@Version('1')
to a route and the swagger documentation doesn’t show the version at all. Is this a bug or that wasn’t implemented? How do I get the version to show should I hardcode it in the route? Thanks!This is how I am implementing it now
Would you like to create a PR to address this issue?