-
-
Notifications
You must be signed in to change notification settings - Fork 555
Open
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library
Description
openapi-fetch version
0.14.0
Description
openapi-fetch doesn't cope well with methods accepting text/plain body. It ignores the compiled information about the body content and processes the passed arguments as application/json.
Reproduction
We have an OpenAPI schema with an endpoint that goes like this.
post:
requestBody:
required: true
content:
text/plain:
schema:
type: string
The compiler then processes it correctly:
"/api/my_method": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
post: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
"text/plain": string;
};
};
// ...
}
}
But the request sent by browser has:
Content-Type: application/json
header (that we could change manually passing the header ourselves)- The body parameter has string type but it is encoded with
JSON.stringify
before being sent.
Expected result
The request should be sent with a correct Content-Type and not be encoded as JSON value.
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library