How to use Swagger with WebApi-Mvc project?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to use Swagger with WebApi-Mvc project?
Hello Everyone
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?
Thanks,
Jdang
- Labels:
-
Swagger Codegen
-
Swagger UI
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been using Swagger for many years for WebApi, not WebApi MVC, So far, there is no luck yet.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have been using Swagger for many years for WebApi, not WebApi MVC, So far, there is no luck yet.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your project's startup code (typically in the Startup.cs file), add the necessary configurations to enable Swagger. This includes adding the Swagger services with AddSwaggerGen() and configuring the Swagger middleware with UseSwagger() and UseSwaggerUI().
iOS 16.5
