Closed fcatae closed 7 years ago
See this discussion: https://github.com/Microsoft/aspnet-api-versioning/issues/60
Solution:
Define the available versions
c.SwaggerDoc("v1", new Info { Title = "Arda.Kanban", Version = "v1" });
c.SwaggerDoc("v2", new Info { Title = "Arda.Kanban v2 (Workspaces)", Version = "v2" });
Define a function to classify the API in version
c.DocInclusionPredicate((docName, apiDesc) =>
{
switch (docName)
{
case "v1":
return apiDesc.RelativePath.StartsWith("api/");
case "v2":
return apiDesc.RelativePath.StartsWith("v2/");
}
// unknown version?
return true;
});
Update the Swagger UI
app.UseSwaggerUi(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Arda.Kanban v1");
c.SwaggerEndpoint("/swagger/v2/swagger.json", "Arda.Kanban v2 (Workspaces)");
});
Done
Need Swagger versioning to support Kanban v2
Sample: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/test/WebSites/MultipleVersions/Startup.cs