Skip to content

OpenAPI accuracy: runtime headers and 405, auth 401/403 per method, mixed error scopes; standard formats for parameters (#881) - #894

Merged
jimhoyd merged 2 commits into
mainfrom
claude/openapi-accuracy
Sep 29, 2026
Merged

jimhoyd merged 2 commits into
mainfrom
claude/openapi-accuracy

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fixes #881 items 3, 4, 5, 6 and 9. Items 1 and 2 (extension contributions, function response schemas) stay open there.

OpenAPI (openapi.ts)

  • Runtime headers (item 3). Every response declares X-Request-Id and X-Content-Type-Options: nosniff as reusable components.headers; the runtime always sets both and handlers can't replace them. Cache-Control: no-store is declared only on the runtime's own error responses (400/404/413/415/422).
  • The 405 (item 3). An undeclared method has no operation to hang a response on, so each path item gets x-urlcode.methodNotAllowed with:
    • the exact Allow value;
    • a reference to a components.responses entry in the path's error format.
    • It notes that earlier gates (throttle, agents, an extension's authorize, a plugin) may answer first.
  • Auth responses (item 4). auth: true routes declare 401 on every method and 403 only on POST, PUT, PATCH and DELETE, matching the auth extension.
  • site.errors scopes (item 5). Scopes are matched segment by segment against the route pattern.
    • Full coverage gives json.
    • Partial coverage (an exact /users/42 beside /users/{id}, or /v2/* over /{version}/items) gives mixed. x-urlcode.errorScope lists the covering entries, and the error bodies are declared in both formats.
  • Contract run (item 6). Now reusable. It checks the runtime headers and one undeclared method per path (405 with the Allow value). It also runs against a project with:
    • an auth: true route: 401 on GET and POST, 403 on a cross-origin POST, 200 on a cross-origin GET;
    • two function routes: one with a required query parameter, one with a date-formatted body.
    • A separate test serves the mixed case.

Parameter formats (item 9)

  • Path and query parameters accept the same nine standard formats as bodies, with the same functions and caps. Cloudflare's parameter validators inline the same checks.
  • schemas/urlcode.schema.json and the capability text list all nine; an unknown format fails at load.
  • Changed test: test/body-validation.test.ts now uses idn-email as the unsupported example.

Evidence (macOS, Node 26), rebased on main after #891

Docs: TOOLING (the OpenAPI "Not yet described" list is down to items 1 and 2), HTTP, RIM-INPUT-001, RIM-OPENAPI-001, llms.

🤖 Generated with Claude Code

jimhoyd and others added 2 commits September 28, 2026 21:46
…cy; parameter formats (#881)

OpenAPI export (#881 items 3-6):
- Every response names X-Request-Id and X-Content-Type-Options (reusable
  components.headers); the runtime's own errors also name their fixed
  Cache-Control: no-store. Cache-Control is not stated elsewhere, since a
  handler, declared header or cache policy may set it.
- Each path item states the 405 for an undeclared method under
  x-urlcode.methodNotAllowed: the exact Allow value and a
  components.responses body in the path's error format.
- auth: true routes declare 401 on every method and 403 only on POST, PUT,
  PATCH and DELETE, matching the auth extension's authorize().
- site.errors entries are compared with the route pattern segment by
  segment. An entry covering only some concrete paths of a templated route
  (an exact /users/42 beside /users/{id}) makes the path `mixed`:
  x-urlcode.errorScope lists the entries and each runtime error declares
  both bodies.
- The contract run now also covers a project with an auth: true route
  (synthetic auth extension) and function routes, checks the runtime
  headers, and provokes a 405 on every path.

Parameter formats (#881 item 9): path, query and header parameter schemas
accept the body schema's standard formats (date, time, date-time, email,
uri, hostname, ipv4, ipv6, uuid) through the same body-formats.ts checks
and caps; the Cloudflare build inlines them into validators.js. Schema,
capability text, HTTP.md and RIM-INPUT-001 updated; workerd parity cases
added.

Unpacked package budget raised by the measured growth (3604 to 3614 KiB).

Items 1 and 2 (extension contributions, function response schemas) remain
open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 02:52
@jimhoyd
jimhoyd merged commit 1459b22 into main Sep 29, 2026
25 checks passed
@jimhoyd
jimhoyd deleted the claude/openapi-accuracy branch September 29, 2026 02:58
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.

OpenAPI export and schema follow-ups: extension contributions, function response schemas, 405/common headers, more formats

1 participant