[BUG] PHP client is not sending multipart request unless a file is part of the schema
Created by: reeperbahnause
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix
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 type string
and format binary
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
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
https://github.com/OpenAPITools/openapi-generator/pull/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: https://github.com/OpenAPITools/openapi-generator/blob/3588990a4f9f7e7d3e3ae8e2dda59206f57bf676/modules/openapi-generator/src/main/resources/php/api.mustache#L533-L541