Is your feature request related to a problem? No
Currently, Redoc and Swagger UI are served from literal strings in the code with formatted-in options for Title, JS URL, etc. However, these are not customisable and the hardcoded defaults are always used.
The solution you would like
I propose to add some a redoc_kwargs and docs_kwargs (or similar) parameter to the FastAPI class (because having individual arguments would be too cumbersome) which are passed to the get_redoc_html and get_swagger_ui_html methods. I also propose adding some more arguments to those methods for custom CSS, fonts, or other HTML additions (perhaps a slot each for <head> and <body> after the rest of the content) if required.
Describe alternatives you've considered
Currently you could implement your own Redoc/Swagger UI endpoints instead of using FastAPI's ones and returning your own HTML, but I feel that sort of defeats the purpose of having these features.
These endpoints could even be converted to full-blown Jinja2 templates or similar, although this does seem a bit excessive to me.
Additional context
(note: what follows are a bunch of rambled related ideas I came up with in the 5 minutes I spent writing this issue, in hindsight these could have been separate issues)
Perhaps as part of this revamp, the get_redoc_html and get_swagger_ui_html methods could be closures, so that the static HTML is not recreated on every request (a separate issue, I know, and only a very minor performance bump as well)
Another related suggestion would be to allow rewriting all requests to /docs/* / /redoc/* to those URLs to enable use of HTML5 history mode instead of anchors, SPA-style (although I believe currently neither Swagger UI nor Redoc actually support these)
Is your feature request related to a problem? No
Currently, Redoc and Swagger UI are served from literal strings in the code with formatted-in options for Title, JS URL, etc. However, these are not customisable and the hardcoded defaults are always used.
The solution you would like
I propose to add some a
redoc_kwargsanddocs_kwargs(or similar) parameter to the FastAPI class (because having individual arguments would be too cumbersome) which are passed to theget_redoc_htmlandget_swagger_ui_htmlmethods. I also propose adding some more arguments to those methods for custom CSS, fonts, or other HTML additions (perhaps a slot each for<head>and<body>after the rest of the content) if required.Describe alternatives you've considered
Currently you could implement your own Redoc/Swagger UI endpoints instead of using FastAPI's ones and returning your own HTML, but I feel that sort of defeats the purpose of having these features.
These endpoints could even be converted to full-blown Jinja2 templates or similar, although this does seem a bit excessive to me.
Additional context
(note: what follows are a bunch of rambled related ideas I came up with in the 5 minutes I spent writing this issue, in hindsight these could have been separate issues)
Perhaps as part of this revamp, the
get_redoc_htmlandget_swagger_ui_htmlmethods could be closures, so that the static HTML is not recreated on every request (a separate issue, I know, and only a very minor performance bump as well)Another related suggestion would be to allow rewriting all requests to
/docs/*//redoc/*to those URLs to enable use of HTML5 history mode instead of anchors, SPA-style (although I believe currently neither Swagger UI nor Redoc actually support these)