This providdes configuration for swagger with default endpoints for swagger spec and ui. It can be used in every web API project that is built with ASP.NET Core.
- reference this package to your project: https://www.nuget.org/packages/Samhammer.Swagger.Default/
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen();
services.AddSwaggerDefaultApi();
}
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI();
}public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen();
}
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI();
}This providdes configuration for swagger with authentication by oauth2 codeflow or bearer token or guest auth. It can be used in every web API project that is built with ASP.NET Core.
- reference this package to your project: https://www.nuget.org/packages/Samhammer.Swagger.Authentication/
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen();
services.AddSwaggerAuthentication(Configuration);
}
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI();
}For setup of auth2 codeflow add this to appsettings.json:
"SwaggerAuthOptions": {
"ClientId": "<<ClientId>>",
"AccessTokenUrl": "<<TokenUrl>>",
"AuthUrl": "<<AuthUrl>>"
},For Authenticaton by https://github.com/SamhammerAG/Samhammer.Authentication#guest-authentication
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGuest(Configuration);
}For override of default settings (enabled true) add this to appsettings.json:
"SwaggerGuestOptions": {
"Enabled": false
}This providdes configuration for swagger with api versioning support. It can be used in every web API project that is built with ASP.NET Core.
- reference this package to your project: https://www.nuget.org/packages/Samhammer.Swagger.Authentication/
public void ConfigureServices(IServiceCollection services)
{
services.AddApiVersioning(...);
services.AddSwaggerGen();
services.AddSwaggerVersionedApi();
}
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI();
}- Create a tag and let the github action do the publishing for you