Skip to content

fix(types): define 3.1 LinkObject locally, add prepack hook, extend type tests - #9

Merged
dinwwwh merged 2 commits into
mainfrom
claude/packages-types-review-2f3e40
Sep 7, 2026
Merged

fix(types): define 3.1 LinkObject locally, add prepack hook, extend type tests#9
dinwwwh merged 2 commits into
mainfrom
claude/packages-types-review-2f3e40

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 6, 2026

Copy link
Copy Markdown
Member

Deep review of @openapi-spec/types. Every interface's field list was cross-checked against the official OAS 3.0/3.1/3.2 JSON Schemas and matched; this PR fixes the two consistency and packaging gaps that turned up and adds the version-boundary type tests that tests/README.md previously only described.

Fixes

  • The 3.1 module no longer re-exports the 3.0 LinkObject. It referenced the 3.0 ServerObject while 3.1 redefines that type, so hover docs pointed at 3.0.4. LinkObject is now defined in v3.1.ts against the 3.1 ServerObject, in line with the module's re-export rule.
  • Publishing always ships a freshly built dist: a prepack script runs unbuild, matching @openapi-spec/downgrader.

Testing

  • 3.1-only fields are rejected in 3.0 documents (info.summary, license.identifier, jsonSchemaDialect, components.pathItems, type: "null", const), and Header Objects reject styles other than simple.
  • 3.2-only fields are rejected in 3.1 documents (querystring location, cookie style, $self, components.mediaTypes, server name, tag parent/kind, itemSchema, dataValue, defaultMapping, XML nodeType, security scheme deprecated, device authorization flow, response summary).
  • 3.2 accepts Reference Objects in request body, response, and header content maps.
  • pnpm type:check, pnpm lint, pnpm build, and pnpm test (327 tests) pass.

Reviewer notes

  • Known gap, intentionally left as is: TypeScript does not check values under numeric response keys such as 200: against the template-literal index signature of ResponsesObject (string keys are checked). A stricter mapped-type version was tried and dropped; a [statusCode: number] index signature would close the gap at the cost of accepting numeric out-of-range codes.
  • The repo has no LICENSE file, so npm publishes the package without one.

…ype tests

- Define LinkObject in v3.1 against the 3.1 ServerObject instead of
  re-exporting the 3.0 type, per the module's own re-export rule.
- Add a prepack build script so publishing always ships a fresh dist,
  matching the downgrader package.
- Add @ts-expect-error tests for fields that belong to a later spec
  version (3.1-only fields in 3.0, 3.2-only fields in 3.1), header style
  restriction, and positive tests for referenced media types in 3.2
  content maps.
@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog 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.

ℹ️ Two minor suggestions inline — otherwise this is mergeable as-is.

Reviewed changes — single commit 083815d across 5 files; I ran pnpm type:check, pnpm lint, and pnpm test (327 passing) and verified every version-boundary claim against the official OAS 3.0.4 / 3.1.2 / 3.2.0 spec text.

  • 3.1 LinkObject local definitionv3.1.ts stops re-exporting the 3.0 LinkObject and defines it locally against 3.1's ServerObject, fixing hover/docs pointing at the 3.0.4 type. Field set exactly matches the 3.1.2 spec; no gap.
  • prepack build hookpackages/types/package.json swaps "build": "unbuild" for "prepack": "unbuild" so publishing always ships freshly built dist.
  • 3.0 boundary tests — new @ts-expect-error tests reject 3.1-only fields (info.summary, license.identifier, jsonSchemaDialect, components.pathItems, type: 'null', const) and non-simple header styles.
  • 3.1 boundary tests — 13 negative tests reject 3.2-only fields (response summary, querystring location, cookie style, $self, components.mediaTypes, server name, tag parent, itemSchema, dataValue, defaultMapping, XML nodeType, scheme deprecated, device-authorization flow).
  • 3.2 positive tests — Reference Objects accepted as content-map values in request body, response, and header.

Verification notes: because pnpm type:check (which covers *.test-d.ts via the root tsconfig) passes, every @ts-expect-error directive is "used" — i.e. it suppresses a real error — so the negative tests genuinely pin the version boundaries rather than passing vacuously. Every version-claim comment in the tests was independently confirmed against the official spec text (including the high-risk ones: Response summary is indeed 3.2-only, Server Object gains only name in 3.2, and Header style stays simple-only across all three versions); no over-strict types were found.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

Comment thread packages/types/package.json
Comment thread packages/types/src/v3.1.test-d.ts
The test claimed to cover both parent and kind but only exercised parent.
TypeScript reports one excess property per object literal, so kind now
lives in its own tag entry with its own @ts-expect-error.

@pullfrog pullfrog 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.

ℹ️ The incremental change cleanly closes the prior test-coverage gap; no new issues found.

Reviewed changes — single commit b47d4aa touching only packages/types/src/v3.1.test-d.ts; I re-ran pnpm type:check and lint to confirm the new directive is live.

  • Tag kind boundary now pinned — the noTagHierarchy test negates the Tag Object's 3.2-only kind field (alongside parent) with its own @ts-expect-error. Because pnpm type:check covers *.test-d.ts and passes, the new directive genuinely suppresses an excess-property error rather than passing vacuously — confirmed against TagObject in v3.2.ts:1109 vs the 3.1-re-exported 3.0 shape.

The one other thread from the prior review (the buildprepack script rename nit in package.json:67) was left unchanged by this commit and is the author's call — the PR remains mergeable as-is.

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

@dinwwwh
dinwwwh merged commit ef7ca7d into main Sep 7, 2026
7 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