openapi-typescript
openapi-typescript copied to clipboard
Encode the request body if `Content-Type` header is `x-www-form-urlencoded`
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:examplesrun (only applicable for openapi-typescript)