FD-880: Migrate redoc-cli to @redocly/cli#535
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates the documentation generation from redoc-cli to @redocly/cli, consolidating the configuration into .redocly.yaml and removing obsolete dependencies. It also attempts to upgrade the Node.js environment to version 24. However, several critical issues were identified: Node.js version 24 is not yet released, which will break the build in the Dockerfile, GitHub Actions, and package engine requirements. Additionally, @redocly/cli does not support dot-notation for template options in the package.json script, meaning these options must be moved to a JSON file to prevent template variables from rendering empty. Finally, a minor CSS syntax issue with a trailing semicolon in the font-family configuration needs to be corrected.
| "pretty:check": "prettier --check .", | ||
| "proxy": "prism proxy --errors $npm_package_config_specfile https://api.lob.com/v1", | ||
| "redoc": "redoc-cli build $npm_package_config_specfile -t actions/redoc/template.hbs --templateOptions.segmentKey=0ysbW8vXHeRAnY2saZPMlRSZFfPwd1RO --templateOptions.SUPPORT_URL=https://support.lob.com/hc/en-us --templateOptions.LOB_ASSETS_URL=https://s3-us-west-2.amazonaws.com/public.lob.com --templateOptions.canonicalUrl=https://docs.lob.com/ --templateOptions.keywords=\"Direct Mail, Address Verification\" --templateOptions.description=\"Detailed developer documentation for Lob's address verification API and print & mail API. Learn how to easily integrate Lob's APIs within your product or technology stack.\" --templateOptions.LOB_URL=https://lob.com --templateOptions.image=https://s3-us-west-2.amazonaws.com/public.lob.com/dashboard/navbar/lob-logo.svg --templateOptions.DASHBOARD_URL=https://dashboard.lob.com/# --templateOptions.HELP_URL=https://help.lob.com/ --templateOptions.LOB_BACKUP_ASSETS_URL=https://assets-global.website-files.com/5e1e5c62fa3d4447af417098/ --options=docs/redocOptions.json --title=\"Lob API documentation\" -o docs/index.html", | ||
| "redoc": "redocly build-docs $npm_package_config_specfile -t actions/redoc/template.hbs --templateOptions.segmentKey=0ysbW8vXHeRAnY2saZPMlRSZFfPwd1RO --templateOptions.SUPPORT_URL=https://support.lob.com/hc/en-us --templateOptions.LOB_ASSETS_URL=https://s3-us-west-2.amazonaws.com/public.lob.com --templateOptions.canonicalUrl=https://docs.lob.com/ --templateOptions.keywords=\"Direct Mail, Address Verification\" --templateOptions.description=\"Detailed developer documentation for Lob's address verification API and print & mail API. Learn how to easily integrate Lob's APIs within your product or technology stack.\" --templateOptions.LOB_URL=https://lob.com --templateOptions.image=https://s3-us-west-2.amazonaws.com/public.lob.com/dashboard/navbar/lob-logo.svg --templateOptions.DASHBOARD_URL=https://dashboard.lob.com/# --templateOptions.HELP_URL=https://help.lob.com/ --templateOptions.LOB_BACKUP_ASSETS_URL=https://assets-global.website-files.com/5e1e5c62fa3d4447af417098/ --title=\"Lob API documentation\" -o docs/index.html", |
There was a problem hiding this comment.
Unlike redoc-cli (which used yargs and supported dot-notation for object arguments), @redocly/cli uses a different argument parser that does not support passing individual template options via --templateOptions.key=value flags. Instead, @redocly/cli expects --templateOptions to point to a JSON file containing the options.\n\nIf you run this command as-is, the template options will be ignored, and all the custom template variables (like {{templateOptions.LOB_URL}}, {{templateOptions.segmentKey}}, etc.) in actions/redoc/template.hbs will render as empty strings, breaking links, images, and analytics in the generated docs.\n\nTo fix this, create a JSON file (e.g., docs/templateOptions.json) with the template options and reference it using --templateOptions docs/templateOptions.json.
| "redoc": "redocly build-docs $npm_package_config_specfile -t actions/redoc/template.hbs --templateOptions.segmentKey=0ysbW8vXHeRAnY2saZPMlRSZFfPwd1RO --templateOptions.SUPPORT_URL=https://support.lob.com/hc/en-us --templateOptions.LOB_ASSETS_URL=https://s3-us-west-2.amazonaws.com/public.lob.com --templateOptions.canonicalUrl=https://docs.lob.com/ --templateOptions.keywords=\"Direct Mail, Address Verification\" --templateOptions.description=\"Detailed developer documentation for Lob's address verification API and print & mail API. Learn how to easily integrate Lob's APIs within your product or technology stack.\" --templateOptions.LOB_URL=https://lob.com --templateOptions.image=https://s3-us-west-2.amazonaws.com/public.lob.com/dashboard/navbar/lob-logo.svg --templateOptions.DASHBOARD_URL=https://dashboard.lob.com/# --templateOptions.HELP_URL=https://help.lob.com/ --templateOptions.LOB_BACKUP_ASSETS_URL=https://assets-global.website-files.com/5e1e5c62fa3d4447af417098/ --title=\"Lob API documentation\" -o docs/index.html", | |
| "redoc": "redocly build-docs $npm_package_config_specfile -t actions/redoc/template.hbs --templateOptions docs/templateOptions.json --title=\"Lob API documentation\" -o docs/index.html", |
There was a problem hiding this comment.
I don’t think this applies to the Redocly CLI version in this PR. redocly build-docs --help documents dot notation for --templateOptions, and the generated docs/index.html confirms these values are being rendered correctly: templateOptions.LOB_URL, canonicalUrl, image URLs, etc. are populated.
Also, from the CLI implementation, templateOptions is passed through from parsed argv, while JSON/file parsing is applied to --theme/openapi options. So changing this to --templateOptions docs/templateOptions.json may actually make templateOptions a string path rather than the object expected by the template.
- Replace deprecated redoc-cli with the already-present @redocly/cli - Remove patch-package and the redoc-cli patch (no longer needed) - Migrate redocOptions.json theme/display settings into .redocly.yaml - Update cd.yml to use npm install instead of inline redoc-cli install
The third-party action runs in a Node 12 container which is incompatible with @redocly/cli (uses optional chaining). Replace with a plain npm run bundle step on the host runner. Also add setup-node and fix deprecated set-output command.
- Use npm ci in CD workflow for reproducible installs - Remove unused extract_branch step from CD workflow - Move @redocly/cli to devDependencies at stable ^2.31.5 - Fix fontWeight type to string in .redocly.yaml - Update template.hbs variable references to templateOptions.* namespace - Delete docs/redocOptions.json (options now in .redocly.yaml) - Regenerate dist artifacts and docs/index.html
The docs build now loads Redoc from cdn.redocly.com rather than embedding it inline, consistent with how @redocly/cli works by default. Update docs/README.md and the CD workflow step name to reflect reality.
fe9c69e to
9345ee9
Compare
|
Question: are we OK with the generated docs now depending on Redocly’s CDN for the core Redoc runtime? Before this PR, The page already had other external assets, so it was not fully offline before, but this is a new external dependency for the docs renderer itself. If the "zero dependency" is intentional, I think I can preserve the old behavior with a small post-build inlining step. |
Jira
FD-880
Description
Migrates the docs toolchain from the deprecated
redoc-clito@redocly/cli.Changes
package.jsonredoc-cli(devDependency) with@redocly/cli@^2.31.5patch-packagedependency andpostinstallpatch-package hookredocscript fromredoc-cli buildtoredocly build-docs; drop--options=docs/redocOptions.json(config moved to.redocly.yaml).redocly.yamldocs/redocOptions.jsoninto.redocly.yamlundertheme.openapidisallowAdditionalProperties→allowAdditionalProperties: true.github/workflows/cd.ymlhilary/openapi-cli-bundle-action@v0.0.2withnpm ci && npm run bundleextract_branchstep.github/workflows/ci.ymlnpm i prettier && npm run prettywithnpm ci && npm run pretty:checkto enforce Prettier as a check rather than auto-fixingDeleted
docs/redocOptions.json— config moved to.redocly.yamlpatches/redoc-cli+0.13.16.patch— no longer neededdocs/README.mdredoc-clito@redocly/cli