Following #1393 and #1355, I'm only suggesting a possible approach for a better API Versioning support.
It would be really useful and less mistake-prone if NSwag could handle the different decleared versions of an API automatically.
Actually, by following #1393, all the different versions of API needs to be registered and configure manually in Startup (version number matching the one in the Controller Attribute, files, etc.).
A possible different approach could be to have something like this:
app.UseSwaggerUi3(typeof(Startup).GetTypeInfo().Assembly, config =>
{
/* Looks inside Controllers for all ApiVersion() attributes and generates a route and a JSON file for each one.
* Also the DefaultUrlTemplate property could be taken from Route() controller attribute, if present.
*/
config.GeneratorSettings.UseMultipleVersions = true;
config.SwaggerRoutes.LoadFromControllers();
// Generic settings for all routes
config.GeneratorSettings.Title = "My Amazing API";
config.GeneratorSettings.Description = "Amazing API functionalities.";
// Specific settings for single route
foreach (var route in config.SwaggerRoutes)
{
route.DefaultUrlTemplate = "{v:apiVersion}/{controller}/{action}/{id?}";
route.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase;
}
});
Thank you!
Some news about that?
Most helpful comment
Some news about that?