mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
feat(directory): ✨ add more Swagger config
This commit is contained in:
parent
3598609d9f
commit
13db19857e
2 changed files with 46 additions and 9 deletions
|
|
@ -4,7 +4,6 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace FilterLists.Directory.Api
|
||||
{
|
||||
|
|
@ -21,8 +20,7 @@ public void ConfigureServices(IServiceCollection services)
|
|||
{
|
||||
services.AddControllers()
|
||||
.AddJsonOptions(o => o.JsonSerializerOptions.IgnoreNullValues = true);
|
||||
services.AddSwaggerGen(c =>
|
||||
c.SwaggerDoc("v1", new OpenApiInfo {Title = "FilterLists Directory API", Version = "v1"}));
|
||||
services.AddSwaggerGen();
|
||||
services.AddApplicationServices(Configuration);
|
||||
}
|
||||
|
||||
|
|
@ -30,14 +28,9 @@ public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|||
{
|
||||
if (env.IsDevelopment())
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("swagger/v1/swagger.json", "FilterLists Directory API V1");
|
||||
c.RoutePrefix = string.Empty;
|
||||
});
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(e => { e.MapControllers(); });
|
||||
app.UseSwagger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace FilterLists.Directory.Api
|
||||
{
|
||||
internal static class SwaggerExtensions
|
||||
{
|
||||
public static void AddSwaggerGen(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
c.SwaggerDoc("v1", new OpenApiInfo
|
||||
{
|
||||
Title = "FilterLists Directory API",
|
||||
Description =
|
||||
"FilterLists is the independent, comprehensive directory of filter and host lists for advertisements, trackers, malware, and annoyances.",
|
||||
Version = "v1",
|
||||
//TermsOfService = "",
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "Collin M. Barrett",
|
||||
Url = new Uri("https://collinmbarrett.com/contact/")
|
||||
},
|
||||
License = new OpenApiLicense
|
||||
{
|
||||
Name = "MIT License",
|
||||
Url = new Uri("https://github.com/collinbarrett/FilterLists/blob/master/LICENSE")
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static void UseSwagger(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseSwagger(o => o.RouteTemplate = "{documentName}/swagger.json");
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("v1/swagger.json", "FilterLists Directory API V1");
|
||||
c.DocumentTitle = "FilterLists Directory API";
|
||||
c.RoutePrefix = string.Empty;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue