Skip to content

chore: fetch OpenAPI spec directly from cloudflare/api-schemas - #490

Draft
teamchong wants to merge 1 commit into
mainfrom
stevenchong/retire-surfaces-direct-api-schemas
Draft

teamchong wants to merge 1 commit into
mainfrom
stevenchong/retire-surfaces-direct-api-schemas

Conversation

@teamchong

Copy link
Copy Markdown
Contributor

Fetch openapi.json directly from cloudflare/api-schemas instead of the openapi.forge.json GitHub release artifact on cloudflare/forge.

  • packages/cli/generate.ts: Combine matching /accounts/{account_id}/<subpath> and /zones/{zone_id}/<subpath> route pairs into /{account_or_zone}/{account_or_zone_id}/<subpath> at the start of prepareAccountOrZoneOperations, and ignore legacy v1 /accounts/{account_id}/cloudforce-one/requests operations that still carry x-forge-hidden: true upstream.
  • scripts/update-openapi.ts: Resolve the latest commit SHA from repos/cloudflare/api-schemas/commits/main instead of repos/cloudflare/forge/releases/latest.

Depends on cloudflare/forge#89 for the @cloudflare/forge linker updates.

Before:

https://github.com/cloudflare/forge/releases/download/openapi@${FORGE_OPENAPI_VERSION}/openapi.forge.json

After:

https://raw.githubusercontent.com/cloudflare/api-schemas/${FORGE_OPENAPI_VERSION}/openapi.json

@teamchong
teamchong requested a review from a team as a code owner November 3, 2026 03:00
Comment thread packages/cli/generate.ts Resolved
@ask-bonk

ask-bonk Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

Posted 1 inline suggestion.

github run

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 06d4fbe0.

This review, of b06b1c82

💬 Approved with comments — Nothing found makes this unsafe to merge. One WARNING: the new account/zone route merge strips shared path-item keys from zone paths that still have operations. There are also open questions about the pinned SHA and the Forge dependency, plus stale developer docs.

Findings: 2 warnings · 1 question · 1 info · 1 suggestion (3 are inline comments on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #490.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (2)

### [Code Quality] Merging account/zone routes deletes shared path-item keys (e.g. path-level `parameters`) from zone paths that are kept because they have extra methods, which can leave those operations without their `{zone_id}` parameter.
- **File:** packages/cli/generate.ts:257

### [Documentation] `scripts/README.md`, `docs/architecture.md` and `packages/cli/AGENTS.md` still describe fetching the Forge `openapi.forge.json` release asset. Update them for the `cloudflare/api-schemas` source.

## INFO (1)

### [Code Quality] The new `combineAccountAndZoneRoutes` and legacy cloudforce-one handling have no tests.
- **File:** packages/cli/generate.ts:154

## SUGGESTION (1)

### [Code Quality] The JSDoc for `prepareAccountOrZoneOperations` now documents `rewriteAccountZoneDocumentation`.
- **File:** packages/cli/generate.ts:145

## QUESTIONS (1)

### [Code Quality] The pinned `FORGE_OPENAPI_VERSION` (`ec5b5772…`) was a Forge release identifier and now resolves to `raw.githubusercontent.com/cloudflare/api-schemas/<sha>/openapi.json`. Is this SHA a real `cloudflare/api-schemas` commit? Also, should the pinned `@cloudflare/forge` build be bumped here, given the stated dependency on cloudflare/forge#89?
- **File:** packages/cli/generate.ts:20

📋 Code Quality: ⚠️ 1 warning · 1 question · 1 info · 1 suggestion

The route-combining logic can leave zone-only operations without their path-level keys. The pinned SHA and the Forge dependency need confirming, and the new logic has no tests.

Recommendation: 📝 Minor Comments

  • [WARNING] Merging account/zone routes deletes shared path-item keys (e.g. path-level parameters) from zone paths that are kept because they have extra methods, which can leave those operations without their {zone_id} parameter. (packages/cli/generate.ts:257)
  • [QUESTION] The pinned FORGE_OPENAPI_VERSION (ec5b5772…) was a Forge release identifier and now resolves to raw.githubusercontent.com/cloudflare/api-schemas/<sha>/openapi.json. Is this SHA a real cloudflare/api-schemas commit? Also, should the pinned @cloudflare/forge build be bumped here, given the stated dependency on cloudflare/forge#89? (packages/cli/generate.ts:20)
  • [INFO] The new combineAccountAndZoneRoutes and legacy cloudforce-one handling have no tests. (packages/cli/generate.ts:154)
  • [SUGGESTION] The JSDoc for prepareAccountOrZoneOperations now documents rewriteAccountZoneDocumentation. (packages/cli/generate.ts:145)
View full review
  • Partial merge strips zone path-item keys (packages/cli/generate.ts:255-258). combineAccountAndZoneRoutes deletes every key of the cloned account item from both source path items, including path-level parameters, summary, description and servers. If the zone path has a method the account path lacks, the zone path is kept, but it can lose the path-level parameters that declare {zone_id}. That method's spec is then broken. The zone variant's own request and response schemas are also dropped in favour of the account variant's.
  • Pinned SHA and Forge dependency (packages/cli/generate.ts:17). FORGE_OPENAPI_VERSION is unchanged, but it now resolves against cloudflare/api-schemas instead of a Forge release tag. The description also says this needs cloudflare/forge#89, and the pinned Forge build is not bumped here.
  • No tests for combineAccountAndZoneRoutes or the legacy cloudforce-one handling.
  • Misplaced JSDoc (packages/cli/generate.ts:145). The doc block for prepareAccountOrZoneOperations now sits above rewriteAccountZoneDocumentation.

📝 Documentation: ⚠️ 1 warning

Developer docs still describe the Forge release asset flow.

Recommendation: 📝 Minor Comments

  • [WARNING] scripts/README.md, docs/architecture.md and packages/cli/AGENTS.md still describe fetching the Forge openapi.forge.json release asset. Update them for the cloudflare/api-schemas source.
View full review

Three developer docs still say the OpenAPI pin comes from the latest Forge release and its openapi.forge.json asset: scripts/README.md:16-19, docs/architecture.md (around lines 147 and 787) and packages/cli/AGENTS.md:73-75. Update them to describe the cloudflare/api-schemas main-commit lookup and the openapi.json download.


✅ All other checks passed

🔒 Security: ✅ LGTM

The new latest-commit lookup accepts only a 40-character hex SHA before it is interpolated into the URL, the version pin and the PR body. The route rewriting runs only at build time, on the spec document.


📖 AGENTS.md: ✅ LGTM

The packages/cli/AGENTS.md:73-75 description of the OpenAPI source is covered in the documentation section.


⚡ Performance: ✅ LGTM

No performance concerns.


Reviewed commit: b06b1c82

Comment thread packages/cli/generate.ts Resolved
Comment thread packages/cli/generate.ts Resolved
Comment thread packages/cli/generate.ts Resolved
@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from b06b1c8 to 06d4fbe Compare November 3, 2026 03:10
@pkg-pr-new

pkg-pr-new Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@490

commit: 6d2dcc8

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

cf --help startup

mean stddev min max
PR 298.0 ms 6.6 ms 289.3 ms 317.2 ms
base 301.1 ms 11.1 ms 291.1 ms 330.9 ms

Δ (PR vs base): ↓ -3.1 ms (-1.0%)

Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.

@ask-bonk

ask-bonk Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Review: 0 findings.

No new concerns since the last review.

github run

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 307f323a.

This review, of 06d4fbe0

💬 Approved with comments — One correctness WARNING: the account/zone route merge removes path-level keys from zone paths that are kept. One documentation WARNING: the developer docs are stale. There is also an open question about the pinned SHA. Nothing found is a blocking production risk.

Findings: 2 warnings · 1 question · 2 info · 1 suggestion (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #490.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (2)

### [Code Quality] combineAccountAndZoneRoutes deletes every key of the account item, including path-level `parameters`, from a zone path that is kept because it has extra methods. Those operations can lose their `{zone_id}` path parameter.
- **File:** packages/cli/generate.ts:257

### [Documentation] scripts/README.md, docs/architecture.md and packages/cli/AGENTS.md still say the OpenAPI pin comes from the latest Forge release and its `openapi.forge.json` asset. Update them to describe the cloudflare/api-schemas commit lookup and the `openapi.json` download.

## INFO (2)

### [Code Quality] The new combineAccountAndZoneRoutes logic and the handling of the legacy cloudforce-one v1 operations have no tests.
- **File:** packages/cli/generate.ts:153

### [Documentation] The comment on the pin still calls the SHA a release, but it now identifies a cloudflare/api-schemas commit.
- **File:** packages/cli/generate.ts:16

## SUGGESTION (1)

### [Code Quality] The JSDoc describing prepareAccountOrZoneOperations now sits above rewriteAccountZoneDocumentation.
- **File:** packages/cli/generate.ts:145

## QUESTIONS (1)

### [Code Quality] FORGE_OPENAPI_VERSION is unchanged but now resolves to raw.githubusercontent.com/cloudflare/api-schemas/<sha>/openapi.json. Is `ec5b5772…` a commit in cloudflare/api-schemas? If not, `pnpm generate` will fail with a 404.
- **File:** packages/cli/generate.ts:20

📋 Code Quality: ⚠️ 1 warning · 1 question · 1 info · 1 suggestion

The route merge removes shared path-item keys from zone paths that are kept, the pinned SHA has not been confirmed, and the new logic has no tests.

Recommendation: 📝 Minor Comments

  • [WARNING] combineAccountAndZoneRoutes deletes every key of the account item, including path-level parameters, from a zone path that is kept because it has extra methods. Those operations can lose their {zone_id} path parameter. (packages/cli/generate.ts:257)
  • [QUESTION] FORGE_OPENAPI_VERSION is unchanged but now resolves to raw.githubusercontent.com/cloudflare/api-schemas/<sha>/openapi.json. Is ec5b5772… a commit in cloudflare/api-schemas? If not, pnpm generate will fail with a 404. (packages/cli/generate.ts:20)
  • [INFO] The new combineAccountAndZoneRoutes logic and the handling of the legacy cloudforce-one v1 operations have no tests. (packages/cli/generate.ts:153)
  • [SUGGESTION] The JSDoc describing prepareAccountOrZoneOperations now sits above rewriteAccountZoneDocumentation. (packages/cli/generate.ts:145)
View full review
  • Shared keys removed from zone paths that are kept (packages/cli/generate.ts:255-258). The loop deletes every key of the cloned account item from both source items, including path-level parameters, summary, description and servers. When the zone path has a method the account path lacks, that zone path is kept, but it can lose the path-level parameter that declares {zone_id}.
  • Pinned SHA (packages/cli/generate.ts:17-20). The same SHA is now used for cloudflare/api-schemas. Please confirm it is a commit in that repository.
  • No tests for combineAccountAndZoneRoutes or the handling of the legacy cloudforce-one v1 operations.
  • Misplaced JSDoc (packages/cli/generate.ts:130-145). The doc block for prepareAccountOrZoneOperations now sits above rewriteAccountZoneDocumentation.

The @cloudflare/forge bump in package.json and the lockfile is consistent.


📝 Documentation: ⚠️ 1 warning · 1 info

The developer docs and one comment in the generator still describe the retired Forge release-asset source.

Recommendation: 📝 Minor Comments

  • [WARNING] scripts/README.md, docs/architecture.md and packages/cli/AGENTS.md still say the OpenAPI pin comes from the latest Forge release and its openapi.forge.json asset. Update them to describe the cloudflare/api-schemas commit lookup and the openapi.json download.
  • [INFO] The comment on the pin still calls the SHA a release, but it now identifies a cloudflare/api-schemas commit. (packages/cli/generate.ts:16)
View full review
  • These docs still describe picking the latest Forge release and downloading its openapi.forge.json asset:

    • scripts/README.md:16-19,29-30
    • docs/architecture.md:147,787-788
    • packages/cli/AGENTS.md:73-75

    Update them for the cloudflare/api-schemas main-commit lookup and the openapi.json download, including the note about anonymous requests.

  • packages/cli/generate.ts:16 still says to bump the SHA for a "new release". The SHA now identifies an api-schemas commit.


✅ All other checks passed

🔒 Security: ✅ LGTM

The latest-commit lookup checks the SHA against ^[0-9a-f]{40}$ before it goes into the URL, the version pin and the pull request body. The route rewriting runs only at build time on the spec document. The @cloudflare/forge pin moves to another commit-pinned build, with a matching integrity hash in the lockfile.


📖 AGENTS.md: ✅ LGTM

The packages/cli/AGENTS.md:73-75 description of the OpenAPI source is covered in the documentation section.


⚡ Performance: ✅ LGTM

No performance concerns.


Reviewed commit: 06d4fbe0

Comment thread packages/cli/generate.ts Resolved
@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from 06d4fbe to 307f323 Compare November 3, 2026 03:21
@ask-bonk

ask-bonk Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💬 Approved with comments — The earlier correctness and documentation warnings are fixed. What remains is a question about whether the pinned SHA exists in cloudflare/api-schemas, and a note about missing tests.

Findings: 1 question · 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: ❓ 1 question · 1 info

The earlier issues are fixed. A question about the pinned SHA and a note about missing tests remain.

Recommendation: 💬 Optional Nits

  • [QUESTION] FORGE_OPENAPI_VERSION is unchanged but now resolves to raw.githubusercontent.com/cloudflare/api-schemas/<sha>/openapi.json. Please confirm ec5b5772… is a commit in cloudflare/api-schemas; otherwise pnpm generate fails with a 404. (packages/cli/generate.ts:17)
  • [INFO] combineAccountAndZoneRoutes and the legacy cloudforce-one v1 handling have no tests. (packages/cli/generate.ts:138)
View full review
  • Pinned SHA (packages/cli/generate.ts:17-20): the value of FORGE_OPENAPI_VERSION has not changed, but it is now used as a commit in cloudflare/api-schemas. If that repository has no such commit, the raw.githubusercontent.com download returns a 404 and pnpm generate fails.
  • No tests for combineAccountAndZoneRoutes or for the handling of the legacy cloudforce-one v1 operations.

Fixed since the last review:

  • Only the combined HTTP methods are deleted now, so a zone path that is kept still has its path-level keys.
  • The JSDoc is back above prepareAccountOrZoneOperations.

The changes to scripts/update-openapi.ts and its tests match each other.


✅ All other checks passed

🔒 Security: ✅ LGTM

The update script checks the commit SHA against ^[0-9a-f]{40}$ before it goes into the URL or the version pin. The spec rewriting runs only at build time. The @cloudflare/forge pin moves to another commit-pinned build, with a matching integrity hash in the lockfile.


📖 AGENTS.md: ✅ LGTM

packages/cli/AGENTS.md now describes the OpenAPI source correctly.


⚡ Performance: ✅ LGTM

No performance concerns. The changes run only at build time.


📝 Documentation: ✅ LGTM

scripts/README.md, docs/architecture.md and packages/cli/AGENTS.md now describe the cloudflare/api-schemas commit lookup and the openapi.json download. The comment on the pin in generate.ts now refers to an api-schemas commit.


Reviewed commit: 307f323a

@petebacondarwin
petebacondarwin marked this pull request as draft November 3, 2026 10:19
@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch 2 times, most recently from 84ed843 to 317fb4b Compare November 3, 2026 20:51
@ask-bonk

ask-bonk Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

🤖 I've done a thorough review of your PR.

Fetches OpenAPI directly from cloudflare/api-schemas and rewrites route handling.

  1. Blocking packages/cli/generate.ts:285: Updated the existing suggestion. The rewrite combines unrelated account/zone endpoints, replacing zone schemas and hiding zone-only operations.

github run

@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from 317fb4b to 6d2dcc8 Compare November 3, 2026 20:58
@ask-bonk

ask-bonk Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

No new concerns since the last review

github run

@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from 6d2dcc8 to 8d2a05b Compare November 4, 2026 00:28
@ask-bonk

ask-bonk Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from 8d2a05b to 56e9fd3 Compare November 4, 2026 15:13
Comment thread packages/cli/generate.ts Outdated
// Bump this SHA to generate the commands from a new release.
const FORGE_OPENAPI_VERSION = "ec5b5772f5cf7dfb16c49f3527671edfa37bb666";
// Bump this SHA to generate the commands from a newer cloudflare/api-schemas commit.
const FORGE_OPENAPI_VERSION = "193e683baba9c46b675d91c959c3b9a7926b2d84";

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.

193e683baba9c46b675d91c959c3b9a7926b2d84 is not a commit in cloudflare/api-schemas: GitHub's commit API returns 422 and the raw openapi.json URL returns 404. Consequently pnpm generate fails before Forge runs. Pin a real api-schemas commit (the commit below existed before this PR was opened and serves openapi.json) and regenerate the committed output.

Suggested change
const FORGE_OPENAPI_VERSION = "193e683baba9c46b675d91c959c3b9a7926b2d84";
const FORGE_OPENAPI_VERSION = "bdea3bc5b21212e02c8b54dd8f0c5929a4f7b8cf";

@ask-bonk

ask-bonk Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Review: 1 findings.

🤖 I've done a thorough review of your PR.

Fetches OpenAPI directly from cloudflare/api-schemas.

  1. Blocking: Posted 1 inline suggestion for the invalid OpenAPI commit pin.

github run

@teamchong
teamchong force-pushed the stevenchong/retire-surfaces-direct-api-schemas branch from 56e9fd3 to 2e3387e Compare November 4, 2026 20:03
@ask-bonk

ask-bonk Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants