Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Last active October 1, 2024 09:01
Show Gist options
  • Save dj-nitehawk/ba223a3dd415407a3e664a4a2b61dbc7 to your computer and use it in GitHub Desktop.
Save dj-nitehawk/ba223a3dd415407a3e664a4a2b61dbc7 to your computer and use it in GitHub Desktop.
Customizing Swagger Middleware & UI Paths
app.UseSwaggerGen(
s =>
{
//where to serve swagger.json files from
s.Path = "/PREFIX/swagger/{documentName}/swagger.json";
//api endpoint server base path customization
s.PostProcess = (document, request) =>
{
document.Servers.Clear();
document.Servers.Add(
new()
{
Url = $"{request.Scheme}://{request.Host}/PREFIX"
});
};
},
ui =>
{
//where to serve swagger ui from
ui.Path = "/PREFIX/swagger";
//where the ui looks for swagger.json files
ui.DocumentPath = "/PREFIX/swagger/{documentName}/swagger.json";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment