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.

API Versioning: Multiple versions for controller not displayed properly in Swagger

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

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();
  }
}

api-versioning

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mahmoudmaamounzcommented, Sep 28, 2021

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

  @Version('1')
  @Post()
  async test(@Body() body: Payment): Promise<string> {
1reaction
kamilmysliwieccommented, Sep 27, 2021

Would you like to create a PR to address this issue?

Read more comments on GitHub >

github_iconTop 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 >

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