Is it possible to force NSwag generate OpenAPI schema/SwaggerUi for ASP.NET MVC Controllers (not ApiController!)

Viewed 394

I have the very basic setup according to the official wiki for ASP.NET MVC project with GlobalAsax.cs (.NET Framework). Due to some reasons, I have to use MVC controllers (System.Web.Mvc.Controller inherited) for the API (requirement of the external framework, cannot be changed). NSwag ignores MVC controllers, is there a way to force it to add them to the schema except for using WebApiOpenApiDocumentGenerator manually?

1 Answers

The solution is really simple: instead of using assembly type for UseSwaggerUi/UseSwaggerUi3, pass all controller types explicitly (there's an overload, that accepts IEnumerable<Type> types).

Related