From cd23dfd3ce701e4d892e1be88a22699235e2ebf9 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 12 Feb 2024 08:47:27 +0100 Subject: [PATCH] fix(php): call selectHeaders correctly in psr-18 implementation (#17832) - `selectHeadersForMultipart()` does not exist, - therefore we have to call `selectHeaders()` This is signature of `public function selectHeaders(array $accept, string $contentType, bool $isMultipart): array;` We have to pass `$multipart` as 3rd parameter. The second parameter is content type as string, not in array. --- .../php/libraries/psr-18/api.mustache | 15 +- .../php/psr-18/lib/Api/AnotherFakeApi.php | 15 +- .../php/psr-18/lib/Api/DefaultApi.php | 15 +- .../petstore/php/psr-18/lib/Api/FakeApi.php | 330 ++++++------------ .../lib/Api/FakeClassnameTags123Api.php | 15 +- .../petstore/php/psr-18/lib/Api/PetApi.php | 135 +++---- .../petstore/php/psr-18/lib/Api/StoreApi.php | 60 ++-- .../petstore/php/psr-18/lib/Api/UserApi.php | 120 +++---- 8 files changed, 235 insertions(+), 470 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache b/modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache index 57f852ee12c1..16c6a900bb5c 100644 --- a/modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache @@ -605,16 +605,11 @@ use function sprintf; } {{/formParams}} - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}], - [{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}] - ); - } + $headers = $this->headerSelector->selectHeaders( + [{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}], + '{{#consumes}}{{{mediaType}}}{{/consumes}}', + $multipart + ); // for model (json/xml) {{#bodyParams}} diff --git a/samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php index 729c91d53bce..4fad7cfccc03 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php @@ -369,16 +369,11 @@ class AnotherFakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($client)) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php b/samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php index 6ef6284d5c47..c08955c73fc2 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php @@ -350,16 +350,11 @@ class DefaultApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/FakeApi.php b/samples/client/petstore/php/psr-18/lib/Api/FakeApi.php index 0abdffefa42a..587ffa987b91 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/FakeApi.php @@ -350,16 +350,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -590,16 +585,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -821,16 +811,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/jsonapplication/xml', + $multipart + ); // for model (json/xml) if (isset($pet)) { @@ -1064,16 +1049,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($body)) { @@ -1307,16 +1287,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($outer_composite)) { @@ -1550,16 +1525,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($body)) { @@ -1793,16 +1763,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($body)) { @@ -2042,16 +2007,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($outer_object_with_enum_property)) { @@ -2332,16 +2292,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2538,16 +2493,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($request_body)) { @@ -2742,16 +2692,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['image/png'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'image/png', + $multipart + ); // for model (json/xml) if (isset($body)) { @@ -2946,16 +2891,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($file_schema_test_class)) { @@ -3172,16 +3112,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($user)) { @@ -3429,16 +3364,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($client)) { @@ -3835,16 +3765,11 @@ class FakeApi $formParams['callback'] = ObjectSerializer::toFormValue($callback); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/x-www-form-urlencoded'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/x-www-form-urlencoded', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4153,16 +4078,11 @@ class FakeApi $formParams['enum_form_string'] = ObjectSerializer::toFormValue($enum_form_string); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/x-www-form-urlencoded'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/x-www-form-urlencoded', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4466,16 +4386,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4676,16 +4591,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($request_body)) { @@ -4888,16 +4798,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($test_inline_freeform_additional_properties_request)) { @@ -5119,16 +5024,11 @@ class FakeApi $formParams['param2'] = ObjectSerializer::toFormValue($param2); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/x-www-form-urlencoded'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/x-www-form-urlencoded', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -5438,16 +5338,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -5644,16 +5539,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($request_body)) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/psr-18/lib/Api/FakeClassnameTags123Api.php index 50fb8f4c42bd..128a9cc0d19f 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/psr-18/lib/Api/FakeClassnameTags123Api.php @@ -369,16 +369,11 @@ class FakeClassnameTags123Api - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($client)) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/PetApi.php b/samples/client/petstore/php/psr-18/lib/Api/PetApi.php index 5f68de5ee1ae..f984e0de3362 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/PetApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/PetApi.php @@ -349,16 +349,11 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/jsonapplication/xml', + $multipart + ); // for model (json/xml) if (isset($pet)) { @@ -586,16 +581,11 @@ class PetApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -848,16 +838,11 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1111,16 +1096,11 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1374,16 +1354,11 @@ class PetApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1610,16 +1585,11 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/jsonapplication/xml', + $multipart + ); // for model (json/xml) if (isset($pet)) { @@ -1856,16 +1826,11 @@ class PetApi $formParams['status'] = ObjectSerializer::toFormValue($status); } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/x-www-form-urlencoded'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/x-www-form-urlencoded', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2145,16 +2110,11 @@ class PetApi } } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + 'multipart/form-data', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2440,16 +2400,11 @@ class PetApi } } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - ['multipart/form-data'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + 'multipart/form-data', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/StoreApi.php b/samples/client/petstore/php/psr-18/lib/Api/StoreApi.php index c64a258b301a..612ac56bdd06 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/StoreApi.php @@ -332,16 +332,11 @@ class StoreApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -572,16 +567,11 @@ class StoreApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -843,16 +833,11 @@ class StoreApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1094,16 +1079,11 @@ class StoreApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($order)) { diff --git a/samples/client/petstore/php/psr-18/lib/Api/UserApi.php b/samples/client/petstore/php/psr-18/lib/Api/UserApi.php index 62e8746d2a3a..529a85bea1c0 100644 --- a/samples/client/petstore/php/psr-18/lib/Api/UserApi.php +++ b/samples/client/petstore/php/psr-18/lib/Api/UserApi.php @@ -324,16 +324,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($user)) { @@ -536,16 +531,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($user)) { @@ -748,16 +738,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($user)) { @@ -968,16 +953,11 @@ class UserApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1227,16 +1207,11 @@ class UserApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1511,16 +1486,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/xml', 'application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1706,16 +1676,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + '', + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1931,16 +1896,11 @@ class UserApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + 'application/json', + $multipart + ); // for model (json/xml) if (isset($user)) {