[typescript-fetch] serialize complex type in multipart/form-data as JSON#7677
[typescript-fetch] serialize complex type in multipart/form-data as JSON#7677macjohnny merged 1 commit intoOpenAPITools:masterfrom verokarhu:serialize-complex-types-as-json-in-typescript-fetch
Conversation
|
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
macjohnny
left a comment
There was a problem hiding this comment.
thanks for your contribution
There was a problem hiding this comment.
what if the parameter is e.g. a Blob, is it also a primitive type?
There was a problem hiding this comment.
Yes, it's a primitive. I updated the PR cover letter with test details that includes binary data.
|
I may have run into an issue with the fix as-is, I'll convert this into a draft until it's fixed. |
…SON (#7658) Complex types need to be serialized as JSON to avoid FormData.append() from converting them into strings through .toString(). The generated ToJSON mapper is used in case the value name has underscores or other unusual characters. Signed-off-by: Andreas Metsälä <andreas.metsala@gmail.com>
Fixed it, a straightforward conversion did not work with unusual names. The object has to be run through the generated ToJSON mapper method. |
|
Might this be able to make it to the next beta? |
Complex types need to be serialized as JSON to avoid FormData.append()
from converting them into strings through .toString().
Fixes #7658
Tested locally by running the generator against the following schema:
This resulted in the following serialization code:
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.master@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)