How to use Swagger with WebApi-Mvc project?
I'm inheriting a WebApi-Mvc project where the return of the public methods of the controller is the Razor page.
I'm not sure if it's possible to integrate Swagger with this project to provide some documentation. Or is there any way we can manually integrate with just a few methods from a few controllers?
Hi @jdang67 ,
I'm no .NET expert, but the go-to library for Swagger is Swashbuckle (https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnet...) .
Integrating that would be a good first step, especially to see how far you can get with automated approaches.
Ultimately there are two steps, getting the API details (ie: describing your API) which is what Swashbuckle helps to do.
Then the second part is displaying that description (known as an OpenAPI file/definition) in some documentation tool (typically SwaggerUI, but there are others). The second step can be entirely independent of the server stack using, which is where you can manually describe the definition and then render it inside Razor pages or outside of it.
Hope that helps get things going!