aspnet-api-versioning icon indicating copy to clipboard operation
aspnet-api-versioning copied to clipboard

Is there a way to integrate Swagger without using SwashBuckle?

Open gauravagerwala opened this issue 8 years ago • 3 comments

gauravagerwala avatar Apr 16 '18 12:04 gauravagerwala

Services.GetApiExplorer is returning the endpoint(ApiDescription.RelativePath) like this: example/v{version}/call How do I ensure that it returns the version I have specified

gauravagerwala avatar Apr 16 '18 12:04 gauravagerwala

API Versioning doesn't directly care about Swagger or Swashbuckle; it only provides an API Explorer. The API Explorer is paramount to Swashbuckle and NSwag to generate Swagger documents. To answer your question, then - yes - you can create Swagger documents without Swashbuckle using the API Explorer.

It also looks like you're asking how to substitute the API version in the explored APIs. Remember that your route templates are defined as example/v{version:apiVersion}/call. This is no different than if the route template was example/call/{id:int}. Route templates are not normally auto-magically populated.

While it's always been possible to perform the substitution yourself, service authors using the URL segment version method often ask for this behavior. A new option was added to the API Explorer a while back to do this for you:

configuration.AddVersionedApiExplorer( options => options.SubstituteApiVersionInUrl = true );

This is documented in the wiki and only applies to the URL segment method.

I hope that helps.

commonsensesoftware avatar Apr 16 '18 16:04 commonsensesoftware

It worked, Thanks

gauravagerwala avatar Apr 17 '18 09:04 gauravagerwala