问题
I am using NSwag to generate swagger for my .NET Core api and everything works great, except the fact that paths are rendered in order that reflection seems to pickup Controllers from project.
So if I do have hierarchy - some controllers at root level (Controllers folder) and some in subfolder (Controllers\Subfolder folder) then the order gets messed up.
Is it possible to somehow tell NSwag to generate resulting swagger.json showing operations in alphabetical order?
回答1:
There is option within UI configuration. All you need is utilize OperationsSorter and TagsSorter, within your Startup.Configure method like:
app.UseSwaggerUi3(a => {
a.OperationsSorter = "alpha";
a.TagsSorter = "alpha";
});
来源:https://stackoverflow.com/questions/59060563/how-to-order-sort-paths-in-nswag-swagger-json-by-controller-name