-
-
Save stormwild/62b5172f2093f0b69bc2f780d8a6eee3 to your computer and use it in GitHub Desktop.
Customizing Swagger Middleware & UI Paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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