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.

[discussion]: Multiple versions support at Swagger (Documents & UI)

See original GitHub issue

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

While developing an API, you usually want to have the ability to separate it into different versions. NestJS 8 can define versions at controllers or methods, and the latest @nestjs/swagger is bundling them into a single swagger document.

However, it’s not always that easy for consumers to filter through all versions in a single place, and we could improve Swagger by using URLs with different specs per API version.

Describe the solution you’d like

An excellent example of such behavior has the Swashbuckle .Net implementation of swagger with the MultipleApiVersions feature - it generates multiple swagger documents per API version, collecting only controllers/methods with specific API version, and puts those swagger documents as specs to Swagger UI.

Example (top right corner): image

Teachability, documentation, adoption, migration strategy

Right now, we are building a single Swagger document by providing a DocumentBuilder config to SwaggerModule.createDocument, and I think there are multiple possible ways to make it use better versions separations there:

Idea

We can add a version as a filter to SwaggerModule.createDocument, and change SwaggerModule.setup to accept & generate multiple swagger config documents with different content. Multiple document usage will affect a swagger generation and require filtering by versions while collecting controllers, methods, DTOs, etc., for the Swagger document.

This change will be a major change to the document generation, as it will require the construction of multiple swagger documents and should work only if app.enableVersioning is enabled.

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

While building the API, versioning is vital to control the regression and integration. After the backend API reaches many API endpoints and gets a new version, filtering by versions for API consumers is pretty painful.

Having the ability to review & check API separated by a simple switch of different versions would increase overall satisfaction & productivity.

Let us know If it’s not only us who have such an issue, and we’ll try to contribute to this feature.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:23
  • Comments:6

github_iconTop GitHub Comments

1reaction
wibekcommented, Oct 18, 2022

+1 for this issue. We really need it!

0reactions
binhotvncommented, Oct 15, 2022

Hi, does anyone have solution for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# .net core swagger trying to use Multiple API Versions, but ...
We are trying to separate our API versions into different Swagger documents. We have configured everything as described in ...
Read more >
Swagger Codegen Documentation
All versions of the Swagger Codegen project can be found on Maven Central. ... see the various config help section options for specific...
Read more >
Using OpenAPI and Swagger UI - Quarkus
Quarkus supports various paths to store your OpenAPI document under. ... Swagger UI is a great tool permitting to visualize and interact with...
Read more >
Managing Multiple Versions of Your API with .NET and Swagger
In this article, we will explore the different approaches to REST API versioning and discuss the pros and cons of each approach. We...
Read more >
.NET Core 3.1 Web API - Keeping Different API Versions In A ...
The below code will be adding Swagger and SwaggerUI support. It also defines the swagger UI end points to browse for each API...
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