Open pedromtcosta opened 1 year ago
Hello @pedromtcosta !
Thanks for this question.
Can you describe why your solution is not a good solution in details ?
Just this package is template driven and you can redefine part of swagger schema fields which your swagger schema is using.
Main target for this project is browser, I'm trying to help you how to better create this function createFormData
, but I don't know how, sorry. I hope community of this project will help you
Also you can try rewrite fully http-client template as you want
Hi @js2me !
Basically, the problem with my solution is that I have to provide a file name, which contains the file extension, so generating a "random" name would not work. One thing that could work nicely for this case is if I can somehow map string.binary
to be a custom type, so I could do something like:
type MyFile = {
contents: Buffer
name: string
}
then the only problem I'd have in this case is that I'd need to change the createFormData
function every time I re-generate the client. So I guess my questions at this point would be:
string.binary
to a custom type?createFormData
is generated?
The client gets generated with the
createFormData
function that is used when the request content ismultipart/form-data
. The problem is that this function uses the typesBlob
andFile
, which are not available in the NodeJS runtime:using
primitiveTypeConstructs
to changestring.binary
fromFile
toBuffer
for example does not work for 2 reasons:createFormData
still uses theBlob
andFile
types;Buffer
type lacks some stuff that's needed to upload a file withFormData
, such as the file name;Just as a test, I changed the
createFormData
function to be like the one below and it worked nicely in an API I am testing with, but this is obviously not a good solution:so, is it possible to use
multipart/form-data
in NodeJS?