fix(directory): 🐛 fix swagger server path to include 'api' prefix

This commit is contained in:
Collin M. Barrett 2020-09-08 07:15:41 -05:00
parent 13db19857e
commit 36e3eb9739

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
@ -32,7 +33,14 @@ public static void AddSwaggerGen(this IServiceCollection services)
public static void UseSwagger(this IApplicationBuilder app)
{
app.UseSwagger(o => o.RouteTemplate = "{documentName}/swagger.json");
app.UseSwagger(o =>
{
o.RouteTemplate = "{documentName}/swagger.json";
o.PreSerializeFilters.Add((swaggerDoc, httpReq) => swaggerDoc.Servers = new List<OpenApiServer>
{
new OpenApiServer {Url = $"{httpReq.Scheme}://{httpReq.Host.Value}/api"}
});
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("v1/swagger.json", "FilterLists Directory API V1");