-
-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Labels
Description
Describe the feature
Feature Request:
orpc currently always uses application/json as the Content-Type for OpenAPILink and other generated links (not sure). While this works for most cases, some APIs require different content types such as:
application/x-www-form-urlencodedmultipart/form-data
When using these content types, the request payload must be encoded differently than JSON.
Problem
There is no way to override Content-Type per operation, which prevents calling endpoints that do not accept JSON request bodies.
Expected Behavior
- Allow overriding
Content-Typeper OpenAPI operation or link. - Automatically serialize request data based on the selected content type.
Examples (JavaScript)
application/json
fetch("/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: "help",
password: "help",
}),
})application/x-www-form-urlencoded
fetch("/login", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: new URLSearchParams({
username: "help",
password: "help",
}),
})multipart/form-data
const form = new FormData()
form.append("username", "help")
form.append("password", "help")
fetch("/login", {
method: "POST",
body: form,
})Use Case
Required for authentication endpoints, legacy APIs, and form-based submissions that do not accept JSON payloads.
Additional information
- Would you be willing to help implement this feature?
unnoq, LudovicGen, MathieuCaselles, tresorama and Azzerty23