Skip to content

waxtell/Swashbuckle.Rebase.Extensions

Repository files navigation

Swashbuckle.Rebase.Extensions

Rebase your API paths at Swashbuckle preserialization

Build Publish to nuget

Configuration:

            app.UseSwagger
            (
                options =>
                {
                    options.PreSerializeFilters.Add((swagger, httpReq) =>
                    {
                        if (!string.IsNullOrWhiteSpace(httpReq?.Host.Value))
                        {
                            swagger.Servers.Add
                            (
                                new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{{basePath}}" }
                                    .WithVariable("basePath", new OpenApiServerVariable { Default = "/test" })
                            );
                        }
                    });

                    options.RemoveRoot("/test");
                }
            );

About

Rebase your API paths at Swashbuckle preserialization

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages