Reputation: 259
I'm having a ASP.Net Core solution for which I want to use Swagger. For this I use the Nuget package NSwag (Assembly NSwag.AspNetCore, Version=11.20.1.0). In my Configuration of the app I have the following:
public void Configure(IApplicationBuilder app) {
app..UseSwaggerUi3WithApiExplorer(settings =>
{
settings.GeneratorSettings.DefaultPropertyNameHandling = PropertyNameHandling.CamelCase;
settings.PostProcess = document =>
{
document.Info.Version = $"v{typeof(Startup).Assembly.GetName().Version.Major}";
document.Info.Title = "Test Api";
document.Info.Description = "Sample API";
document.Info.TermsOfService = "None";
document.Info.Contact = new NSwag.SwaggerContact
{
Name = "Person",
Email = "Email"
};
};
});
}
When I run this, I see correctly all controllers and corresponding methods, but it is not sorted alphabetically.
I already tried the following:
Add TagSorter to settings:
app.UseSwaggerUi3WithApiExplorer(settings =>
{
...
settings.TagSorter = "alpha";
...
});
Add ApisSorter to settings:
app.UseSwaggerUi3WithApiExplorer(settings =>
{
...
settings.ApisSorter = "alpha";
...
});
But these changes result in the same output. How can I achieve the sorting?
Upvotes: 2
Views: 2425
Reputation: 422
I had the same issue. But after upgrading NSwag.AspNetCore -> 12.0.8 (latest version at time of writing) and replacing the methods that are now Obsolete
it worked with
s.TagsSorter = "alpha";
s.OperationsSorter = "alpha";
Upvotes: 1