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

Misplaced </html> in swagger_ui HTML template #660

Closed
SaculRennorb opened this issue Sep 18, 2023 · 3 comments
Closed

Misplaced </html> in swagger_ui HTML template #660

SaculRennorb opened this issue Sep 18, 2023 · 3 comments

Comments

@SaculRennorb
Copy link
Contributor

https://github.com/poem-web/poem/blob/51d6d8d934aecf093e8044d9ba78e05349473b4c/poem-openapi/src/ui/swagger_ui/mod.rs#L15C1-L15C8

has the closing html tag misplaced. i would open a pr, but its hardly worth the fork.

  const SWAGGER_UI_TEMPLATE: &str = r#"
  <html charset="UTF-8">
  <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
      <title>Swagger UI</title>
      <style charset="UTF-8">{:style}</style>
      <script charset="UTF-8">{:script}</script>
  </head>
- </html>
  <body>
  
  <div id="ui"></div>
  <script>
      let spec = {:spec};
      let oauth2RedirectUrl;
  
      let query = window.location.href.indexOf("?");
      if (query > 0) {
          oauth2RedirectUrl = window.location.href.substring(0, query);
      } else {
          oauth2RedirectUrl = window.location.href;
      }
  
      if (!oauth2RedirectUrl.endsWith("/")) {
          oauth2RedirectUrl += "/";
      }
      oauth2RedirectUrl += "oauth-receiver.html";
  
      SwaggerUIBundle({
          dom_id: '#ui',
          spec: spec,
          filter: false,
          oauth2RedirectUrl: oauth2RedirectUrl,
      })
  </script>
  
  </body>
+ </html>
  "#;

Also from what I gathered it seems like it might be possible to replace the html template for the UI as a consumer of the package, but I'm not quite certain if that is possible and if so how to accomplish it, so I might aswell ask:

Is is possible to provide a custom HTML template to set things like the page title and icon for those UIs (Specifically the swagger one in my case)?

@sunli829
Copy link
Collaborator

sunli829 commented Sep 23, 2023

You can open a PR, any fixes are welcome. 🙂

@SaculRennorb
Copy link
Contributor Author

I mean i put the fix in my original comment, but sure - i'll open a pr when i find some time in the next few days.

attila-lin pushed a commit that referenced this issue Sep 26, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Addressing #660
@SaculRennorb
Copy link
Contributor Author

I will close this as completed as the original problem is now fixed, but my second question still stands:

Is is possible to provide a custom HTML template to set things like the page title and icon for those UIs (Specifically the swagger one in my case)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants