diff --git a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache index 5d62a7b5b9d..75e86d3a00a 100644 --- a/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache +++ b/modules/openapi-generator/src/main/resources/php/HeaderSelector.mustache @@ -1,6 +1,6 @@ selectContentTypeHeader($contentTypes); - return $headers; - } - - /** - * @param string[] $accept - * @return array - */ - public function selectHeadersForMultipart($accept) - { - $headers = $this->selectHeaders($accept, []); - - unset($headers['Content-Type']); return $headers; } @@ -77,22 +69,4 @@ class HeaderSelector return implode(',', $accept); } } - - /** - * Return the content type based on an array of content-type provided - * - * @param string[] $contentType Array fo content-type - * - * @return string Content-Type (e.g. application/json) - */ - private function selectContentTypeHeader($contentType) - { - if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { - return 'application/json'; - } elseif (preg_grep("/application\/json/i", $contentType)) { - return 'application/json'; - } else { - return implode(',', $contentType); - } - } } diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 35955992f4f..a9893bf9e3f 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -60,7 +60,16 @@ use {{invokerPackage}}\ObjectSerializer; */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [{{#operation}} + '{{{operationId}}}' => [{{#consumes}} + '{{{mediaType}}}',{{/consumes}} + {{^consumes}} + 'application/json', +{{/consumes}} ],{{/operation}} + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -151,6 +160,7 @@ use {{invokerPackage}}\ObjectSerializer; * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. {{/-first}} {{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * * @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -159,9 +169,9 @@ use {{invokerPackage}}\ObjectSerializer; * @deprecated {{/isDeprecated}} */ - public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} + {{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}} return $response;{{/returnType}} } @@ -209,6 +219,7 @@ use {{invokerPackage}}\ObjectSerializer; * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. {{/-first}} {{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * * @throws \{{invokerPackage}}\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -217,9 +228,9 @@ use {{invokerPackage}}\ObjectSerializer; * @deprecated {{/isDeprecated}} */ - public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); try { $options = $this->createHttpClientOption(); @@ -367,6 +378,7 @@ use {{invokerPackage}}\ObjectSerializer; * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. {{/-first}} {{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -374,9 +386,9 @@ use {{invokerPackage}}\ObjectSerializer; * @deprecated {{/isDeprecated}} */ - public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { - return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) ->then( function ($response) { return $response[0]; @@ -428,6 +440,7 @@ use {{invokerPackage}}\ObjectSerializer; * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. {{/-first}} {{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -435,10 +448,10 @@ use {{invokerPackage}}\ObjectSerializer; * @deprecated {{/isDeprecated}} */ - public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { $returnType = '{{{returnType}}}'; - $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); + $request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -517,6 +530,7 @@ use {{invokerPackage}}\ObjectSerializer; * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. {{/-first}} {{/servers}} + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['{{{operationId}}}'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request @@ -524,7 +538,7 @@ use {{invokerPackage}}\ObjectSerializer; * @deprecated {{/isDeprecated}} */ - public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}?int $hostIndex = null, array $variables = []{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) + public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}}) { {{#vendorExtensions.x-group-parameters}} // unbox the parameters from the associative array @@ -533,7 +547,9 @@ use {{invokerPackage}}\ObjectSerializer; {{/allParams}}{{#servers.0}} $hostIndex = $associative_array['hostIndex']; $variables = array_key_exists('variables', $associative_array) ? $associative_array['variables'] : []; -{{/servers.0}}{{/vendorExtensions.x-group-parameters}}{{#allParams}} +{{/servers.0}} + $contentType = $associative_array['contentType'] ?? self::contentTypes['{{{operationId}}}'][0]; + {{/vendorExtensions.x-group-parameters}}{{#allParams}} {{#required}} // verify the required parameter '{{paramName}}' is set if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) { @@ -578,9 +594,7 @@ use {{invokerPackage}}\ObjectSerializer; throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.'); } {{/minItems}} - - {{/hasValidation}} - {{/allParams}} + {{/hasValidation}}{{/allParams}} $resourcePath = '{{{path}}}'; $formParams = []; @@ -649,21 +663,17 @@ use {{invokerPackage}}\ObjectSerializer; } {{/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}}}', {{/produces}}], + $contentType, + $multipart + ); // for model (json/xml) {{#bodyParams}} if (isset(${{paramName}})) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); } else { $httpBody = ${{paramName}}; @@ -687,9 +697,9 @@ use {{invokerPackage}}\ObjectSerializer; // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php index 914233b96fa..3fce701c54e 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -69,7 +69,14 @@ class AnotherFakeApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'call123TestSpecialTags' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -121,14 +128,15 @@ class AnotherFakeApi * To test special tags * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ - public function call123TestSpecialTags($client) + public function call123TestSpecialTags($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) { - list($response) = $this->call123TestSpecialTagsWithHttpInfo($client); + list($response) = $this->call123TestSpecialTagsWithHttpInfo($client, $contentType); return $response; } @@ -138,14 +146,15 @@ class AnotherFakeApi * To test special tags * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ - public function call123TestSpecialTagsWithHttpInfo($client) + public function call123TestSpecialTagsWithHttpInfo($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) { - $request = $this->call123TestSpecialTagsRequest($client); + $request = $this->call123TestSpecialTagsRequest($client, $contentType); try { $options = $this->createHttpClientOption(); @@ -237,13 +246,14 @@ class AnotherFakeApi * To test special tags * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function call123TestSpecialTagsAsync($client) + public function call123TestSpecialTagsAsync($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) { - return $this->call123TestSpecialTagsAsyncWithHttpInfo($client) + return $this->call123TestSpecialTagsAsyncWithHttpInfo($client, $contentType) ->then( function ($response) { return $response[0]; @@ -257,14 +267,15 @@ class AnotherFakeApi * To test special tags * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function call123TestSpecialTagsAsyncWithHttpInfo($client) + public function call123TestSpecialTagsAsyncWithHttpInfo($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) { $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->call123TestSpecialTagsRequest($client); + $request = $this->call123TestSpecialTagsRequest($client, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -306,11 +317,12 @@ class AnotherFakeApi * Create request for operation 'call123TestSpecialTags' * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function call123TestSpecialTagsRequest($client) + public function call123TestSpecialTagsRequest($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) { // verify the required parameter 'client' is set @@ -320,6 +332,7 @@ class AnotherFakeApi ); } + $resourcePath = '/another-fake/dummy'; $formParams = []; $queryParams = []; @@ -331,20 +344,16 @@ 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', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($client)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client)); } else { $httpBody = $client; @@ -364,9 +373,9 @@ class AnotherFakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php index c4434410584..621e0fd0ff9 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -69,7 +69,14 @@ class DefaultApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'fooGet' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -118,28 +125,30 @@ class DefaultApi /** * Operation fooGet * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\FooGetDefaultResponse */ - public function fooGet() + public function fooGet(string $contentType = self::contentTypes['fooGet'][0]) { - list($response) = $this->fooGetWithHttpInfo(); + list($response) = $this->fooGetWithHttpInfo($contentType); return $response; } /** * Operation fooGetWithHttpInfo * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\FooGetDefaultResponse, HTTP status code, HTTP response headers (array of strings) */ - public function fooGetWithHttpInfo() + public function fooGetWithHttpInfo(string $contentType = self::contentTypes['fooGet'][0]) { - $request = $this->fooGetRequest(); + $request = $this->fooGetRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -228,13 +237,14 @@ class DefaultApi /** * Operation fooGetAsync * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fooGetAsync() + public function fooGetAsync(string $contentType = self::contentTypes['fooGet'][0]) { - return $this->fooGetAsyncWithHttpInfo() + return $this->fooGetAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -245,14 +255,15 @@ class DefaultApi /** * Operation fooGetAsyncWithHttpInfo * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fooGetAsyncWithHttpInfo() + public function fooGetAsyncWithHttpInfo(string $contentType = self::contentTypes['fooGet'][0]) { $returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse'; - $request = $this->fooGetRequest(); + $request = $this->fooGetRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -293,13 +304,15 @@ class DefaultApi /** * Create request for operation 'fooGet' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fooGetRequest() + public function fooGetRequest(string $contentType = self::contentTypes['fooGet'][0]) { + $resourcePath = '/foo'; $formParams = []; $queryParams = []; @@ -311,16 +324,11 @@ class DefaultApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -338,9 +346,9 @@ class DefaultApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index deeb2678b56..418f6d4d4e2 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -69,7 +69,63 @@ class FakeApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'fakeHealthGet' => [ + 'application/json', + ], + 'fakeHttpSignatureTest' => [ + 'application/json', + 'application/xml', + ], + 'fakeOuterBooleanSerialize' => [ + 'application/json', + ], + 'fakeOuterCompositeSerialize' => [ + 'application/json', + ], + 'fakeOuterNumberSerialize' => [ + 'application/json', + ], + 'fakeOuterStringSerialize' => [ + 'application/json', + ], + 'fakePropertyEnumIntegerSerialize' => [ + 'application/json', + ], + 'testBodyWithBinary' => [ + 'image/png', + ], + 'testBodyWithFileSchema' => [ + 'application/json', + ], + 'testBodyWithQueryParams' => [ + 'application/json', + ], + 'testClientModel' => [ + 'application/json', + ], + 'testEndpointParameters' => [ + 'application/x-www-form-urlencoded', + ], + 'testEnumParameters' => [ + 'application/x-www-form-urlencoded', + ], + 'testGroupParameters' => [ + 'application/json', + ], + 'testInlineAdditionalProperties' => [ + 'application/json', + ], + 'testJsonFormData' => [ + 'application/x-www-form-urlencoded', + ], + 'testQueryParameterCollectionFormat' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -120,14 +176,15 @@ class FakeApi * * Health check endpoint * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\HealthCheckResult */ - public function fakeHealthGet() + public function fakeHealthGet(string $contentType = self::contentTypes['fakeHealthGet'][0]) { - list($response) = $this->fakeHealthGetWithHttpInfo(); + list($response) = $this->fakeHealthGetWithHttpInfo($contentType); return $response; } @@ -136,14 +193,15 @@ class FakeApi * * Health check endpoint * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\HealthCheckResult, HTTP status code, HTTP response headers (array of strings) */ - public function fakeHealthGetWithHttpInfo() + public function fakeHealthGetWithHttpInfo(string $contentType = self::contentTypes['fakeHealthGet'][0]) { - $request = $this->fakeHealthGetRequest(); + $request = $this->fakeHealthGetRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -234,13 +292,14 @@ class FakeApi * * Health check endpoint * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeHealthGetAsync() + public function fakeHealthGetAsync(string $contentType = self::contentTypes['fakeHealthGet'][0]) { - return $this->fakeHealthGetAsyncWithHttpInfo() + return $this->fakeHealthGetAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -253,14 +312,15 @@ class FakeApi * * Health check endpoint * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeHealthGetAsyncWithHttpInfo() + public function fakeHealthGetAsyncWithHttpInfo(string $contentType = self::contentTypes['fakeHealthGet'][0]) { $returnType = '\OpenAPI\Client\Model\HealthCheckResult'; - $request = $this->fakeHealthGetRequest(); + $request = $this->fakeHealthGetRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -301,13 +361,15 @@ class FakeApi /** * Create request for operation 'fakeHealthGet' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeHealthGetRequest() + public function fakeHealthGetRequest(string $contentType = self::contentTypes['fakeHealthGet'][0]) { + $resourcePath = '/fake/health'; $formParams = []; $queryParams = []; @@ -319,16 +381,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -346,9 +403,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -385,14 +442,15 @@ class FakeApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param string $query_1 query parameter (optional) * @param string $header_1 header parameter (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function fakeHttpSignatureTest($pet, $query_1 = null, $header_1 = null) + public function fakeHttpSignatureTest($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) { - $this->fakeHttpSignatureTestWithHttpInfo($pet, $query_1, $header_1); + $this->fakeHttpSignatureTestWithHttpInfo($pet, $query_1, $header_1, $contentType); } /** @@ -403,14 +461,15 @@ class FakeApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param string $query_1 query parameter (optional) * @param string $header_1 header parameter (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function fakeHttpSignatureTestWithHttpInfo($pet, $query_1 = null, $header_1 = null) + public function fakeHttpSignatureTestWithHttpInfo($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) { - $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1); + $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1, $contentType); try { $options = $this->createHttpClientOption(); @@ -464,13 +523,14 @@ class FakeApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param string $query_1 query parameter (optional) * @param string $header_1 header parameter (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeHttpSignatureTestAsync($pet, $query_1 = null, $header_1 = null) + public function fakeHttpSignatureTestAsync($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) { - return $this->fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1, $header_1) + return $this->fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1, $header_1, $contentType) ->then( function ($response) { return $response[0]; @@ -486,14 +546,15 @@ class FakeApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param string $query_1 query parameter (optional) * @param string $header_1 header parameter (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1 = null, $header_1 = null) + public function fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) { $returnType = ''; - $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1); + $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -524,11 +585,12 @@ class FakeApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param string $query_1 query parameter (optional) * @param string $header_1 header parameter (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = null) + public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) { // verify the required parameter 'pet' is set @@ -540,6 +602,7 @@ class FakeApi + $resourcePath = '/fake/http-signature-test'; $formParams = []; $queryParams = []; @@ -564,20 +627,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($pet)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($pet)); } else { $httpBody = $pet; @@ -597,9 +656,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -632,14 +691,15 @@ class FakeApi * Operation fakeOuterBooleanSerialize * * @param bool $body Input boolean as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return bool */ - public function fakeOuterBooleanSerialize($body = null) + public function fakeOuterBooleanSerialize($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) { - list($response) = $this->fakeOuterBooleanSerializeWithHttpInfo($body); + list($response) = $this->fakeOuterBooleanSerializeWithHttpInfo($body, $contentType); return $response; } @@ -647,14 +707,15 @@ class FakeApi * Operation fakeOuterBooleanSerializeWithHttpInfo * * @param bool $body Input boolean as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of bool, HTTP status code, HTTP response headers (array of strings) */ - public function fakeOuterBooleanSerializeWithHttpInfo($body = null) + public function fakeOuterBooleanSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) { - $request = $this->fakeOuterBooleanSerializeRequest($body); + $request = $this->fakeOuterBooleanSerializeRequest($body, $contentType); try { $options = $this->createHttpClientOption(); @@ -744,13 +805,14 @@ class FakeApi * Operation fakeOuterBooleanSerializeAsync * * @param bool $body Input boolean as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterBooleanSerializeAsync($body = null) + public function fakeOuterBooleanSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) { - return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body) + return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body, $contentType) ->then( function ($response) { return $response[0]; @@ -762,14 +824,15 @@ class FakeApi * Operation fakeOuterBooleanSerializeAsyncWithHttpInfo * * @param bool $body Input boolean as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null) + public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) { $returnType = 'bool'; - $request = $this->fakeOuterBooleanSerializeRequest($body); + $request = $this->fakeOuterBooleanSerializeRequest($body, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -811,14 +874,16 @@ class FakeApi * Create request for operation 'fakeOuterBooleanSerialize' * * @param bool $body Input boolean as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeOuterBooleanSerializeRequest($body = null) + public function fakeOuterBooleanSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) { + $resourcePath = '/fake/outer/boolean'; $formParams = []; $queryParams = []; @@ -830,20 +895,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($body)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body)); } else { $httpBody = $body; @@ -863,9 +924,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -898,14 +959,15 @@ class FakeApi * Operation fakeOuterCompositeSerialize * * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\OuterComposite */ - public function fakeOuterCompositeSerialize($outer_composite = null) + public function fakeOuterCompositeSerialize($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) { - list($response) = $this->fakeOuterCompositeSerializeWithHttpInfo($outer_composite); + list($response) = $this->fakeOuterCompositeSerializeWithHttpInfo($outer_composite, $contentType); return $response; } @@ -913,14 +975,15 @@ class FakeApi * Operation fakeOuterCompositeSerializeWithHttpInfo * * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings) */ - public function fakeOuterCompositeSerializeWithHttpInfo($outer_composite = null) + public function fakeOuterCompositeSerializeWithHttpInfo($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) { - $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite, $contentType); try { $options = $this->createHttpClientOption(); @@ -1010,13 +1073,14 @@ class FakeApi * Operation fakeOuterCompositeSerializeAsync * * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterCompositeSerializeAsync($outer_composite = null) + public function fakeOuterCompositeSerializeAsync($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) { - return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite) + return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite, $contentType) ->then( function ($response) { return $response[0]; @@ -1028,14 +1092,15 @@ class FakeApi * Operation fakeOuterCompositeSerializeAsyncWithHttpInfo * * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite = null) + public function fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) { $returnType = '\OpenAPI\Client\Model\OuterComposite'; - $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1077,14 +1142,16 @@ class FakeApi * Create request for operation 'fakeOuterCompositeSerialize' * * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeOuterCompositeSerializeRequest($outer_composite = null) + public function fakeOuterCompositeSerializeRequest($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) { + $resourcePath = '/fake/outer/composite'; $formParams = []; $queryParams = []; @@ -1096,20 +1163,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($outer_composite)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($outer_composite)); } else { $httpBody = $outer_composite; @@ -1129,9 +1192,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1164,14 +1227,15 @@ class FakeApi * Operation fakeOuterNumberSerialize * * @param float $body Input number as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return float */ - public function fakeOuterNumberSerialize($body = null) + public function fakeOuterNumberSerialize($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) { - list($response) = $this->fakeOuterNumberSerializeWithHttpInfo($body); + list($response) = $this->fakeOuterNumberSerializeWithHttpInfo($body, $contentType); return $response; } @@ -1179,14 +1243,15 @@ class FakeApi * Operation fakeOuterNumberSerializeWithHttpInfo * * @param float $body Input number as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of float, HTTP status code, HTTP response headers (array of strings) */ - public function fakeOuterNumberSerializeWithHttpInfo($body = null) + public function fakeOuterNumberSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) { - $request = $this->fakeOuterNumberSerializeRequest($body); + $request = $this->fakeOuterNumberSerializeRequest($body, $contentType); try { $options = $this->createHttpClientOption(); @@ -1276,13 +1341,14 @@ class FakeApi * Operation fakeOuterNumberSerializeAsync * * @param float $body Input number as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterNumberSerializeAsync($body = null) + public function fakeOuterNumberSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) { - return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body) + return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body, $contentType) ->then( function ($response) { return $response[0]; @@ -1294,14 +1360,15 @@ class FakeApi * Operation fakeOuterNumberSerializeAsyncWithHttpInfo * * @param float $body Input number as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null) + public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) { $returnType = 'float'; - $request = $this->fakeOuterNumberSerializeRequest($body); + $request = $this->fakeOuterNumberSerializeRequest($body, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1343,14 +1410,16 @@ class FakeApi * Create request for operation 'fakeOuterNumberSerialize' * * @param float $body Input number as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeOuterNumberSerializeRequest($body = null) + public function fakeOuterNumberSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) { + $resourcePath = '/fake/outer/number'; $formParams = []; $queryParams = []; @@ -1362,20 +1431,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($body)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body)); } else { $httpBody = $body; @@ -1395,9 +1460,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1430,14 +1495,15 @@ class FakeApi * Operation fakeOuterStringSerialize * * @param string $body Input string as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return string */ - public function fakeOuterStringSerialize($body = null) + public function fakeOuterStringSerialize($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) { - list($response) = $this->fakeOuterStringSerializeWithHttpInfo($body); + list($response) = $this->fakeOuterStringSerializeWithHttpInfo($body, $contentType); return $response; } @@ -1445,14 +1511,15 @@ class FakeApi * Operation fakeOuterStringSerializeWithHttpInfo * * @param string $body Input string as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ - public function fakeOuterStringSerializeWithHttpInfo($body = null) + public function fakeOuterStringSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) { - $request = $this->fakeOuterStringSerializeRequest($body); + $request = $this->fakeOuterStringSerializeRequest($body, $contentType); try { $options = $this->createHttpClientOption(); @@ -1542,13 +1609,14 @@ class FakeApi * Operation fakeOuterStringSerializeAsync * * @param string $body Input string as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterStringSerializeAsync($body = null) + public function fakeOuterStringSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) { - return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body) + return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body, $contentType) ->then( function ($response) { return $response[0]; @@ -1560,14 +1628,15 @@ class FakeApi * Operation fakeOuterStringSerializeAsyncWithHttpInfo * * @param string $body Input string as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null) + public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) { $returnType = 'string'; - $request = $this->fakeOuterStringSerializeRequest($body); + $request = $this->fakeOuterStringSerializeRequest($body, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1609,14 +1678,16 @@ class FakeApi * Create request for operation 'fakeOuterStringSerialize' * * @param string $body Input string as post body (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakeOuterStringSerializeRequest($body = null) + public function fakeOuterStringSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) { + $resourcePath = '/fake/outer/string'; $formParams = []; $queryParams = []; @@ -1628,20 +1699,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($body)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body)); } else { $httpBody = $body; @@ -1661,9 +1728,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1696,14 +1763,15 @@ class FakeApi * Operation fakePropertyEnumIntegerSerialize * * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\OuterObjectWithEnumProperty */ - public function fakePropertyEnumIntegerSerialize($outer_object_with_enum_property) + public function fakePropertyEnumIntegerSerialize($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) { - list($response) = $this->fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property); + list($response) = $this->fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property, $contentType); return $response; } @@ -1711,14 +1779,15 @@ class FakeApi * Operation fakePropertyEnumIntegerSerializeWithHttpInfo * * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\OuterObjectWithEnumProperty, HTTP status code, HTTP response headers (array of strings) */ - public function fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property) + public function fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) { - $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property); + $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, $contentType); try { $options = $this->createHttpClientOption(); @@ -1808,13 +1877,14 @@ class FakeApi * Operation fakePropertyEnumIntegerSerializeAsync * * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakePropertyEnumIntegerSerializeAsync($outer_object_with_enum_property) + public function fakePropertyEnumIntegerSerializeAsync($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) { - return $this->fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property) + return $this->fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property, $contentType) ->then( function ($response) { return $response[0]; @@ -1826,14 +1896,15 @@ class FakeApi * Operation fakePropertyEnumIntegerSerializeAsyncWithHttpInfo * * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property) + public function fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) { $returnType = '\OpenAPI\Client\Model\OuterObjectWithEnumProperty'; - $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property); + $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1875,11 +1946,12 @@ class FakeApi * Create request for operation 'fakePropertyEnumIntegerSerialize' * * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property) + public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) { // verify the required parameter 'outer_object_with_enum_property' is set @@ -1889,6 +1961,7 @@ class FakeApi ); } + $resourcePath = '/fake/property/enum-int'; $formParams = []; $queryParams = []; @@ -1900,20 +1973,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['*/*'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['*/*'], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['*/*', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($outer_object_with_enum_property)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property)); } else { $httpBody = $outer_object_with_enum_property; @@ -1933,9 +2002,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1968,28 +2037,30 @@ class FakeApi * Operation testBodyWithBinary * * @param \SplFileObject $body image to upload (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testBodyWithBinary($body) + public function testBodyWithBinary($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) { - $this->testBodyWithBinaryWithHttpInfo($body); + $this->testBodyWithBinaryWithHttpInfo($body, $contentType); } /** * Operation testBodyWithBinaryWithHttpInfo * * @param \SplFileObject $body image to upload (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testBodyWithBinaryWithHttpInfo($body) + public function testBodyWithBinaryWithHttpInfo($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) { - $request = $this->testBodyWithBinaryRequest($body); + $request = $this->testBodyWithBinaryRequest($body, $contentType); try { $options = $this->createHttpClientOption(); @@ -2039,13 +2110,14 @@ class FakeApi * Operation testBodyWithBinaryAsync * * @param \SplFileObject $body image to upload (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithBinaryAsync($body) + public function testBodyWithBinaryAsync($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) { - return $this->testBodyWithBinaryAsyncWithHttpInfo($body) + return $this->testBodyWithBinaryAsyncWithHttpInfo($body, $contentType) ->then( function ($response) { return $response[0]; @@ -2057,14 +2129,15 @@ class FakeApi * Operation testBodyWithBinaryAsyncWithHttpInfo * * @param \SplFileObject $body image to upload (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithBinaryAsyncWithHttpInfo($body) + public function testBodyWithBinaryAsyncWithHttpInfo($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) { $returnType = ''; - $request = $this->testBodyWithBinaryRequest($body); + $request = $this->testBodyWithBinaryRequest($body, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2093,11 +2166,12 @@ class FakeApi * Create request for operation 'testBodyWithBinary' * * @param \SplFileObject $body image to upload (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testBodyWithBinaryRequest($body) + public function testBodyWithBinaryRequest($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) { // verify the required parameter 'body' is set @@ -2107,6 +2181,7 @@ class FakeApi ); } + $resourcePath = '/fake/body-with-binary'; $formParams = []; $queryParams = []; @@ -2118,20 +2193,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['image/png'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($body)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($body)); } else { $httpBody = $body; @@ -2151,9 +2222,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2186,28 +2257,30 @@ class FakeApi * Operation testBodyWithFileSchema * * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class file_schema_test_class (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testBodyWithFileSchema($file_schema_test_class) + public function testBodyWithFileSchema($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) { - $this->testBodyWithFileSchemaWithHttpInfo($file_schema_test_class); + $this->testBodyWithFileSchemaWithHttpInfo($file_schema_test_class, $contentType); } /** * Operation testBodyWithFileSchemaWithHttpInfo * * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testBodyWithFileSchemaWithHttpInfo($file_schema_test_class) + public function testBodyWithFileSchemaWithHttpInfo($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) { - $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class); + $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class, $contentType); try { $options = $this->createHttpClientOption(); @@ -2257,13 +2330,14 @@ class FakeApi * Operation testBodyWithFileSchemaAsync * * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithFileSchemaAsync($file_schema_test_class) + public function testBodyWithFileSchemaAsync($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) { - return $this->testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class) + return $this->testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class, $contentType) ->then( function ($response) { return $response[0]; @@ -2275,14 +2349,15 @@ class FakeApi * Operation testBodyWithFileSchemaAsyncWithHttpInfo * * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class) + public function testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) { $returnType = ''; - $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class); + $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2311,11 +2386,12 @@ class FakeApi * Create request for operation 'testBodyWithFileSchema' * * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testBodyWithFileSchemaRequest($file_schema_test_class) + public function testBodyWithFileSchemaRequest($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) { // verify the required parameter 'file_schema_test_class' is set @@ -2325,6 +2401,7 @@ class FakeApi ); } + $resourcePath = '/fake/body-with-file-schema'; $formParams = []; $queryParams = []; @@ -2336,20 +2413,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($file_schema_test_class)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class)); } else { $httpBody = $file_schema_test_class; @@ -2369,9 +2442,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2405,14 +2478,15 @@ class FakeApi * * @param string $query query (required) * @param \OpenAPI\Client\Model\User $user user (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testBodyWithQueryParams($query, $user) + public function testBodyWithQueryParams($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) { - $this->testBodyWithQueryParamsWithHttpInfo($query, $user); + $this->testBodyWithQueryParamsWithHttpInfo($query, $user, $contentType); } /** @@ -2420,14 +2494,15 @@ class FakeApi * * @param string $query (required) * @param \OpenAPI\Client\Model\User $user (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testBodyWithQueryParamsWithHttpInfo($query, $user) + public function testBodyWithQueryParamsWithHttpInfo($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) { - $request = $this->testBodyWithQueryParamsRequest($query, $user); + $request = $this->testBodyWithQueryParamsRequest($query, $user, $contentType); try { $options = $this->createHttpClientOption(); @@ -2478,13 +2553,14 @@ class FakeApi * * @param string $query (required) * @param \OpenAPI\Client\Model\User $user (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithQueryParamsAsync($query, $user) + public function testBodyWithQueryParamsAsync($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) { - return $this->testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + return $this->testBodyWithQueryParamsAsyncWithHttpInfo($query, $user, $contentType) ->then( function ($response) { return $response[0]; @@ -2497,14 +2573,15 @@ class FakeApi * * @param string $query (required) * @param \OpenAPI\Client\Model\User $user (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + public function testBodyWithQueryParamsAsyncWithHttpInfo($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) { $returnType = ''; - $request = $this->testBodyWithQueryParamsRequest($query, $user); + $request = $this->testBodyWithQueryParamsRequest($query, $user, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2534,11 +2611,12 @@ class FakeApi * * @param string $query (required) * @param \OpenAPI\Client\Model\User $user (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testBodyWithQueryParamsRequest($query, $user) + public function testBodyWithQueryParamsRequest($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) { // verify the required parameter 'query' is set @@ -2555,6 +2633,7 @@ class FakeApi ); } + $resourcePath = '/fake/body-with-query-params'; $formParams = []; $queryParams = []; @@ -2575,20 +2654,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($user)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user)); } else { $httpBody = $user; @@ -2608,9 +2683,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2645,14 +2720,15 @@ class FakeApi * To test \"client\" model * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ - public function testClientModel($client) + public function testClientModel($client, string $contentType = self::contentTypes['testClientModel'][0]) { - list($response) = $this->testClientModelWithHttpInfo($client); + list($response) = $this->testClientModelWithHttpInfo($client, $contentType); return $response; } @@ -2662,14 +2738,15 @@ class FakeApi * To test \"client\" model * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ - public function testClientModelWithHttpInfo($client) + public function testClientModelWithHttpInfo($client, string $contentType = self::contentTypes['testClientModel'][0]) { - $request = $this->testClientModelRequest($client); + $request = $this->testClientModelRequest($client, $contentType); try { $options = $this->createHttpClientOption(); @@ -2761,13 +2838,14 @@ class FakeApi * To test \"client\" model * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testClientModelAsync($client) + public function testClientModelAsync($client, string $contentType = self::contentTypes['testClientModel'][0]) { - return $this->testClientModelAsyncWithHttpInfo($client) + return $this->testClientModelAsyncWithHttpInfo($client, $contentType) ->then( function ($response) { return $response[0]; @@ -2781,14 +2859,15 @@ class FakeApi * To test \"client\" model * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testClientModelAsyncWithHttpInfo($client) + public function testClientModelAsyncWithHttpInfo($client, string $contentType = self::contentTypes['testClientModel'][0]) { $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->testClientModelRequest($client); + $request = $this->testClientModelRequest($client, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2830,11 +2909,12 @@ class FakeApi * Create request for operation 'testClientModel' * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testClientModelRequest($client) + public function testClientModelRequest($client, string $contentType = self::contentTypes['testClientModel'][0]) { // verify the required parameter 'client' is set @@ -2844,6 +2924,7 @@ class FakeApi ); } + $resourcePath = '/fake'; $formParams = []; $queryParams = []; @@ -2855,20 +2936,16 @@ 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', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($client)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client)); } else { $httpBody = $client; @@ -2888,9 +2965,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2938,14 +3015,15 @@ class FakeApi * @param \DateTime $date_time None (optional) * @param string $password None (optional) * @param string $callback None (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) + public function testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) { - $this->testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + $this->testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); } /** @@ -2967,14 +3045,15 @@ class FakeApi * @param \DateTime $date_time None (optional) * @param string $password None (optional) * @param string $callback None (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) + public function testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) { - $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); try { $options = $this->createHttpClientOption(); @@ -3039,13 +3118,14 @@ class FakeApi * @param \DateTime $date_time None (optional) * @param string $password None (optional) * @param string $callback None (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testEndpointParametersAsync($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) + public function testEndpointParametersAsync($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) { - return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType) ->then( function ($response) { return $response[0]; @@ -3072,14 +3152,15 @@ class FakeApi * @param \DateTime $date_time None (optional) * @param string $password None (optional) * @param string $callback None (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) + public function testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) { $returnType = ''; - $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -3121,11 +3202,12 @@ class FakeApi * @param \DateTime $date_time None (optional) * @param string $password None (optional) * @param string $callback None (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null) + public function testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) { // verify the required parameter 'number' is set @@ -3140,8 +3222,7 @@ class FakeApi if ($number < 32.1) { throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); } - - + // verify the required parameter 'double' is set if ($double === null || (is_array($double) && count($double) === 0)) { throw new \InvalidArgumentException( @@ -3154,8 +3235,7 @@ class FakeApi if ($double < 67.8) { throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); } - - + // verify the required parameter 'pattern_without_delimiter' is set if ($pattern_without_delimiter === null || (is_array($pattern_without_delimiter) && count($pattern_without_delimiter) === 0)) { throw new \InvalidArgumentException( @@ -3165,8 +3245,7 @@ class FakeApi if (!preg_match("/^[A-Z].*/", $pattern_without_delimiter)) { throw new \InvalidArgumentException("invalid value for \"pattern_without_delimiter\" when calling FakeApi.testEndpointParameters, must conform to the pattern /^[A-Z].*/."); } - - + // verify the required parameter 'byte' is set if ($byte === null || (is_array($byte) && count($byte) === 0)) { throw new \InvalidArgumentException( @@ -3180,27 +3259,23 @@ class FakeApi if ($integer !== null && $integer < 10) { throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); } - - + if ($int32 !== null && $int32 > 200) { throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.'); } if ($int32 !== null && $int32 < 20) { throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.'); } - - + if ($float !== null && $float > 987.6) { throw new \InvalidArgumentException('invalid value for "$float" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); } - - + if ($string !== null && !preg_match("/[a-z]/i", $string)) { throw new \InvalidArgumentException("invalid value for \"string\" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i."); } - - + @@ -3210,7 +3285,7 @@ class FakeApi if ($password !== null && strlen($password) < 10) { throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); } - + $resourcePath = '/fake'; @@ -3288,16 +3363,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( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -3315,9 +3385,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3364,14 +3434,15 @@ class FakeApi * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array enum_query_model_array (optional) * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testEnumParameters($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg') + public function testEnumParameters($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) { - $this->testEnumParametersWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string); + $this->testEnumParametersWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); } /** @@ -3388,14 +3459,15 @@ class FakeApi * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testEnumParametersWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg') + public function testEnumParametersWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) { - $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string); + $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); try { $options = $this->createHttpClientOption(); @@ -3455,13 +3527,14 @@ class FakeApi * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testEnumParametersAsync($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg') + public function testEnumParametersAsync($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) { - return $this->testEnumParametersAsyncWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string) + return $this->testEnumParametersAsyncWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType) ->then( function ($response) { return $response[0]; @@ -3483,14 +3556,15 @@ class FakeApi * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testEnumParametersAsyncWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg') + public function testEnumParametersAsyncWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) { $returnType = ''; - $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string); + $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -3527,11 +3601,12 @@ class FakeApi * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testEnumParametersRequest($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg') + public function testEnumParametersRequest($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) { @@ -3543,6 +3618,7 @@ class FakeApi + $resourcePath = '/fake'; $formParams = []; $queryParams = []; @@ -3618,16 +3694,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( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -3645,9 +3716,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3689,6 +3760,7 @@ class FakeApi * @param int $string_group String in group parameters (optional) * @param bool $boolean_group Boolean in group parameters (optional) * @param int $int64_group Integer in group parameters (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -3712,6 +3784,7 @@ class FakeApi * @param int $string_group String in group parameters (optional) * @param bool $boolean_group Boolean in group parameters (optional) * @param int $int64_group Integer in group parameters (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException @@ -3778,6 +3851,7 @@ class FakeApi * @param int $string_group String in group parameters (optional) * @param bool $boolean_group Boolean in group parameters (optional) * @param int $int64_group Integer in group parameters (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -3805,6 +3879,7 @@ class FakeApi * @param int $string_group String in group parameters (optional) * @param bool $boolean_group Boolean in group parameters (optional) * @param int $int64_group Integer in group parameters (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface @@ -3848,6 +3923,7 @@ class FakeApi * @param int $string_group String in group parameters (optional) * @param bool $boolean_group Boolean in group parameters (optional) * @param int $int64_group Integer in group parameters (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request @@ -3861,7 +3937,8 @@ class FakeApi $string_group = array_key_exists('string_group', $associative_array) ? $associative_array['string_group'] : null; $boolean_group = array_key_exists('boolean_group', $associative_array) ? $associative_array['boolean_group'] : null; $int64_group = array_key_exists('int64_group', $associative_array) ? $associative_array['int64_group'] : null; - + $contentType = $associative_array['contentType'] ?? self::contentTypes['testGroupParameters'][0]; + // verify the required parameter 'required_string_group' is set if ($required_string_group === null || (is_array($required_string_group) && count($required_string_group) === 0)) { throw new \InvalidArgumentException( @@ -3886,6 +3963,7 @@ class FakeApi + $resourcePath = '/fake'; $formParams = []; $queryParams = []; @@ -3941,16 +4019,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -3968,9 +4041,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4009,14 +4082,15 @@ class FakeApi * test inline additionalProperties * * @param array $request_body request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testInlineAdditionalProperties($request_body) + public function testInlineAdditionalProperties($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) { - $this->testInlineAdditionalPropertiesWithHttpInfo($request_body); + $this->testInlineAdditionalPropertiesWithHttpInfo($request_body, $contentType); } /** @@ -4025,14 +4099,15 @@ class FakeApi * test inline additionalProperties * * @param array $request_body request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testInlineAdditionalPropertiesWithHttpInfo($request_body) + public function testInlineAdditionalPropertiesWithHttpInfo($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) { - $request = $this->testInlineAdditionalPropertiesRequest($request_body); + $request = $this->testInlineAdditionalPropertiesRequest($request_body, $contentType); try { $options = $this->createHttpClientOption(); @@ -4084,13 +4159,14 @@ class FakeApi * test inline additionalProperties * * @param array $request_body request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testInlineAdditionalPropertiesAsync($request_body) + public function testInlineAdditionalPropertiesAsync($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) { - return $this->testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + return $this->testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body, $contentType) ->then( function ($response) { return $response[0]; @@ -4104,14 +4180,15 @@ class FakeApi * test inline additionalProperties * * @param array $request_body request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + public function testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) { $returnType = ''; - $request = $this->testInlineAdditionalPropertiesRequest($request_body); + $request = $this->testInlineAdditionalPropertiesRequest($request_body, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -4140,11 +4217,12 @@ class FakeApi * Create request for operation 'testInlineAdditionalProperties' * * @param array $request_body request body (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testInlineAdditionalPropertiesRequest($request_body) + public function testInlineAdditionalPropertiesRequest($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) { // verify the required parameter 'request_body' is set @@ -4154,6 +4232,7 @@ class FakeApi ); } + $resourcePath = '/fake/inline-additionalProperties'; $formParams = []; $queryParams = []; @@ -4165,20 +4244,16 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($request_body)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($request_body)); } else { $httpBody = $request_body; @@ -4198,9 +4273,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4236,14 +4311,15 @@ class FakeApi * * @param string $param field1 (required) * @param string $param2 field2 (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testJsonFormData($param, $param2) + public function testJsonFormData($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) { - $this->testJsonFormDataWithHttpInfo($param, $param2); + $this->testJsonFormDataWithHttpInfo($param, $param2, $contentType); } /** @@ -4253,14 +4329,15 @@ class FakeApi * * @param string $param field1 (required) * @param string $param2 field2 (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testJsonFormDataWithHttpInfo($param, $param2) + public function testJsonFormDataWithHttpInfo($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) { - $request = $this->testJsonFormDataRequest($param, $param2); + $request = $this->testJsonFormDataRequest($param, $param2, $contentType); try { $options = $this->createHttpClientOption(); @@ -4313,13 +4390,14 @@ class FakeApi * * @param string $param field1 (required) * @param string $param2 field2 (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testJsonFormDataAsync($param, $param2) + public function testJsonFormDataAsync($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) { - return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2) + return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2, $contentType) ->then( function ($response) { return $response[0]; @@ -4334,14 +4412,15 @@ class FakeApi * * @param string $param field1 (required) * @param string $param2 field2 (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testJsonFormDataAsyncWithHttpInfo($param, $param2) + public function testJsonFormDataAsyncWithHttpInfo($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) { $returnType = ''; - $request = $this->testJsonFormDataRequest($param, $param2); + $request = $this->testJsonFormDataRequest($param, $param2, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -4371,11 +4450,12 @@ class FakeApi * * @param string $param field1 (required) * @param string $param2 field2 (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testJsonFormDataRequest($param, $param2) + public function testJsonFormDataRequest($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) { // verify the required parameter 'param' is set @@ -4392,6 +4472,7 @@ class FakeApi ); } + $resourcePath = '/fake/jsonFormData'; $formParams = []; $queryParams = []; @@ -4411,16 +4492,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( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4438,9 +4514,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4479,14 +4555,15 @@ class FakeApi * @param string[] $context context (required) * @param string $allow_empty allow_empty (required) * @param array $language language (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testQueryParameterCollectionFormat($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null) + public function testQueryParameterCollectionFormat($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) { - $this->testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language); + $this->testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); } /** @@ -4499,14 +4576,15 @@ class FakeApi * @param string[] $context (required) * @param string $allow_empty (required) * @param array $language (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null) + public function testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) { - $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language); + $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); try { $options = $this->createHttpClientOption(); @@ -4562,13 +4640,14 @@ class FakeApi * @param string[] $context (required) * @param string $allow_empty (required) * @param array $language (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testQueryParameterCollectionFormatAsync($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null) + public function testQueryParameterCollectionFormatAsync($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) { - return $this->testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language) + return $this->testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType) ->then( function ($response) { return $response[0]; @@ -4586,14 +4665,15 @@ class FakeApi * @param string[] $context (required) * @param string $allow_empty (required) * @param array $language (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null) + public function testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) { $returnType = ''; - $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language); + $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -4628,11 +4708,12 @@ class FakeApi * @param string[] $context (required) * @param string $allow_empty (required) * @param array $language (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null) + public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) { // verify the required parameter 'pipe' is set @@ -4678,6 +4759,7 @@ class FakeApi } + $resourcePath = '/fake/test-query-parameters'; $formParams = []; $queryParams = []; @@ -4752,16 +4834,11 @@ class FakeApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -4779,9 +4856,9 @@ class FakeApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php index 0dcd17977ad..47e1247402a 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -69,7 +69,14 @@ class FakeClassnameTags123Api */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'testClassname' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -121,14 +128,15 @@ class FakeClassnameTags123Api * To test class name in snake case * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Client */ - public function testClassname($client) + public function testClassname($client, string $contentType = self::contentTypes['testClassname'][0]) { - list($response) = $this->testClassnameWithHttpInfo($client); + list($response) = $this->testClassnameWithHttpInfo($client, $contentType); return $response; } @@ -138,14 +146,15 @@ class FakeClassnameTags123Api * To test class name in snake case * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) */ - public function testClassnameWithHttpInfo($client) + public function testClassnameWithHttpInfo($client, string $contentType = self::contentTypes['testClassname'][0]) { - $request = $this->testClassnameRequest($client); + $request = $this->testClassnameRequest($client, $contentType); try { $options = $this->createHttpClientOption(); @@ -237,13 +246,14 @@ class FakeClassnameTags123Api * To test class name in snake case * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testClassnameAsync($client) + public function testClassnameAsync($client, string $contentType = self::contentTypes['testClassname'][0]) { - return $this->testClassnameAsyncWithHttpInfo($client) + return $this->testClassnameAsyncWithHttpInfo($client, $contentType) ->then( function ($response) { return $response[0]; @@ -257,14 +267,15 @@ class FakeClassnameTags123Api * To test class name in snake case * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testClassnameAsyncWithHttpInfo($client) + public function testClassnameAsyncWithHttpInfo($client, string $contentType = self::contentTypes['testClassname'][0]) { $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->testClassnameRequest($client); + $request = $this->testClassnameRequest($client, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -306,11 +317,12 @@ class FakeClassnameTags123Api * Create request for operation 'testClassname' * * @param \OpenAPI\Client\Model\Client $client client model (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function testClassnameRequest($client) + public function testClassnameRequest($client, string $contentType = self::contentTypes['testClassname'][0]) { // verify the required parameter 'client' is set @@ -320,6 +332,7 @@ class FakeClassnameTags123Api ); } + $resourcePath = '/fake_classname_test'; $formParams = []; $queryParams = []; @@ -331,20 +344,16 @@ 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', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($client)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($client)); } else { $httpBody = $client; @@ -364,9 +373,9 @@ class FakeClassnameTags123Api // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index bc00b5ed681..b818c0a819a 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -69,7 +69,40 @@ class PetApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'addPet' => [ + 'application/json', + 'application/xml', + ], + 'deletePet' => [ + 'application/json', + ], + 'findPetsByStatus' => [ + 'application/json', + ], + 'findPetsByTags' => [ + 'application/json', + ], + 'getPetById' => [ + 'application/json', + ], + 'updatePet' => [ + 'application/json', + 'application/xml', + ], + 'updatePetWithForm' => [ + 'application/x-www-form-urlencoded', + ], + 'uploadFile' => [ + 'multipart/form-data', + ], + 'uploadFileWithRequiredFile' => [ + 'multipart/form-data', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -139,14 +172,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function addPet($pet, ?int $hostIndex = null, array $variables = []) + public function addPet($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) { - $this->addPetWithHttpInfo($pet, $hostIndex, $variables); + $this->addPetWithHttpInfo($pet, $hostIndex, $variables, $contentType); } /** @@ -173,14 +207,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function addPetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = []) + public function addPetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) { - $request = $this->addPetRequest($pet, $hostIndex, $variables); + $request = $this->addPetRequest($pet, $hostIndex, $variables, $contentType); try { $options = $this->createHttpClientOption(); @@ -250,13 +285,14 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function addPetAsync($pet, ?int $hostIndex = null, array $variables = []) + public function addPetAsync($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) { - return $this->addPetAsyncWithHttpInfo($pet, $hostIndex, $variables) + return $this->addPetAsyncWithHttpInfo($pet, $hostIndex, $variables, $contentType) ->then( function ($response) { return $response[0]; @@ -288,14 +324,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function addPetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = []) + public function addPetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) { $returnType = ''; - $request = $this->addPetRequest($pet, $hostIndex, $variables); + $request = $this->addPetRequest($pet, $hostIndex, $variables, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -342,11 +379,12 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function addPetRequest($pet, ?int $hostIndex = null, array $variables = []) + public function addPetRequest($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) { // verify the required parameter 'pet' is set @@ -356,6 +394,7 @@ class PetApi ); } + $resourcePath = '/pet'; $formParams = []; $queryParams = []; @@ -367,20 +406,16 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($pet)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($pet)); } else { $httpBody = $pet; @@ -400,9 +435,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -494,14 +529,15 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key api_key (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function deletePet($pet_id, $api_key = null) + public function deletePet($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) { - $this->deletePetWithHttpInfo($pet_id, $api_key); + $this->deletePetWithHttpInfo($pet_id, $api_key, $contentType); } /** @@ -511,14 +547,15 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function deletePetWithHttpInfo($pet_id, $api_key = null) + public function deletePetWithHttpInfo($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) { - $request = $this->deletePetRequest($pet_id, $api_key); + $request = $this->deletePetRequest($pet_id, $api_key, $contentType); try { $options = $this->createHttpClientOption(); @@ -571,13 +608,14 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deletePetAsync($pet_id, $api_key = null) + public function deletePetAsync($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) { - return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key) + return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key, $contentType) ->then( function ($response) { return $response[0]; @@ -592,14 +630,15 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null) + public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) { $returnType = ''; - $request = $this->deletePetRequest($pet_id, $api_key); + $request = $this->deletePetRequest($pet_id, $api_key, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -629,11 +668,12 @@ class PetApi * * @param int $pet_id Pet id to delete (required) * @param string $api_key (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function deletePetRequest($pet_id, $api_key = null) + public function deletePetRequest($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) { // verify the required parameter 'pet_id' is set @@ -644,6 +684,7 @@ class PetApi } + $resourcePath = '/pet/{petId}'; $formParams = []; $queryParams = []; @@ -667,16 +708,11 @@ class PetApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -694,9 +730,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -735,14 +771,15 @@ class PetApi * Finds Pets by status * * @param string[] $status Status values that need to be considered for filter (required) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Pet[] */ - public function findPetsByStatus($status) + public function findPetsByStatus($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) { - list($response) = $this->findPetsByStatusWithHttpInfo($status); + list($response) = $this->findPetsByStatusWithHttpInfo($status, $contentType); return $response; } @@ -752,14 +789,15 @@ class PetApi * Finds Pets by status * * @param string[] $status Status values that need to be considered for filter (required) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) */ - public function findPetsByStatusWithHttpInfo($status) + public function findPetsByStatusWithHttpInfo($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) { - $request = $this->findPetsByStatusRequest($status); + $request = $this->findPetsByStatusRequest($status, $contentType); try { $options = $this->createHttpClientOption(); @@ -851,13 +889,14 @@ class PetApi * Finds Pets by status * * @param string[] $status Status values that need to be considered for filter (required) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function findPetsByStatusAsync($status) + public function findPetsByStatusAsync($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) { - return $this->findPetsByStatusAsyncWithHttpInfo($status) + return $this->findPetsByStatusAsyncWithHttpInfo($status, $contentType) ->then( function ($response) { return $response[0]; @@ -871,14 +910,15 @@ class PetApi * Finds Pets by status * * @param string[] $status Status values that need to be considered for filter (required) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function findPetsByStatusAsyncWithHttpInfo($status) + public function findPetsByStatusAsyncWithHttpInfo($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) { $returnType = '\OpenAPI\Client\Model\Pet[]'; - $request = $this->findPetsByStatusRequest($status); + $request = $this->findPetsByStatusRequest($status, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -920,11 +960,12 @@ class PetApi * Create request for operation 'findPetsByStatus' * * @param string[] $status Status values that need to be considered for filter (required) (deprecated) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function findPetsByStatusRequest($status) + public function findPetsByStatusRequest($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) { // verify the required parameter 'status' is set @@ -934,6 +975,7 @@ class PetApi ); } + $resourcePath = '/pet/findByStatus'; $formParams = []; $queryParams = []; @@ -954,16 +996,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -981,9 +1018,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1022,15 +1059,16 @@ class PetApi * Finds Pets by tags * * @param string[] $tags Tags to filter by (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Pet[] * @deprecated */ - public function findPetsByTags($tags) + public function findPetsByTags($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) { - list($response) = $this->findPetsByTagsWithHttpInfo($tags); + list($response) = $this->findPetsByTagsWithHttpInfo($tags, $contentType); return $response; } @@ -1040,15 +1078,16 @@ class PetApi * Finds Pets by tags * * @param string[] $tags Tags to filter by (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) * @deprecated */ - public function findPetsByTagsWithHttpInfo($tags) + public function findPetsByTagsWithHttpInfo($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) { - $request = $this->findPetsByTagsRequest($tags); + $request = $this->findPetsByTagsRequest($tags, $contentType); try { $options = $this->createHttpClientOption(); @@ -1140,14 +1179,15 @@ class PetApi * Finds Pets by tags * * @param string[] $tags Tags to filter by (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface * @deprecated */ - public function findPetsByTagsAsync($tags) + public function findPetsByTagsAsync($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) { - return $this->findPetsByTagsAsyncWithHttpInfo($tags) + return $this->findPetsByTagsAsyncWithHttpInfo($tags, $contentType) ->then( function ($response) { return $response[0]; @@ -1161,15 +1201,16 @@ class PetApi * Finds Pets by tags * * @param string[] $tags Tags to filter by (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface * @deprecated */ - public function findPetsByTagsAsyncWithHttpInfo($tags) + public function findPetsByTagsAsyncWithHttpInfo($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) { $returnType = '\OpenAPI\Client\Model\Pet[]'; - $request = $this->findPetsByTagsRequest($tags); + $request = $this->findPetsByTagsRequest($tags, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1211,12 +1252,13 @@ class PetApi * Create request for operation 'findPetsByTags' * * @param string[] $tags Tags to filter by (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request * @deprecated */ - public function findPetsByTagsRequest($tags) + public function findPetsByTagsRequest($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) { // verify the required parameter 'tags' is set @@ -1225,7 +1267,7 @@ class PetApi 'Missing the required parameter $tags when calling findPetsByTags' ); } - + $resourcePath = '/pet/findByTags'; $formParams = []; @@ -1247,16 +1289,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1274,9 +1311,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1315,14 +1352,15 @@ class PetApi * Find pet by ID * * @param int $pet_id ID of pet to return (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Pet */ - public function getPetById($pet_id) + public function getPetById($pet_id, string $contentType = self::contentTypes['getPetById'][0]) { - list($response) = $this->getPetByIdWithHttpInfo($pet_id); + list($response) = $this->getPetByIdWithHttpInfo($pet_id, $contentType); return $response; } @@ -1332,14 +1370,15 @@ class PetApi * Find pet by ID * * @param int $pet_id ID of pet to return (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) */ - public function getPetByIdWithHttpInfo($pet_id) + public function getPetByIdWithHttpInfo($pet_id, string $contentType = self::contentTypes['getPetById'][0]) { - $request = $this->getPetByIdRequest($pet_id); + $request = $this->getPetByIdRequest($pet_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -1431,13 +1470,14 @@ class PetApi * Find pet by ID * * @param int $pet_id ID of pet to return (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getPetByIdAsync($pet_id) + public function getPetByIdAsync($pet_id, string $contentType = self::contentTypes['getPetById'][0]) { - return $this->getPetByIdAsyncWithHttpInfo($pet_id) + return $this->getPetByIdAsyncWithHttpInfo($pet_id, $contentType) ->then( function ($response) { return $response[0]; @@ -1451,14 +1491,15 @@ class PetApi * Find pet by ID * * @param int $pet_id ID of pet to return (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getPetByIdAsyncWithHttpInfo($pet_id) + public function getPetByIdAsyncWithHttpInfo($pet_id, string $contentType = self::contentTypes['getPetById'][0]) { $returnType = '\OpenAPI\Client\Model\Pet'; - $request = $this->getPetByIdRequest($pet_id); + $request = $this->getPetByIdRequest($pet_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1500,11 +1541,12 @@ class PetApi * Create request for operation 'getPetById' * * @param int $pet_id ID of pet to return (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getPetByIdRequest($pet_id) + public function getPetByIdRequest($pet_id, string $contentType = self::contentTypes['getPetById'][0]) { // verify the required parameter 'pet_id' is set @@ -1514,6 +1556,7 @@ class PetApi ); } + $resourcePath = '/pet/{petId}'; $formParams = []; $queryParams = []; @@ -1533,16 +1576,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1560,9 +1598,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1620,14 +1658,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function updatePet($pet, ?int $hostIndex = null, array $variables = []) + public function updatePet($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) { - $this->updatePetWithHttpInfo($pet, $hostIndex, $variables); + $this->updatePetWithHttpInfo($pet, $hostIndex, $variables, $contentType); } /** @@ -1654,14 +1693,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function updatePetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = []) + public function updatePetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) { - $request = $this->updatePetRequest($pet, $hostIndex, $variables); + $request = $this->updatePetRequest($pet, $hostIndex, $variables, $contentType); try { $options = $this->createHttpClientOption(); @@ -1731,13 +1771,14 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updatePetAsync($pet, ?int $hostIndex = null, array $variables = []) + public function updatePetAsync($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) { - return $this->updatePetAsyncWithHttpInfo($pet, $hostIndex, $variables) + return $this->updatePetAsyncWithHttpInfo($pet, $hostIndex, $variables, $contentType) ->then( function ($response) { return $response[0]; @@ -1769,14 +1810,15 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updatePetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = []) + public function updatePetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) { $returnType = ''; - $request = $this->updatePetRequest($pet, $hostIndex, $variables); + $request = $this->updatePetRequest($pet, $hostIndex, $variables, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1823,11 +1865,12 @@ class PetApi * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updatePetRequest($pet, ?int $hostIndex = null, array $variables = []) + public function updatePetRequest($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) { // verify the required parameter 'pet' is set @@ -1837,6 +1880,7 @@ class PetApi ); } + $resourcePath = '/pet'; $formParams = []; $queryParams = []; @@ -1848,20 +1892,16 @@ class PetApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', 'application/xml'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($pet)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($pet)); } else { $httpBody = $pet; @@ -1881,9 +1921,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1976,14 +2016,15 @@ class PetApi * @param int $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function updatePetWithForm($pet_id, $name = null, $status = null) + public function updatePetWithForm($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) { - $this->updatePetWithFormWithHttpInfo($pet_id, $name, $status); + $this->updatePetWithFormWithHttpInfo($pet_id, $name, $status, $contentType); } /** @@ -1994,14 +2035,15 @@ class PetApi * @param int $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null) + public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) { - $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + $request = $this->updatePetWithFormRequest($pet_id, $name, $status, $contentType); try { $options = $this->createHttpClientOption(); @@ -2055,13 +2097,14 @@ class PetApi * @param int $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updatePetWithFormAsync($pet_id, $name = null, $status = null) + public function updatePetWithFormAsync($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) { - return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status) + return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status, $contentType) ->then( function ($response) { return $response[0]; @@ -2077,14 +2120,15 @@ class PetApi * @param int $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null) + public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) { $returnType = ''; - $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + $request = $this->updatePetWithFormRequest($pet_id, $name, $status, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2115,11 +2159,12 @@ class PetApi * @param int $pet_id ID of pet that needs to be updated (required) * @param string $name Updated name of the pet (optional) * @param string $status Updated status of the pet (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updatePetWithFormRequest($pet_id, $name = null, $status = null) + public function updatePetWithFormRequest($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) { // verify the required parameter 'pet_id' is set @@ -2131,6 +2176,7 @@ class PetApi + $resourcePath = '/pet/{petId}'; $formParams = []; $queryParams = []; @@ -2158,16 +2204,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( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2185,9 +2226,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2228,14 +2269,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\ApiResponse */ - public function uploadFile($pet_id, $additional_metadata = null, $file = null) + public function uploadFile($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) { - list($response) = $this->uploadFileWithHttpInfo($pet_id, $additional_metadata, $file); + list($response) = $this->uploadFileWithHttpInfo($pet_id, $additional_metadata, $file, $contentType); return $response; } @@ -2247,14 +2289,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) */ - public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null) + public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) { - $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file, $contentType); try { $options = $this->createHttpClientOption(); @@ -2348,13 +2391,14 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null) + public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) { - return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file) + return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file, $contentType) ->then( function ($response) { return $response[0]; @@ -2370,14 +2414,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null) + public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) { $returnType = '\OpenAPI\Client\Model\ApiResponse'; - $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2421,11 +2466,12 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param string $additional_metadata Additional data to pass to server (optional) * @param \SplFileObject $file file to upload (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function uploadFileRequest($pet_id, $additional_metadata = null, $file = null) + public function uploadFileRequest($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) { // verify the required parameter 'pet_id' is set @@ -2437,6 +2483,7 @@ class PetApi + $resourcePath = '/pet/{petId}/uploadImage'; $formParams = []; $queryParams = []; @@ -2472,16 +2519,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2499,9 +2541,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2542,14 +2584,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param \SplFileObject $required_file file to upload (required) * @param string $additional_metadata Additional data to pass to server (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\ApiResponse */ - public function uploadFileWithRequiredFile($pet_id, $required_file, $additional_metadata = null) + public function uploadFileWithRequiredFile($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) { - list($response) = $this->uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata); + list($response) = $this->uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata, $contentType); return $response; } @@ -2561,14 +2604,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param \SplFileObject $required_file file to upload (required) * @param string $additional_metadata Additional data to pass to server (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) */ - public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata = null) + public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) { - $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata); + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata, $contentType); try { $options = $this->createHttpClientOption(); @@ -2662,13 +2706,14 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param \SplFileObject $required_file file to upload (required) * @param string $additional_metadata Additional data to pass to server (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function uploadFileWithRequiredFileAsync($pet_id, $required_file, $additional_metadata = null) + public function uploadFileWithRequiredFileAsync($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) { - return $this->uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata) + return $this->uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata, $contentType) ->then( function ($response) { return $response[0]; @@ -2684,14 +2729,15 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param \SplFileObject $required_file file to upload (required) * @param string $additional_metadata Additional data to pass to server (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata = null) + public function uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) { $returnType = '\OpenAPI\Client\Model\ApiResponse'; - $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata); + $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -2735,11 +2781,12 @@ class PetApi * @param int $pet_id ID of pet to update (required) * @param \SplFileObject $required_file file to upload (required) * @param string $additional_metadata Additional data to pass to server (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata = null) + public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) { // verify the required parameter 'pet_id' is set @@ -2757,6 +2804,7 @@ class PetApi } + $resourcePath = '/fake/{petId}/uploadImageWithRequiredFile'; $formParams = []; $queryParams = []; @@ -2792,16 +2840,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -2819,9 +2862,9 @@ class PetApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php index b4e44d05a30..f238db0c1bb 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -69,7 +69,23 @@ class StoreApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'deleteOrder' => [ + 'application/json', + ], + 'getInventory' => [ + 'application/json', + ], + 'getOrderById' => [ + 'application/json', + ], + 'placeOrder' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -121,14 +137,15 @@ class StoreApi * Delete purchase order by ID * * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function deleteOrder($order_id) + public function deleteOrder($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) { - $this->deleteOrderWithHttpInfo($order_id); + $this->deleteOrderWithHttpInfo($order_id, $contentType); } /** @@ -137,14 +154,15 @@ class StoreApi * Delete purchase order by ID * * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function deleteOrderWithHttpInfo($order_id) + public function deleteOrderWithHttpInfo($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) { - $request = $this->deleteOrderRequest($order_id); + $request = $this->deleteOrderRequest($order_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -196,13 +214,14 @@ class StoreApi * Delete purchase order by ID * * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deleteOrderAsync($order_id) + public function deleteOrderAsync($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) { - return $this->deleteOrderAsyncWithHttpInfo($order_id) + return $this->deleteOrderAsyncWithHttpInfo($order_id, $contentType) ->then( function ($response) { return $response[0]; @@ -216,14 +235,15 @@ class StoreApi * Delete purchase order by ID * * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deleteOrderAsyncWithHttpInfo($order_id) + public function deleteOrderAsyncWithHttpInfo($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) { $returnType = ''; - $request = $this->deleteOrderRequest($order_id); + $request = $this->deleteOrderRequest($order_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -252,11 +272,12 @@ class StoreApi * Create request for operation 'deleteOrder' * * @param string $order_id ID of the order that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function deleteOrderRequest($order_id) + public function deleteOrderRequest($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) { // verify the required parameter 'order_id' is set @@ -266,6 +287,7 @@ class StoreApi ); } + $resourcePath = '/store/order/{order_id}'; $formParams = []; $queryParams = []; @@ -285,16 +307,11 @@ class StoreApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -312,9 +329,9 @@ class StoreApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -348,14 +365,15 @@ class StoreApi * * Returns pet inventories by status * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array */ - public function getInventory() + public function getInventory(string $contentType = self::contentTypes['getInventory'][0]) { - list($response) = $this->getInventoryWithHttpInfo(); + list($response) = $this->getInventoryWithHttpInfo($contentType); return $response; } @@ -364,14 +382,15 @@ class StoreApi * * Returns pet inventories by status * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of array, HTTP status code, HTTP response headers (array of strings) */ - public function getInventoryWithHttpInfo() + public function getInventoryWithHttpInfo(string $contentType = self::contentTypes['getInventory'][0]) { - $request = $this->getInventoryRequest(); + $request = $this->getInventoryRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -462,13 +481,14 @@ class StoreApi * * Returns pet inventories by status * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getInventoryAsync() + public function getInventoryAsync(string $contentType = self::contentTypes['getInventory'][0]) { - return $this->getInventoryAsyncWithHttpInfo() + return $this->getInventoryAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -481,14 +501,15 @@ class StoreApi * * Returns pet inventories by status * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getInventoryAsyncWithHttpInfo() + public function getInventoryAsyncWithHttpInfo(string $contentType = self::contentTypes['getInventory'][0]) { $returnType = 'array'; - $request = $this->getInventoryRequest(); + $request = $this->getInventoryRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -529,13 +550,15 @@ class StoreApi /** * Create request for operation 'getInventory' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getInventoryRequest() + public function getInventoryRequest(string $contentType = self::contentTypes['getInventory'][0]) { + $resourcePath = '/store/inventory'; $formParams = []; $queryParams = []; @@ -547,16 +570,11 @@ class StoreApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - ['application/json'] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - ['application/json'], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -574,9 +592,9 @@ class StoreApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -616,14 +634,15 @@ class StoreApi * Find purchase order by ID * * @param int $order_id ID of pet that needs to be fetched (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Order */ - public function getOrderById($order_id) + public function getOrderById($order_id, string $contentType = self::contentTypes['getOrderById'][0]) { - list($response) = $this->getOrderByIdWithHttpInfo($order_id); + list($response) = $this->getOrderByIdWithHttpInfo($order_id, $contentType); return $response; } @@ -633,14 +652,15 @@ class StoreApi * Find purchase order by ID * * @param int $order_id ID of pet that needs to be fetched (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ - public function getOrderByIdWithHttpInfo($order_id) + public function getOrderByIdWithHttpInfo($order_id, string $contentType = self::contentTypes['getOrderById'][0]) { - $request = $this->getOrderByIdRequest($order_id); + $request = $this->getOrderByIdRequest($order_id, $contentType); try { $options = $this->createHttpClientOption(); @@ -732,13 +752,14 @@ class StoreApi * Find purchase order by ID * * @param int $order_id ID of pet that needs to be fetched (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderByIdAsync($order_id) + public function getOrderByIdAsync($order_id, string $contentType = self::contentTypes['getOrderById'][0]) { - return $this->getOrderByIdAsyncWithHttpInfo($order_id) + return $this->getOrderByIdAsyncWithHttpInfo($order_id, $contentType) ->then( function ($response) { return $response[0]; @@ -752,14 +773,15 @@ class StoreApi * Find purchase order by ID * * @param int $order_id ID of pet that needs to be fetched (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getOrderByIdAsyncWithHttpInfo($order_id) + public function getOrderByIdAsyncWithHttpInfo($order_id, string $contentType = self::contentTypes['getOrderById'][0]) { $returnType = '\OpenAPI\Client\Model\Order'; - $request = $this->getOrderByIdRequest($order_id); + $request = $this->getOrderByIdRequest($order_id, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -801,11 +823,12 @@ class StoreApi * Create request for operation 'getOrderById' * * @param int $order_id ID of pet that needs to be fetched (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getOrderByIdRequest($order_id) + public function getOrderByIdRequest($order_id, string $contentType = self::contentTypes['getOrderById'][0]) { // verify the required parameter 'order_id' is set @@ -820,7 +843,7 @@ class StoreApi if ($order_id < 1) { throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be bigger than or equal to 1.'); } - + $resourcePath = '/store/order/{order_id}'; $formParams = []; @@ -841,16 +864,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -868,9 +886,9 @@ class StoreApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -905,14 +923,15 @@ class StoreApi * Place an order for a pet * * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\Order */ - public function placeOrder($order) + public function placeOrder($order, string $contentType = self::contentTypes['placeOrder'][0]) { - list($response) = $this->placeOrderWithHttpInfo($order); + list($response) = $this->placeOrderWithHttpInfo($order, $contentType); return $response; } @@ -922,14 +941,15 @@ class StoreApi * Place an order for a pet * * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) */ - public function placeOrderWithHttpInfo($order) + public function placeOrderWithHttpInfo($order, string $contentType = self::contentTypes['placeOrder'][0]) { - $request = $this->placeOrderRequest($order); + $request = $this->placeOrderRequest($order, $contentType); try { $options = $this->createHttpClientOption(); @@ -1021,13 +1041,14 @@ class StoreApi * Place an order for a pet * * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsync($order) + public function placeOrderAsync($order, string $contentType = self::contentTypes['placeOrder'][0]) { - return $this->placeOrderAsyncWithHttpInfo($order) + return $this->placeOrderAsyncWithHttpInfo($order, $contentType) ->then( function ($response) { return $response[0]; @@ -1041,14 +1062,15 @@ class StoreApi * Place an order for a pet * * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function placeOrderAsyncWithHttpInfo($order) + public function placeOrderAsyncWithHttpInfo($order, string $contentType = self::contentTypes['placeOrder'][0]) { $returnType = '\OpenAPI\Client\Model\Order'; - $request = $this->placeOrderRequest($order); + $request = $this->placeOrderRequest($order, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1090,11 +1112,12 @@ class StoreApi * Create request for operation 'placeOrder' * * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function placeOrderRequest($order) + public function placeOrderRequest($order, string $contentType = self::contentTypes['placeOrder'][0]) { // verify the required parameter 'order' is set @@ -1104,6 +1127,7 @@ class StoreApi ); } + $resourcePath = '/store/order'; $formParams = []; $queryParams = []; @@ -1115,20 +1139,16 @@ 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', ], + $contentType, + $multipart + ); // for model (json/xml) if (isset($order)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($order)); } else { $httpBody = $order; @@ -1148,9 +1168,9 @@ class StoreApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 3fe21fa7064..782f8b811d1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -69,7 +69,35 @@ class UserApi */ protected $hostIndex; - /** + /** @var string[] $contentTypes **/ + public const contentTypes = [ + 'createUser' => [ + 'application/json', + ], + 'createUsersWithArrayInput' => [ + 'application/json', + ], + 'createUsersWithListInput' => [ + 'application/json', + ], + 'deleteUser' => [ + 'application/json', + ], + 'getUserByName' => [ + 'application/json', + ], + 'loginUser' => [ + 'application/json', + ], + 'logoutUser' => [ + 'application/json', + ], + 'updateUser' => [ + 'application/json', + ], + ]; + +/** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -121,14 +149,15 @@ class UserApi * Create user * * @param \OpenAPI\Client\Model\User $user Created user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function createUser($user) + public function createUser($user, string $contentType = self::contentTypes['createUser'][0]) { - $this->createUserWithHttpInfo($user); + $this->createUserWithHttpInfo($user, $contentType); } /** @@ -137,14 +166,15 @@ class UserApi * Create user * * @param \OpenAPI\Client\Model\User $user Created user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function createUserWithHttpInfo($user) + public function createUserWithHttpInfo($user, string $contentType = self::contentTypes['createUser'][0]) { - $request = $this->createUserRequest($user); + $request = $this->createUserRequest($user, $contentType); try { $options = $this->createHttpClientOption(); @@ -196,13 +226,14 @@ class UserApi * Create user * * @param \OpenAPI\Client\Model\User $user Created user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUserAsync($user) + public function createUserAsync($user, string $contentType = self::contentTypes['createUser'][0]) { - return $this->createUserAsyncWithHttpInfo($user) + return $this->createUserAsyncWithHttpInfo($user, $contentType) ->then( function ($response) { return $response[0]; @@ -216,14 +247,15 @@ class UserApi * Create user * * @param \OpenAPI\Client\Model\User $user Created user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUserAsyncWithHttpInfo($user) + public function createUserAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUser'][0]) { $returnType = ''; - $request = $this->createUserRequest($user); + $request = $this->createUserRequest($user, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -252,11 +284,12 @@ class UserApi * Create request for operation 'createUser' * * @param \OpenAPI\Client\Model\User $user Created user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createUserRequest($user) + public function createUserRequest($user, string $contentType = self::contentTypes['createUser'][0]) { // verify the required parameter 'user' is set @@ -266,6 +299,7 @@ class UserApi ); } + $resourcePath = '/user'; $formParams = []; $queryParams = []; @@ -277,20 +311,16 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($user)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user)); } else { $httpBody = $user; @@ -310,9 +340,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -347,14 +377,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function createUsersWithArrayInput($user) + public function createUsersWithArrayInput($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) { - $this->createUsersWithArrayInputWithHttpInfo($user); + $this->createUsersWithArrayInputWithHttpInfo($user, $contentType); } /** @@ -363,14 +394,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function createUsersWithArrayInputWithHttpInfo($user) + public function createUsersWithArrayInputWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) { - $request = $this->createUsersWithArrayInputRequest($user); + $request = $this->createUsersWithArrayInputRequest($user, $contentType); try { $options = $this->createHttpClientOption(); @@ -422,13 +454,14 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUsersWithArrayInputAsync($user) + public function createUsersWithArrayInputAsync($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) { - return $this->createUsersWithArrayInputAsyncWithHttpInfo($user) + return $this->createUsersWithArrayInputAsyncWithHttpInfo($user, $contentType) ->then( function ($response) { return $response[0]; @@ -442,14 +475,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUsersWithArrayInputAsyncWithHttpInfo($user) + public function createUsersWithArrayInputAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) { $returnType = ''; - $request = $this->createUsersWithArrayInputRequest($user); + $request = $this->createUsersWithArrayInputRequest($user, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -478,11 +512,12 @@ class UserApi * Create request for operation 'createUsersWithArrayInput' * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createUsersWithArrayInputRequest($user) + public function createUsersWithArrayInputRequest($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) { // verify the required parameter 'user' is set @@ -492,6 +527,7 @@ class UserApi ); } + $resourcePath = '/user/createWithArray'; $formParams = []; $queryParams = []; @@ -503,20 +539,16 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($user)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user)); } else { $httpBody = $user; @@ -536,9 +568,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -573,14 +605,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function createUsersWithListInput($user) + public function createUsersWithListInput($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) { - $this->createUsersWithListInputWithHttpInfo($user); + $this->createUsersWithListInputWithHttpInfo($user, $contentType); } /** @@ -589,14 +622,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function createUsersWithListInputWithHttpInfo($user) + public function createUsersWithListInputWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) { - $request = $this->createUsersWithListInputRequest($user); + $request = $this->createUsersWithListInputRequest($user, $contentType); try { $options = $this->createHttpClientOption(); @@ -648,13 +682,14 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUsersWithListInputAsync($user) + public function createUsersWithListInputAsync($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) { - return $this->createUsersWithListInputAsyncWithHttpInfo($user) + return $this->createUsersWithListInputAsyncWithHttpInfo($user, $contentType) ->then( function ($response) { return $response[0]; @@ -668,14 +703,15 @@ class UserApi * Creates list of users with given input array * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function createUsersWithListInputAsyncWithHttpInfo($user) + public function createUsersWithListInputAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) { $returnType = ''; - $request = $this->createUsersWithListInputRequest($user); + $request = $this->createUsersWithListInputRequest($user, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -704,11 +740,12 @@ class UserApi * Create request for operation 'createUsersWithListInput' * * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function createUsersWithListInputRequest($user) + public function createUsersWithListInputRequest($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) { // verify the required parameter 'user' is set @@ -718,6 +755,7 @@ class UserApi ); } + $resourcePath = '/user/createWithList'; $formParams = []; $queryParams = []; @@ -729,20 +767,16 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($user)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user)); } else { $httpBody = $user; @@ -762,9 +796,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -799,14 +833,15 @@ class UserApi * Delete user * * @param string $username The name that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function deleteUser($username) + public function deleteUser($username, string $contentType = self::contentTypes['deleteUser'][0]) { - $this->deleteUserWithHttpInfo($username); + $this->deleteUserWithHttpInfo($username, $contentType); } /** @@ -815,14 +850,15 @@ class UserApi * Delete user * * @param string $username The name that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function deleteUserWithHttpInfo($username) + public function deleteUserWithHttpInfo($username, string $contentType = self::contentTypes['deleteUser'][0]) { - $request = $this->deleteUserRequest($username); + $request = $this->deleteUserRequest($username, $contentType); try { $options = $this->createHttpClientOption(); @@ -874,13 +910,14 @@ class UserApi * Delete user * * @param string $username The name that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deleteUserAsync($username) + public function deleteUserAsync($username, string $contentType = self::contentTypes['deleteUser'][0]) { - return $this->deleteUserAsyncWithHttpInfo($username) + return $this->deleteUserAsyncWithHttpInfo($username, $contentType) ->then( function ($response) { return $response[0]; @@ -894,14 +931,15 @@ class UserApi * Delete user * * @param string $username The name that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function deleteUserAsyncWithHttpInfo($username) + public function deleteUserAsyncWithHttpInfo($username, string $contentType = self::contentTypes['deleteUser'][0]) { $returnType = ''; - $request = $this->deleteUserRequest($username); + $request = $this->deleteUserRequest($username, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -930,11 +968,12 @@ class UserApi * Create request for operation 'deleteUser' * * @param string $username The name that needs to be deleted (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function deleteUserRequest($username) + public function deleteUserRequest($username, string $contentType = self::contentTypes['deleteUser'][0]) { // verify the required parameter 'username' is set @@ -944,6 +983,7 @@ class UserApi ); } + $resourcePath = '/user/{username}'; $formParams = []; $queryParams = []; @@ -963,16 +1003,11 @@ class UserApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -990,9 +1025,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1027,14 +1062,15 @@ class UserApi * Get user by user name * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \OpenAPI\Client\Model\User */ - public function getUserByName($username) + public function getUserByName($username, string $contentType = self::contentTypes['getUserByName'][0]) { - list($response) = $this->getUserByNameWithHttpInfo($username); + list($response) = $this->getUserByNameWithHttpInfo($username, $contentType); return $response; } @@ -1044,14 +1080,15 @@ class UserApi * Get user by user name * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \OpenAPI\Client\Model\User, HTTP status code, HTTP response headers (array of strings) */ - public function getUserByNameWithHttpInfo($username) + public function getUserByNameWithHttpInfo($username, string $contentType = self::contentTypes['getUserByName'][0]) { - $request = $this->getUserByNameRequest($username); + $request = $this->getUserByNameRequest($username, $contentType); try { $options = $this->createHttpClientOption(); @@ -1143,13 +1180,14 @@ class UserApi * Get user by user name * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserByNameAsync($username) + public function getUserByNameAsync($username, string $contentType = self::contentTypes['getUserByName'][0]) { - return $this->getUserByNameAsyncWithHttpInfo($username) + return $this->getUserByNameAsyncWithHttpInfo($username, $contentType) ->then( function ($response) { return $response[0]; @@ -1163,14 +1201,15 @@ class UserApi * Get user by user name * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function getUserByNameAsyncWithHttpInfo($username) + public function getUserByNameAsyncWithHttpInfo($username, string $contentType = self::contentTypes['getUserByName'][0]) { $returnType = '\OpenAPI\Client\Model\User'; - $request = $this->getUserByNameRequest($username); + $request = $this->getUserByNameRequest($username, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1212,11 +1251,12 @@ class UserApi * Create request for operation 'getUserByName' * * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function getUserByNameRequest($username) + public function getUserByNameRequest($username, string $contentType = self::contentTypes['getUserByName'][0]) { // verify the required parameter 'username' is set @@ -1226,6 +1266,7 @@ class UserApi ); } + $resourcePath = '/user/{username}'; $formParams = []; $queryParams = []; @@ -1245,16 +1286,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1272,9 +1308,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1310,14 +1346,15 @@ class UserApi * * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return string */ - public function loginUser($username, $password) + public function loginUser($username, $password, string $contentType = self::contentTypes['loginUser'][0]) { - list($response) = $this->loginUserWithHttpInfo($username, $password); + list($response) = $this->loginUserWithHttpInfo($username, $password, $contentType); return $response; } @@ -1328,14 +1365,15 @@ class UserApi * * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of string, HTTP status code, HTTP response headers (array of strings) */ - public function loginUserWithHttpInfo($username, $password) + public function loginUserWithHttpInfo($username, $password, string $contentType = self::contentTypes['loginUser'][0]) { - $request = $this->loginUserRequest($username, $password); + $request = $this->loginUserRequest($username, $password, $contentType); try { $options = $this->createHttpClientOption(); @@ -1428,13 +1466,14 @@ class UserApi * * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function loginUserAsync($username, $password) + public function loginUserAsync($username, $password, string $contentType = self::contentTypes['loginUser'][0]) { - return $this->loginUserAsyncWithHttpInfo($username, $password) + return $this->loginUserAsyncWithHttpInfo($username, $password, $contentType) ->then( function ($response) { return $response[0]; @@ -1449,14 +1488,15 @@ class UserApi * * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function loginUserAsyncWithHttpInfo($username, $password) + public function loginUserAsyncWithHttpInfo($username, $password, string $contentType = self::contentTypes['loginUser'][0]) { $returnType = 'string'; - $request = $this->loginUserRequest($username, $password); + $request = $this->loginUserRequest($username, $password, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1499,11 +1539,12 @@ class UserApi * * @param string $username The user name for login (required) * @param string $password The password for login in clear text (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function loginUserRequest($username, $password) + public function loginUserRequest($username, $password, string $contentType = self::contentTypes['loginUser'][0]) { // verify the required parameter 'username' is set @@ -1520,6 +1561,7 @@ class UserApi ); } + $resourcePath = '/user/login'; $formParams = []; $queryParams = []; @@ -1549,16 +1591,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', ], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1576,9 +1613,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1612,14 +1649,15 @@ class UserApi * * Logs out current logged in user session * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function logoutUser() + public function logoutUser(string $contentType = self::contentTypes['logoutUser'][0]) { - $this->logoutUserWithHttpInfo(); + $this->logoutUserWithHttpInfo($contentType); } /** @@ -1627,14 +1665,15 @@ class UserApi * * Logs out current logged in user session * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function logoutUserWithHttpInfo() + public function logoutUserWithHttpInfo(string $contentType = self::contentTypes['logoutUser'][0]) { - $request = $this->logoutUserRequest(); + $request = $this->logoutUserRequest($contentType); try { $options = $this->createHttpClientOption(); @@ -1685,13 +1724,14 @@ class UserApi * * Logs out current logged in user session * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function logoutUserAsync() + public function logoutUserAsync(string $contentType = self::contentTypes['logoutUser'][0]) { - return $this->logoutUserAsyncWithHttpInfo() + return $this->logoutUserAsyncWithHttpInfo($contentType) ->then( function ($response) { return $response[0]; @@ -1704,14 +1744,15 @@ class UserApi * * Logs out current logged in user session * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function logoutUserAsyncWithHttpInfo() + public function logoutUserAsyncWithHttpInfo(string $contentType = self::contentTypes['logoutUser'][0]) { $returnType = ''; - $request = $this->logoutUserRequest(); + $request = $this->logoutUserRequest($contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1739,13 +1780,15 @@ class UserApi /** * Create request for operation 'logoutUser' * + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function logoutUserRequest() + public function logoutUserRequest(string $contentType = self::contentTypes['logoutUser'][0]) { + $resourcePath = '/user/logout'; $formParams = []; $queryParams = []; @@ -1757,16 +1800,11 @@ class UserApi - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - [] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (count($formParams) > 0) { @@ -1784,9 +1822,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1822,14 +1860,15 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function updateUser($username, $user) + public function updateUser($username, $user, string $contentType = self::contentTypes['updateUser'][0]) { - $this->updateUserWithHttpInfo($username, $user); + $this->updateUserWithHttpInfo($username, $user, $contentType); } /** @@ -1839,14 +1878,15 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of null, HTTP status code, HTTP response headers (array of strings) */ - public function updateUserWithHttpInfo($username, $user) + public function updateUserWithHttpInfo($username, $user, string $contentType = self::contentTypes['updateUser'][0]) { - $request = $this->updateUserRequest($username, $user); + $request = $this->updateUserRequest($username, $user, $contentType); try { $options = $this->createHttpClientOption(); @@ -1899,13 +1939,14 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateUserAsync($username, $user) + public function updateUserAsync($username, $user, string $contentType = self::contentTypes['updateUser'][0]) { - return $this->updateUserAsyncWithHttpInfo($username, $user) + return $this->updateUserAsyncWithHttpInfo($username, $user, $contentType) ->then( function ($response) { return $response[0]; @@ -1920,14 +1961,15 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function updateUserAsyncWithHttpInfo($username, $user) + public function updateUserAsyncWithHttpInfo($username, $user, string $contentType = self::contentTypes['updateUser'][0]) { $returnType = ''; - $request = $this->updateUserRequest($username, $user); + $request = $this->updateUserRequest($username, $user, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -1957,11 +1999,12 @@ class UserApi * * @param string $username name that need to be deleted (required) * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - public function updateUserRequest($username, $user) + public function updateUserRequest($username, $user, string $contentType = self::contentTypes['updateUser'][0]) { // verify the required parameter 'username' is set @@ -1978,6 +2021,7 @@ class UserApi ); } + $resourcePath = '/user/{username}'; $formParams = []; $queryParams = []; @@ -1997,20 +2041,16 @@ class UserApi } - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json'] - ); - } + $headers = $this->headerSelector->selectHeaders( + [], + $contentType, + $multipart + ); // for model (json/xml) if (isset($user)) { - if ($headers['Content-Type'] === 'application/json') { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($user)); } else { $httpBody = $user; @@ -2030,9 +2070,9 @@ class UserApi // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); - } elseif ($headers['Content-Type'] === 'application/json') { + } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\json_encode($formParams); - } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php index d3a56bae3c3..769fdb8d0c1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -1,6 +1,6 @@ selectContentTypeHeader($contentTypes); - return $headers; - } - - /** - * @param string[] $accept - * @return array - */ - public function selectHeadersForMultipart($accept) - { - $headers = $this->selectHeaders($accept, []); - - unset($headers['Content-Type']); return $headers; } @@ -86,22 +78,4 @@ class HeaderSelector return implode(',', $accept); } } - - /** - * Return the content type based on an array of content-type provided - * - * @param string[] $contentType Array fo content-type - * - * @return string Content-Type (e.g. application/json) - */ - private function selectContentTypeHeader($contentType) - { - if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { - return 'application/json'; - } elseif (preg_grep("/application\/json/i", $contentType)) { - return 'application/json'; - } else { - return implode(',', $contentType); - } - } } diff --git a/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php index 6dd19a675f6..bbc54c5a78f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php @@ -1,58 +1,70 @@ selectHeaders([ - 'application/xml', - 'application/json' - ], []); - $this->assertSame('application/json', $headers['Accept']); - $headers = $selector->selectHeaders([], []); - $this->assertArrayNotHasKey('Accept', $headers); - - $header = $selector->selectHeaders([ - 'application/yaml', - 'application/xml' - ], []); - $this->assertSame('application/yaml,application/xml', $header['Accept']); - - // test selectHeaderContentType - $headers = $selector->selectHeaders([], [ - 'application/xml', - 'application/json' - ]); - $this->assertSame('application/json', $headers['Content-Type']); - - $headers = $selector->selectHeaders([], []); - $this->assertSame('application/json', $headers['Content-Type']); - $headers = $selector->selectHeaders([], [ - 'application/yaml', - 'application/xml' - ]); - $this->assertSame('application/yaml,application/xml', $headers['Content-Type']); + $headers = $selector->selectHeaders($accept, $contentType, $isMultiple); + $this->assertEquals($expectedHeaders, $headers); } - public function testSelectingHeadersForMultipartBody() + /** + * @return array[][] + */ + public function headersProvider(): array { - // test selectHeaderAccept - $selector = new HeaderSelector(); - $headers = $selector->selectHeadersForMultipart([ - 'application/xml', - 'application/json' - ]); - $this->assertSame('application/json', $headers['Accept']); - $this->assertArrayNotHasKey('Content-Type', $headers); - - $headers = $selector->selectHeadersForMultipart([]); - $this->assertArrayNotHasKey('Accept', $headers); - $this->assertArrayNotHasKey('Content-Type', $headers); + return [ + // array $accept, string $contentType, bool $isMultipart, array $expectedHeaders + [ + [], 'application/xml', false, ['Content-Type' => 'application/xml'], + ], + [ + [], 'application/xml', true, [], + ], + [ + ['application/xml'], '', false, ['Accept' => 'application/xml', 'Content-Type' => 'application/json'], + ], + [ + ['application/xml'], '', true, ['Accept' => 'application/xml'], + ], + [ + ['application/xml'], 'application/xml', false, ['Accept' => 'application/xml', 'Content-Type' => 'application/xml'], + ], + [ + ['application/xml'], 'application/xml', true, ['Accept' => 'application/xml'], + ], + [ + ['application/xml', 'text/html'], 'application/xml', false, ['Accept' => 'application/xml,text/html', 'Content-Type' => 'application/xml'], + ], + [ + ['application/json', 'text/html'], 'application/xml', false, ['Accept' => 'application/json', 'Content-Type' => 'application/xml'], + ], + [ + ['text/html', 'application/json'], 'application/xml', false, ['Accept' => 'application/json', 'Content-Type' => 'application/xml'], + ], + [ + ['application/json;format=flowed'], 'text/plain;format=fixed', false, ['Accept' => 'application/json;format=flowed', 'Content-Type' => 'text/plain;format=fixed'], + ], + [ + ['text/html', 'application/json;format=flowed'], 'text/plain;format=fixed', false, ['Accept' => 'application/json;format=flowed', 'Content-Type' => 'text/plain;format=fixed'], + ], + ]; } }