domaindrivendev / Swashbuckle.WebApi

Seamlessly adds a swagger to WebApi projects!
BSD 3-Clause "New" or "Revised" License
3.07k stars 679 forks source link

API Multiple version - unable to generate swagger document #1029

Open Anjayg opened 7 years ago

Anjayg commented 7 years ago

we adopted versioning approach for our public api and version can be accepted via query string or headers. below are same resource but different store to connect data.

https://github.com/Microsoft/aspnet-api-versioning

[ApiVersion("1")] [RoutePrefix("api/items")] items1controller: apicontroller { GET api/items?api-version =1 }

[ApiVersion("2")] [RoutePrefix("api/items")] items2controller: apicontroller { GET api/items?api-version =2 }

api/items/1?api-version =1 api/items/1?api-version 2

we are unable to generate swagger documentation for multi version api. I think this question was asked many times in different forum. but looking for some solution/direction so that api explorer does not break and we are able to generate swagger document.

remster85 commented 7 years ago

Could you try to use UseFullTypeNamesInSchema ?

cmshawns commented 7 years ago

UseFullTypeNamesInSchema is not a workable solution for us. When we do so we run into an error when consuming the service in Visual Studio because the entity names are too long. Is addressing this issue directly something that's being considered?

commonsensesoftware commented 7 years ago

@Anjayg did you know that there is an API Explorer for API Versioning to support this now? You can see the Web API sample here. Although it's RC, it's stable. I'm tightening up the last few bits this week and I think things will be ready for the first, official release.

cmshawns commented 7 years ago

As a response to my comment specifically, it appears that SwaggerDocsConfig.SchemaId() can be used to provide a custom transform of entity names: https://github.com/domaindrivendev/Swashbuckle/issues/333#issuecomment-144099732