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

RequireJS prevents integrating SwaggerUI with a user script #2471

Open
JanisErdmanis opened this issue Mar 4, 2024 · 1 comment · May be fixed by #2472
Open

RequireJS prevents integrating SwaggerUI with a user script #2471

JanisErdmanis opened this issue Mar 4, 2024 · 1 comment · May be fixed by #2472
Labels
Format: HTML Related to the default HTML output Type: Enhancement

Comments

@JanisErdmanis
Copy link

I am incorporating a Swagger generated docs within a documenter, which looks promising:

Screenshot 2024-03-04 at 13 58 02

However, I have stumbled on a blocking issue where the code above works only if the swagger is loaded before the require.min.js is loaded, but the user assets provided to makedocs in format argument are loaded only afterwards. The code that renders the page is as follows and is included with @raw html:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.11.9/swagger-ui.css">

<style>
  .swagger-ui .information-container {
    display: none !important;
  }

  .swagger-ui #operations-tag-default {
    display: none !important;
  }
</style>


<div id="swagger-ui"></div>
<script>
  window.onload = () => {
      window.ui = SwaggerUIBundle({
          url: window.location.origin + "/assets/swagger/schema.json", 
          dom_id: '#swagger-ui',
      });
  };
</script>

A simple solution I see is that user asset_links in render_head function could be loaded before requirejs_cdn, which would only involve reordering.

Another more sophisticated approach is to make SwaggerUI to be integrated in the same way as higlighting and math rendering is. This involves understanding how requirejs works, documenter internals which is more complex task for which I can’t allocate time.

@JanisErdmanis JanisErdmanis linked a pull request Mar 4, 2024 that will close this issue
@JanisErdmanis
Copy link
Author

After resolving some hurdles I managed to deploy swagger docs in a documenter generated documentation with a #2472 change. Thus I am eager to see this issue resolved.

@mortenpi mortenpi added Type: Enhancement Format: HTML Related to the default HTML output labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Format: HTML Related to the default HTML output Type: Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants