Skip to content

fix(downgrader): inline pathItems refs, convert cycles, map the 3.2 dialect - #10

Merged
dinwwwh merged 2 commits into
mainfrom
claude/downgrader-deep-review-c56715
Sep 7, 2026
Merged

fix(downgrader): inline pathItems refs, convert cycles, map the 3.2 dialect#10
dinwwwh merged 2 commits into
mainfrom
claude/downgrader-deep-review-c56715

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 7, 2026

Copy link
Copy Markdown
Member

Deep review of @openapi-spec/downgrader with fixes for the gaps it turned up. 3.1 → 3.0 output no longer contains dangling $refs into the removed components.pathItems, cyclic input graphs come out fully converted, and 3.2 documents stop carrying a 3.2 dialect URI into 3.1.

Fixes

  • $refs into components.pathItems are inlined in paths and callbacks, following alias chains; the referencing Path Item's own fields win on overlap. Unknown or cyclic targets are left as they were.
  • A subtree that cycles back to an ancestor now points at that ancestor's converted form instead of an unconverted clone, so dereferenced circular documents downgrade cleanly.
  • jsonSchemaDialect naming a 3.2 OAS dialect becomes https://spec.openapis.org/oas/3.1/dialect/base; other dialects pass through.
  • A non-string response summary no longer becomes the required 3.1 description; it falls back to "".

Performance

  • Output keys are assigned directly; only __proto__ is defined, so it stays a plain own property instead of replacing the prototype. Cloning is roughly twice as fast.

Testing

  • 350 tests pass with 100% statement and branch coverage; lint, type-check and build are clean.
  • New tests cover path item inlining (overrides, chains, callbacks, unknown, malformed and cyclic targets), cycle conversion, the dialect rewrite, and setOwn against __proto__ and other Object.prototype member names.
  • The e2e test that pinned the dangling-reference behaviour now asserts inlining and validates the result against the official 3.0 schema.

Kept as-is

  • A $schema inside a Schema Object naming the 3.2 dialect passes through (listed in the README as a known limitation).
  • Discriminator defaultMapping still survives into 3.0 output, as before.

…ialect

Path Item `$ref`s into `components.pathItems` are now inlined on the 3.1
to 3.0 hop instead of dangling in the output, following alias chains and
letting the referencing object's own fields win. Cyclic object graphs
(dereferenced documents) are converted with their cycles preserved rather
than deep-copied unconverted. A 3.2 `jsonSchemaDialect` is rewritten to
the 3.1 base dialect, and a non-string response `summary` no longer lands
in the required 3.1 `description`.

Output keys are assigned directly unless the prototype chain already
knows them, which roughly halves cloning time while keeping `__proto__`
and frozen-intrinsics environments safe.
@pullfrog

pullfrog Bot commented Sep 7, 2026

Copy link
Copy Markdown

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Plain assignment already creates own properties for every other key on a
plain object; only `__proto__` would route through the inherited setter.
The prototype-chain guard and its frozen-intrinsics test are dropped.
@dinwwwh
dinwwwh merged commit 47f3e55 into main Sep 7, 2026
6 checks passed
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.

1 participant