You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add new content to the script so i can decide if i want to show the endpoint list or not but i seems that there's no easy way unless i use regex.
setup_swagger(
app,
swagger_url='/docs',
swagger_from_file="docs/swagger.yaml",
swagger_home_decor=_home_decor,
ui_version=3
)
setup_swagger_ui(app)
defsetup_swagger_ui(app):
html_path=abspath(join(dirname(__file__), "../docs/swagger.html"))
withopen(html_path) asf:
# This key does not have my "##SHOW_ENDPOINTS##" tag# because it was read from the package itself.# and i cannot override it because my template does not have the ##STATIC_PATH### that the package replaced on the setup_swagger method.app["SWAGGER_TEMPLATE_CONTENT"] = (
f.read().replace('##SHOW_ENDPOINTS##', 'false')
)
The only way i can imagine is to use regex to add my conditions, maybe grep by window.ui and change it to add my condition
<!-- my template --><!-- ... --><script>window.onload=function(){// Begin Swagger UI call regionconstui=SwaggerUIBundle({url: "##SWAGGER_CONFIG##",dom_id: '#swagger-ui',deepLinking: true,presets: [SwaggerUIBundle.presets.apis,SwaggerUIStandalonePreset],plugins: [SwaggerUIBundle.plugins.DownloadUrl],layout: "StandaloneLayout"})// End Swagger UI call region// const showEndpoint = eval('##SHOW_ENDPOINTS##')// if (!showEndpoint) { document.querySelector(".wrapper").addClass('is-hidden')window.ui=ui}</script><!-- ... -->
Possible solution
Adds a parameter on the setup_swagger to define the path to the html file
This way we can set all "configs" to the user file and let them replace their own.
Adds a parameter on the setup_swagger so the user can pass a "component" to be injected on the html.
e.g:
<!-- index.html file on the package --><script>window.onload=function(){// ... }window.ui=ui}</script>
##CUSTOM_COMPONENT##
I'm trying to add new content to the
script
so i can decide if i want to show the endpoint list or not but i seems that there's no easy way unless i useregex
.The only way i can imagine is to use regex to add my conditions, maybe grep by
window.ui
and change it to add my conditionPossible solution
Adds a parameter on the
setup_swagger
to define the path to thehtml
fileThis way we can set all "configs" to the user file and let them replace their own.
Adds a parameter on the
setup_swagger
so the user can pass a "component" to be injected on the html.e.g:
Usage:
The text was updated successfully, but these errors were encountered: