Skip to content

Instantly share code, notes, and snippets.

@dj-nitehawk
Last active March 3, 2024 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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