swagger icon indicating copy to clipboard operation
swagger copied to clipboard

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

Open volo-maslow opened this issue 3 years ago • 19 comments

Is there an existing issue that is already proposing this?

  • [X] 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.

volo-maslow avatar Feb 05 '22 21:02 volo-maslow

Any progress on this issue? I really would like to be able to work with multiple swagger versions

Goufix avatar Jun 21 '22 14:06 Goufix

I just ran into the same issue. One of the main reasons I use swagger (with dotnet) is to have the ability to filter between multiple api versions, select and navigate between them.

markovidakovic avatar Jun 24 '22 08:06 markovidakovic

@moewang0321, @volo-maslow,Excuse me, everyone, is there a solution for grouping interface documents as above? Thank you,This issue(issues/1840) is closed

Holy-Mortal avatar Aug 01 '22 11:08 Holy-Mortal

Ran into the same issue. I was used to having versioning built in from different frameworks. Will this be resolved?

MartianH avatar Sep 14 '22 12:09 MartianH

Hi, does anyone have solution for this?

binhotvn avatar Oct 15 '22 07:10 binhotvn

+1 for this issue. We really need it!

wibek avatar Oct 18 '22 08:10 wibek

Hi, Any progress/solution for this one?

lhuria94 avatar Jan 05 '23 03:01 lhuria94

Using the tag Decorator is a workaround, but managing multiple API versions is appreciated, +1. @ApiTags('resource', 'v1') or @ApiTags('/v1/resource')

hofstede-matheus avatar Jan 18 '23 13:01 hofstede-matheus

+1 for this issue, I have a project for which I have enabled app.enableVersioning. Is there a way around it by enabling multiple versions of swagger?

auralshin avatar Jan 20 '23 18:01 auralshin

+1 This would be really a nice feature to have. It's easier for consumers to understand and it would be also great to be able to give "newer" customers / consumers just the "newest" documentation of the API, without bothering them with the documentation of older versions

antonio-masotti avatar Jan 24 '23 16:01 antonio-masotti

+1 for this issue

sefaplus avatar Feb 10 '23 08:02 sefaplus

+1 for this issue

UndefinedOleg avatar Feb 10 '23 08:02 UndefinedOleg

+1 plz

tobthecreator avatar Mar 02 '23 18:03 tobthecreator

+1 for this issue.

JRafael91 avatar Mar 27 '23 06:03 JRafael91

+1 please

nguyenlinhthanhnhan avatar Apr 12 '23 03:04 nguyenlinhthanhnhan

+1 pls add this

SeffUwU avatar Apr 13 '23 06:04 SeffUwU

+1

ricardodantas avatar Apr 13 '23 09:04 ricardodantas

+1

dolimight avatar Apr 14 '23 13:04 dolimight

+1

skrilax91 avatar Apr 26 '23 12:04 skrilax91