Skip to content

[typescript-axios] Serialize complex type in multipart/form-data as JSON#7816

Merged
macjohnny merged 1 commit intoOpenAPITools:masterfrom
pmfonsecatdx:fix-on-typescript-axios-blob-template
Nov 3, 2020
Merged

[typescript-axios] Serialize complex type in multipart/form-data as JSON#7816
macjohnny merged 1 commit intoOpenAPITools:masterfrom
pmfonsecatdx:fix-on-typescript-axios-blob-template

Conversation

@pmfonsecatdx
Copy link
Contributor

Complex types need to be serialized as JSON to avoid FormData.append() from converting them into strings through .toString().

Fixes #7658 for typescript-axios

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./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.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@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)

…SON (OpenAPITools#7658)

Complex types need to be serialized as JSON to avoid FormData.append() from converting them into strings through .toString().
@auto-labeler
Copy link

auto-labeler bot commented Oct 27, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macjohnny macjohnny added this to the 5.0.0 milestone Oct 27, 2020
@verokarhu
Copy link
Contributor

Does this also need the generated ToJSON mapper function or is the Axios path different?

@pmfonsecatdx
Copy link
Contributor Author

It worked perfectly without the TOJSON mapper. Can you explain why would it be needed?

@macjohnny macjohnny merged commit e3121af into OpenAPITools:master Nov 3, 2020
@wing328 wing328 changed the title [typescript-axios] Serialize complex type in multipart/form-data as JSON (#7658) [typescript-axios] Serialize complex type in multipart/form-data as JSON Nov 4, 2020
@verokarhu
Copy link
Contributor

It worked perfectly without the TOJSON mapper. Can you explain why would it be needed?

The typescript-fetch version required the mapper for values that have special characters in the name (e.g. underscores). You can check the PR #7677 which implemented it for a test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][typescript-fetch] Complex values are serialized as the string [object Object] in multipart/form-data

3 participants