-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] PHP client is not sending multipart request unless a file is part of the schema #5536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm running into a similar issue using v7.6.0. The generated code contains (Sidenote: The operation does not contain any files or binary data.) As a result, Guzzle sends requests without a According to https://stackoverflow.com/questions/43932900/multipart-form-data-without-a-boundary, this is invalid. Consequently, the server responds with Manually setting the value of |
I've started looking into this. @reeperbahnause correctly pointed out the right location in the template (updated for the latest commit on master). openapi-generator/modules/openapi-generator/src/main/resources/php/api.mustache Lines 670 to 674 in 640ef9d
This in turn causes openapi-generator/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache Lines 46 to 52 in 640ef9d
But Guzzle doesn't like that and requires you to omit the |
…5536) (#18991) * [php] Set $multipart to true if content-type is multipart/form-data (#5536) Related: #5536 * [php] Use isMultipart variable --------- Co-authored-by: Simon Hammes <[email protected]>
…penAPITools#5536) (OpenAPITools#18991) * [php] Set $multipart to true if content-type is multipart/form-data (OpenAPITools#5536) Related: OpenAPITools#5536 * [php] Use isMultipart variable --------- Co-authored-by: Simon Hammes <[email protected]>
Bug Report Checklist
Description
I noticed that even if the OpenAPI3 definition says it consumes
multipart/form-data
the generated client is not sending multipart request. It only sends multipart requests if a property of the typestring
and formatbinary
is defined and used in the request (definition only is not changing anything). In my point of view the client should send what the server api has defined to be consumed.openapi-generator version
4.2.3, 4.3.0 and 5.0.0
OpenAPI declaration file content or url
https://gist.github.com/reeperbahnause/07fc91a8c276e7479c270b8353eb45d9#file-openapi-generator-php-client-multipart-json
Command line used for generation
java -jar openapi-generator-cli-4.2.3.jar generate -i apitestminimal.json -g php -o apitestdir
Steps to reproduce
Generate the php client api send a request and check the request on the server side. It wont be a multipart/form-data request.
Related issues/PRs
#3750
Suggest a fix
If the parameter is not a file, it might still be a multipart-form-data message, but it's not set to true?
I think, this is the spot to look at:
openapi-generator/modules/openapi-generator/src/main/resources/php/api.mustache
Lines 533 to 541 in 3588990
The text was updated successfully, but these errors were encountered: