Skip to content

fix: send request body for OpenAPI 3.x operations that declare parameters#384

Open
ALagoni97 wants to merge 1 commit into
mainfrom
fix/openapi-request-body-detection
Open

fix: send request body for OpenAPI 3.x operations that declare parameters#384
ALagoni97 wants to merge 1 commit into
mainfrom
fix/openapi-request-body-detection

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

Problem

The OpenAPI 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.

But OpenAPI 3.x operations routinely carry a parameters array (path/query/header) alongside a requestBody. So any POST/PUT/PATCH that also declared a parameter had its request body silently dropped:

  • the generated context interface had no payload field, and
  • the client always sent const body = undefined.

A POST /v2/connect with an X-Correlation-Id header and a required JSON body produced a client that could never send that body.

Fix

Check requestBody first (OpenAPI 3.x) and only fall back to the in: 'body' parameter form when there is no requestBody (OpenAPI 2.0).

Tests

  • New test/codegen/inputs/openapi/payloads.spec.ts: a 3.x operation with both parameters and requestBody now yields a *Request operation payload.
  • Updated payload.spec.ts OpenAPI 3.0/3.1 assertions — the fix un-drops an updateUser request body the suite had been silently accepting as absent.

🤖 Generated with Claude Code

…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>
@ALagoni97 ALagoni97 requested a review from jonaslagoni as a code owner July 6, 2026 19:51
@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for the-codegen-project canceled.

Name Link
🔨 Latest commit bb4ef96
🔍 Latest deploy log https://app.netlify.com/projects/the-codegen-project/deploys/6a4c0749249a9f00087e05bf

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Jul 6, 2026 7:55pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 6, 2026 7:55pm

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