Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more configuration variables in swagger docs #221

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sanic_ext/extensions/openapi/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ def index(
if getattr(request.app.config, "SERVER_NAME", None)
else getattr(request.app.config, "OAS_URL_PREFIX")
).rstrip("/")
config_uri = getattr(request.app.config, "OAS_URI_TO_CONFIG")
config_json = getattr(request.app.config, "OAS_URI_TO_JSON")
return html(
page.replace("__VERSION__", version)
.replace("__URL_PREFIX__", prefix)
.replace("__URL_CONFIG__", config_uri)
.replace("__URL_JSON__", config_json)
.replace("__HTML_TITLE__", html_title)
.replace("__HTML_CUSTOM_CSS__", custom_css)
)
Expand Down
2 changes: 1 addition & 1 deletion sanic_ext/extensions/openapi/ui/redoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<redoc spec-url="__URL_PREFIX__/openapi.json"></redoc>
<redoc spec-url="__URL_PREFIX____URL_CONFIG__"></redoc>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions sanic_ext/extensions/openapi/ui/swagger.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<script>
window.onload = function () {
const ui = SwaggerUIBundle({
url: "__URL_PREFIX__/openapi.json",
url: "__URL_PREFIX____URL_JSON__",
dom_id: "#openapi",
configUrl: "__URL_PREFIX__/swagger-config",
configUrl: "__URL_PREFIX____URL_CONFIG__",
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
Expand Down
Loading