NuGet package for efficiently adding swagger in ASP.NET Core Web API apps. It simplifies the creation of interactive API documentation using the OpenAPI (Swagger) specification. This package helps developers to effortlessly visualize, test, and debug their API endpoints directly from the browser.
- Authorization: Enable
Bearer
authorization by adding JWT bearer token to test authorized APIs.
- Localization: Enable localization and support multi-languages by sending the
Accept-Language
header, facilitating better internationalization.
- Minimal APIs: Enable interactive UI for minimal API endpoints to explore and test directly in the browser.
var app = builder.Build();
///
app.MapGet("/", () => "Hello, World!");
///
app.Run();
- Query Parameters: Enable sending date in the query string as query parameters, enhancing API usability and understanding.
[HttpGet]
public IActionResult Verify([FromQuery] string code) => code == VerificationCode ?
Ok("Verified...") : BadRequest("Wrong verification code!!!");
$ dotnet add package Fathy.Swagger
var builder = WebApplication.CreateBuilder(args);
///
var openApiInfo = new OpenApiInfo
{
Title = "HelloWorld.API",
Version = "v1"
};
builder.Services.AddSwaggerService(openApiInfo);
///
var app = builder.Build();
///
///
var app = builder.Build();
///
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint($"/swagger/{openApiInfo.Version}/swagger.json", openApiInfo.Title);
});
///
app.Run();
APPLICATION_URL/swagger/index.html