openapi-typescript-fetch
openapi-typescript-fetch copied to clipboard
How to provide request body?
I need to pass formdata for file upload to the request, but there is no documented way how to do that.
@JanCizmar only json request body is supported. The main use of the library is for strongly typed request and response...
The request is strongly typed:
Relevant part of paths
interface
addFiles_1: {
parameters: {
query: {
ak?: string;
};
};
responses: {
/** OK */
200: {
content: {
"*/*": components["schemas"]["ImportAddFilesResultModel"];
};
};
/** Bad Request */
400: {
content: {
"*/*": string;
};
};
/** Not Found */
404: {
content: {
"*/*": string;
};
};
};
requestBody: {
content: {
"multipart/form-data": {
files: string[];
};
};
};
};
So the request body is strictly typed.
I'm also encountering this use case for endpoints that expect binary bodies. I think this would be achievable by not overriding the body that can be passed via RequesInit
with JSON if it's already present. What do you think @ajaishankar ?
Is there any update on this issue and the PR #50?