fix: send request body for OpenAPI 3.x operations that declare parameters#384
Open
ALagoni97 wants to merge 1 commit into
Open
fix: send request body for OpenAPI 3.x operations that declare parameters#384ALagoni97 wants to merge 1 commit into
ALagoni97 wants to merge 1 commit into
Conversation
…ters The request-body extractor treated the presence of an operation `parameters` array as an OpenAPI 2.0 signal and looked for a `in: 'body'` parameter, returning nothing for 3.x operations. But 3.x operations routinely carry `parameters` (path/query/header) alongside a `requestBody`, so any such operation (e.g. a POST with an `X-Correlation-Id` header) had its body silently dropped: the generated context had no `payload` field and the client always sent `body = undefined`. Check `requestBody` first (OpenAPI 3.x) and only fall back to the `in: 'body'` parameter form when no `requestBody` is present (OpenAPI 2.0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for the-codegen-project canceled.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
The OpenAPI request-body extractor treated the presence of an operation
parametersarray as an OpenAPI 2.0 signal and looked for ain: 'body'parameter — returning nothing for 3.x.But OpenAPI 3.x operations routinely carry a
parametersarray (path/query/header) alongside arequestBody. So any POST/PUT/PATCH that also declared a parameter had its request body silently dropped:payloadfield, andconst body = undefined.A
POST /v2/connectwith anX-Correlation-Idheader and a required JSON body produced a client that could never send that body.Fix
Check
requestBodyfirst (OpenAPI 3.x) and only fall back to thein: 'body'parameter form when there is norequestBody(OpenAPI 2.0).Tests
test/codegen/inputs/openapi/payloads.spec.ts: a 3.x operation with bothparametersandrequestBodynow yields a*Requestoperation payload.payload.spec.tsOpenAPI 3.0/3.1 assertions — the fix un-drops anupdateUserrequest body the suite had been silently accepting as absent.🤖 Generated with Claude Code