Skip to content

Fixes body of FormParameters in multipart/form-data requests without files sent by generated C# (RestSharp) - #20351

Merged
wing328 merged 3 commits into
OpenAPITools:masterfrom
lewishazell:fix/20347-restsharp-multipart-without-file
Dec 22, 2024
Merged

Fixes body of FormParameters in multipart/form-data requests without files sent by generated C# (RestSharp)#20351
wing328 merged 3 commits into
OpenAPITools:masterfrom
lewishazell:fix/20347-restsharp-multipart-without-file

Conversation

@lewishazell

Copy link
Copy Markdown
Contributor

These are the fixes I have for issue #20347 where FormParameters are not correctly sent as a multipart/form-data body unless a file parameter is present.

This change sets RestRequest.AlwaysMultipartFormData to true if Content-Type is multipart/form-data and also removes serialization of FormParameters under the same condition as this causes further issues.

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.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    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*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@mandrean @shibayan @Blackclaws @lucamazzanti @iBicha

@wing328

wing328 commented Dec 22, 2024

Copy link
Copy Markdown
Member

appveyor tests passed via https://ci.appveyor.com/project/WilliamCheng/openapi-generator/builds/51213766

lets give it a try

thanks for the PR

@wing328
wing328 merged commit ff0fe26 into OpenAPITools:master Dec 22, 2024
timon-sbr pushed a commit to timon-sbr/openapi-generator that referenced this pull request Mar 13, 2025
…files sent by generated C# (RestSharp) (OpenAPITools#20351)

* fix: set RestRequest flag to force multipart/form-data when given as Content-Type

* fix: removed serialization of FormParameters for multipart/form-data

* updated csharp-restsharp samples
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.

2 participants