Open KontoBruktUnderUtdanning opened 4 years ago
In AddOpenApiDocument you can add a custom operation processor and return false for the operations/controllers you want to exclude
Insert the processor at index 0 so that it is executed first
The canonical way to do that with the new asp.net core is to put your controllers into groups :
[ApiController]
[ApiExplorerSettings(GroupName = "MyGroup")]
public class MyController: Controller
In the NSwag document generation method, just put:
settings.Title = "My API";
settings.Description = "My SUPER API";
settings.Version = "v1";
settings.ApiGroupNames = new[] {"MyGroup"};
Only the controllers from MyGroup
will get generated.
I use NSwag to generate Swagger UIs for my endpoints in a .NET Framework project. I do it like this, using the
NSwag.AspNet.Owin
package:Notice how I can specify which controllers are displayed in the UI.
Now I'm working on a .NET Core project and would like to do the same. Using the AspNetCore middleware package seems like the most modern approach.
This is from the
NSwag.AspNetCore
package. It gives me a UI, but it includes endpoints from all of my controllers. I want to specify which controller types are to be used when generating the document/UI. This is easy using the Owin package, but I cannot find any such setting in the AspNetCore middleware. What am I missing?