openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Encode the request body if `Content-Type` header is `x-www-form-urlencoded`

Open obulat opened this issue 10 months ago • 3 comments

Changes

Fixes #2069 This PR updates the defaultBodySerializer to correctly serialize the body if Content-Type header is set to x-www-form-urlencoded. This is useful for OAuth2 token requests.

How to Review

I'm not sure about the headers: what type are they, and are they normalized? I added handling for both a plain JS object (headers['Accept-Content']) and a Headers object (headers.get['Accept-Content']), as well as both capitalized and lower-case versions.

Checklist

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

obulat avatar Jan 11 '25 06:01 obulat