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
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.
The compiler then processes it correctly:
But the request sent by browser has:
Content-Type: application/jsonheader (that we could change manually passing the header ourselves)JSON.stringifybefore being sent.Expected result
The request should be sent with a correct Content-Type and not be encoded as JSON value.
Extra