Skip to content

fix(openapi): preserve vendor +json Content-Type on object bodies - #1937

Open
The-AarushiSingh wants to merge 2 commits into
UsefulSoftwareCo:mainfrom
The-AarushiSingh:fix/openapi-vendor-json-content-type
Open

fix(openapi): preserve vendor +json Content-Type on object bodies#1937
The-AarushiSingh wants to merge 2 commits into
UsefulSoftwareCo:mainfrom
The-AarushiSingh:fix/openapi-vendor-json-content-type

Conversation

@The-AarushiSingh

Copy link
Copy Markdown
Contributor

Fixes #1930

Why

applyRequestBody in packages/plugins/openapi/src/sdk/invoke.ts treats any +json type as JSON (isJsonContentType).

  • String bodies used bodyText(..., contentType) and kept the declared type (application/vnd.api+json).
  • Object bodies used HttpClientRequest.bodyJsonUnsafe(...), which always sets Content-Type: application/json.

JSON:API and other vendor +json servers then return 415. Callers cannot pass a Content-Type header on the tool call.

Change

Object JSON bodies now JSON.stringify and go through bodyText with the declared media type, same as strings.

Added a test in non-json-body.test.ts: object body + application/vnd.api+json asserts that exact Content-Type on the wire.

Out of scope

Editable integration headers on updateSpec / configure. That is a separate feature. This PR only fixes the object-body header.

@baggiiiie baggiiiie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix works, verified locally on my end

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.

[bug] OpenAPI object JSON bodies always send Content-Type application/json, dropping vendor +json types

2 participants