Skip to content

Site: restore inline Redoc rendering for API spec pages - #5434

Open
adutra wants to merge 2 commits into
apache:mainfrom
adutra:redoc-polaris-fix
Open

Site: restore inline Redoc rendering for API spec pages#5434
adutra wants to merge 2 commits into
apache:mainfrom
adutra:redoc-polaris-fix

Conversation

@adutra

@adutra adutra commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The redoc-polaris shortcode was originally designed to render the OpenAPI spec inline using the Redoc component. A later change (c3f0681) replaced the Redoc <script> tag with a <meta http-equiv="refresh">, causing the page to immediately redirect to the Swagger editor instead, leaving the Redoc component output unreachable and producing an abrupt browser experience.

This commit restores inline rendering by bringing the shortcode back in line with the Docsy v0.14.3 original it was copied from, substituting only the URL resolution block with the Polaris-specific rawGithubPolarisUrl partial.

A separate "Open in Swagger Editor ↗" link is added for users who prefer the editor, and the ↗ suffix is removed from the sidebar link titles since the pages no longer redirect.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

The `redoc-polaris` shortcode was originally designed to render the OpenAPI spec inline using the Redoc component. A later change (c3f0681) replaced the Redoc `<script>` tag with a `<meta http-equiv="refresh">`, causing the page to immediately redirect to the Swagger editor instead, leaving the Redoc component output unreachable and producing an abrupt browser experience.

This commit restores inline rendering by bringing the shortcode back in line with the Docsy v0.14.3 original it was copied from, substituting only the URL resolution block with the Polaris-specific `rawGithubPolarisUrl` partial.

A separate "Open in Swagger Editor ↗" link is added for users who prefer the editor, and the ↗ suffix is removed from the sidebar link titles since the pages no longer redirect.
Copilot AI lite review requested due to automatic review settings September 2, 2026 22:46
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The newly added Swagger Editor link uses HTTP and does not URL-encode the url= query parameter, which can cause mixed-content and URL-handling issues on HTTPS sites.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Restores inline Redoc rendering for Polaris OpenAPI spec documentation pages by reverting the redoc-polaris shortcode behavior back toward Docsy’s original approach (render inline, with an optional link out to Swagger Editor) and updating sidebar link titles to match the new non-redirect behavior.

Changes:

  • Replace the shortcode’s redirect behavior with inline Redoc rendering via the Redoc standalone script.
  • Add an “Open in Swagger Editor ↗” link instead of forcing an immediate redirect.
  • Remove the ↗ suffix from API spec page linkTitle values now that pages no longer redirect.
File summaries
File Description
site/layouts/shortcodes/redoc-polaris.html Restores inline Redoc rendering and adds an explicit Swagger Editor link.
site/content/in-dev/unreleased/polaris-api-specs/polaris-management-api.md Updates sidebar link title to remove ↗ since the page no longer redirects externally.
site/content/in-dev/unreleased/polaris-api-specs/polaris-catalog-api.md Updates sidebar link title to remove ↗ since the page no longer redirects externally.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread site/layouts/shortcodes/redoc-polaris.html Outdated
-->

<meta http-equiv="refresh" content="0; url=http://editor-next.swagger.io/?url={{ $url }}" />
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"></script>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Re)adding Redoc rendering for API specs is nice!

This line however is concerning.

The current site build already fetches pinned jQuery and Lunr scripts, adding/using a pinned Redoc JS would resolve the concern.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on serving a pinned Redoc bundle from the site, since the current CSP blocks this CDN script. That still leaves the YAML: Redoc fetches it from raw.githubusercontent.com, which is also blocked because connect-src falls back to default-src. Could we publish the correctly versioned specs with the site too, then verify that both API pages render under the production CSP?

@flyingImer flyingImer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd hold off merging until the loading issue in the existing thread is resolved. The restored inline API docs need to work under the production CSP.

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

Successfully merging this pull request may close these issues.

4 participants