Prompted by Kludex/uvicorn-extensions#15 (comment)
Problem description
Currently, arel can be used by injecting a {{ script }} in the user's app HTML.
But this is not workable on HTML the user can't control.
For example, the user may want their FastAPI docs page to reload when their Uvicorn server restarts, as the OpenAPI schema may have changed due to
On the other hand, it's possible they wouldn't want that. Maybe they're busy testing things in the Swagger UI and, while they're doing edits in the their Python source code, they may not want to lose what they've done in the UI (e.g. authentication credentials).
How should we address these use cases?
Suggested solution
TODO
Possible alternatives
- Replace the manual
{{ script }} thing with automatic injection on HTML pages.
- This could be done by allowing users to register an ASGI middleware that detects HTML responses, and injects the script before the
</body> closing tag. When running in DEBUG mode, users would turn this behavior off by not including the middleware.
- This is somewhat similar to what django-debug-toolbar or fastapi-debug-toolbar do to inject their client-side toolbar JS on all pages -- including Swagger UI for
fastapi-debug-toolbar (since that's an HTML page as well).
Prompted by Kludex/uvicorn-extensions#15 (comment)
Problem description
Currently,
arelcan be used by injecting a{{ script }}in the user's app HTML.But this is not workable on HTML the user can't control.
For example, the user may want their FastAPI docs page to reload when their Uvicorn server restarts, as the OpenAPI schema may have changed due to
On the other hand, it's possible they wouldn't want that. Maybe they're busy testing things in the Swagger UI and, while they're doing edits in the their Python source code, they may not want to lose what they've done in the UI (e.g. authentication credentials).
How should we address these use cases?
Suggested solution
TODO
Possible alternatives
{{ script }}thing with automatic injection on HTML pages.</body>closing tag. When running inDEBUGmode, users would turn this behavior off by not including the middleware.fastapi-debug-toolbar(since that's an HTML page as well).