this blog demonstrates step by step to add swagger in web api project and will submit http request GET/POST/PUT via swagger UI.
Swagger is API developer tools for the Open API Specification(OAS), enabling development across the entire API life cycle, from design and documentation, to test and deployment.
Definition -
after package installed, you will find a new file ‘SwaggerConfig.cs’ under App_Start Folder
public class SwaggerConfig
Swagger is API developer tools for the Open API Specification(OAS), enabling development across the entire API life cycle, from design and documentation, to test and deployment.
Definition -
“Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.”
To add Sweggar into WEBAPI Project, you need to perform only 2 steps
To add Sweggar into WEBAPI Project, you need to perform only 2 steps
2. Configure Swagger Config File :
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "DemoWebAPI");
})
.EnableSwaggerUi(c =>
{
c.DocumentTitle("Demo Web API");
});
}
}
build and run webAPI project and browser http://localhost:65096/swagger
Swagger allow you can submit HTTP request GET, HTTP POST, HTTP PUT against Web API
Example - Submit HTTP GET Request For /api/Projects/{projectId}
Example - Submit HTTP GET Request For /api/Projects/{projectId}
Other swagger related posts
- Swagger UI – How to add custom header Parameter
- Import Swagger APIs documentation into Postman
- Setup Swagger for ASP.NET WebAPI 2.0
- Disable Swagger UI
- Export swagger api document to pdf
Thanks for visiting!!