fix(httpapi): reuse named schemas across response statuses - #6837
Open
aryasaatvik wants to merge 2 commits into
Open
fix(httpapi): reuse named schemas across response statuses#6837aryasaatvik wants to merge 2 commits into
aryasaatvik wants to merge 2 commits into
Conversation
HttpApiSchema.status annotated the schema with httpApiStatus, forking the AST while the fork kept its identifier. A named schema reused with a non-default status then published duplicate OpenAPI components for one declared name (previously: Duplicate identifier throw). The status describes how one endpoint uses the schema, not what the schema is, so it now rides the AST key context — which representation identity already excludes — via annotateKey. Declaration-site statuses (the HttpApiError classes) keep working through the annotation fallback.
🦋 Changeset detectedLatest commit: 571d0c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Moved
httpApiStatusto key context —status()now usesannotateKeyso the status code is excluded from representation identity; a named schema reused with different status codes stays one OpenAPI component. - Context-first resolution with annotation fallback —
resolveHttpApiStatuscheckscontext.annotationsfirst, then the annotation resolver, soHttpApiErrorclasses (which usehttpApiStatusas a regular annotation) keep working without changes. - Test covering the exact bug — validates that a
Widgetschema used with both default 200 andstatus(201)produces a singleWidgetcomponent referenced by both responses.
The change is minimal (3 lines of behavioral code), the fallback is unambiguous, and all internal consumers go through resolveHttpApiStatus — no missed paths.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
…ation A memoized AST derivation (toCodecJson) rebuilds a node whenever any child changes - e.g. Unknown lowering to Json - allocating fresh property-signature wrappers and arrays per top-level input. Two ASTs that differ only in their key context (a named schema and its HttpApiSchema.status copy) are separate derivation inputs, so their rebuilt containers can never be reference-equal and representation identity split them into Widget and Widget_1. Container wrappers are pure structure with no identity of their own. When two ASTs hold the same annotations object - the token of one user declaration - their container slots now compare by contents instead of by reference. Anonymous nodes and nodes with different annotation objects keep pure reference identity, so referentially distinct declarations still suffix.
aryasaatvik
force-pushed
the
fix/httpapi-status-representation-identity
branch
from
August 1, 2026 15:49
cae36dc to
571d0c7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Reuse a named schema across response statuses without emitting duplicate OpenAPI components.
HttpApiSchema.statusnow stores status metadata in key context, while representation identity recognizes rebuilt containers from the same annotated declaration.Before / After
WidgetWidgetWidget_1WidgetChanges
httpApiStatusin key context, with annotation fallback for declaration-site statuses such asHttpApiError.Tests
status, including schemas containingUnknown.