fix(openapi): operation-level parameters override path-level ones (same name+in) - #974
Open
Larslllllll wants to merge 1 commit into
Open
fix(openapi): operation-level parameters override path-level ones (same name+in)#974Larslllllll wants to merge 1 commit into
Larslllllll wants to merge 1 commit into
Conversation
…me name+in) Per the OpenAPI spec, an operation parameter with the same name and location as a path-level parameter replaces it. normalize() concatenated both, so every downstream consumer saw duplicated parameters: - generated docs showed duplicate parameter table rows - MCP input schemas silently overwrote one entry - the TS SDK emitted invalid code: `async getPet(petId: string, petId: string, ...)` — duplicate function arguments do not compile Operation-level params now replace same name+in path params ($refs in both positions are resolved before comparing). Path-level params not overridden are still inherited. Verified against a Petstore-style spec: before, getPet generated two petId arguments; after, one.
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.
Problem
normalize()concatenated path-level and operation-levelparametersarrays. Per the OpenAPI spec, an operation-level parameter with the samename+inreplaces the path-level one (it exists precisely to override description, schema, required, … per operation).Because both copies were kept, every consumer saw duplicated parameters:
openapi docsrenders duplicate rows in the parameters tableopenapi mcpsilently overwrites one entry in the input schemaopenapi sdkemits invalid TypeScript — duplicate function arguments:Repro
Spec:
/pets/{petId}declarespetIdat path level; thegetoperation re-declares it withminLength: 1.sh1pt openapi sdkon this spec produces the broken client above.Fix
name+inparameter.Tests
verbose)$\refto#/components/parameters/…All 10 openapi tests pass; typecheck clean.