Skip to content

feat: allow configuring ReDoc HTML attributes - #388

Merged
G4brym merged 1 commit into
cloudflare:mainfrom
rafamolina1:feat/redoc-options-376
Nov 13, 2026
Merged

G4brym merged 1 commit into
cloudflare:mainfrom
rafamolina1:feat/redoc-options-376

Conversation

@rafamolina1

@rafamolina1 rafamolina1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Allow configuring the ReDoc HTML element through redoc_options on Hono and itty-router adapters and an optional second argument to getReDocUI(). For example, { "show-extensions": "x-filter-fields" } now renders the extension filter requested in the issue.

Export ReDocOptions, preserve the default configuration, escape attribute values and the schema URL, and reject invalid names, event handlers, and attempts to override spec-url. Include documentation and a minor changeset.

Closes #376

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Internal (tests, CI, refactor)

How was this tested?

  • npm test: 458 tests passed, including 23 new ReDoc scenarios.
  • npm test -- redoc-options.test.ts: all 23 tests passed.
  • npm run lint: passed.
  • npm run build: passed; verified the new API in both generated declaration formats.
  • New integration coverage includes primitive values, escaping, invalid attributes, both adapters, custom URLs/base paths, and disabled documentation routes. Compile-time coverage checks the exported types and rejects object attribute values.

Checklist

  • Tests added or updated
  • npm test and npm run lint pass
  • Changeset added (npx changeset, empty changeset for internal changes)
  • Docs updated (if user-facing)
  • No breaking change, or the breaking change is documented

@rafamolina1
rafamolina1 requested a review from G4brym as a code owner November 12, 2026 17:25
@rafamolina1

Copy link
Copy Markdown
Contributor Author

Implemented the ReDoc customization requested in #376. Both adapters now accept:

redoc_options: {
  "show-extensions": "x-filter-fields",
}

The same options can be passed directly to getReDocUI("/openapi.json", options). Attribute names use kebab-case; strings, numbers, and booleans are supported, while undefined values are omitted. Existing calls keep their default behavior.

Attribute values and the schema URL are HTML-escaped. Invalid names, event handlers such as onclick, and spec-url overrides are rejected. The event-handler check allows legitimate options such as only-required-in-samples.

Added public type checks, documentation, a minor changeset, and 23 integration scenarios covering serialization, validation, both adapters, custom paths/base paths, and disabled routes. Validation completed: all 458 tests passed, along with lint and the CJS/ESM build.

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/chanfana@388

commit: 5ebf04a

@G4brym
G4brym merged commit f4ee2aa into cloudflare:main Nov 13, 2026
5 checks passed
@G4brym

G4brym commented Nov 13, 2026

Copy link
Copy Markdown
Member

Thanks @rafamolina1

@github-actions github-actions Bot mentioned this pull request Nov 13, 2026
@rafamolina1

Copy link
Copy Markdown
Contributor Author

Cheers mate 🇧🇷

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.

Provide option to customize getReDocUI

2 participants