Skip to content

Conversation

@swantzter
Copy link

@swantzter swantzter commented Dec 8, 2025

it's relatively expensive to have to clone the request to extract the body again in middleware, and as bodySerializer is provided as part of the options given to the requestSerializer it makes sense to also provide the original body here for advanced use cases that aren't covered by the bodySerializer.

In my case I'm dealing with an API that wants files uploaded to a secondary endpoint after the main request has completed, but I want to provide a good developer experience where they can provide a body such as { description: string, document: File }, to do this I need to traverse the body in a request middleware, extract the files (removing them from the serialized JSON body), link these files to the id (or new Request in a WeakMap), and then if they exist in the onResponse middleware actually post them.

Changes

  • adds body as one of the properties of the options passed to onRequest middleware

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

it's relatively expensive to have to clone the request to extract the
body again in middleware, and as bodySerializer is provided as part of
the options given to the requestSerializer it makes sense to also
provide the original body here for advanced use cases that aren't
covered by the bodySerializer.
@swantzter swantzter requested a review from a team as a code owner December 8, 2025 14:22
@swantzter swantzter requested a review from kerwanp December 8, 2025 14:22
@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

⚠️ No Changeset found

Latest commit: 944502d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Dec 8, 2025

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 944502d

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