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.
This commit is contained in:
Simon Podlipsky
2024-02-12 08:47:27 +01:00
committed by GitHub
parent 5535578036
commit cd23dfd3ce
8 changed files with 235 additions and 470 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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