What is Swagger UI?
Swagger UI provides a display framework that reads an OpenAPI specification document and generates an interactive documentation website.
Why Swagger UI?
ASP.NET Web API Help Page does not allow users to try API on browser. With Swagger UI, users can try all api methods on their browser.
Thus, testers can test api without any user interface also.
Classic ASP.NET Web API Help Page
Installation with NuGet
Install-Package Swashbuckle
Adding SwaggerConfig
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "RegisterSwaggerConfig")]
namespace OAuthNotesApp.App_Start
{
public class SwaggerConfig
{
public static void RegisterSwaggerConfig()
{
GlobalConfiguration.Configuration.EnableSwagger(x => x.SingleApiVersion("v1", "NotesAPI")).EnableSwaggerUi();
}
}
}
User Interface
Navigate /swagger for interface.
Testing register method
You can download source code, db script and postman requests from here –> Download