diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache index 48df1e87b6b6..400dd765b157 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache @@ -762,7 +762,11 @@ use {{invokerPackage}}\ObjectSerializer; if (isset(${{paramName}})) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = ${{paramName}}; } @@ -787,7 +791,11 @@ use {{invokerPackage}}\ObjectSerializer; } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 11cd9754eefa..eb8540f3b618 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -677,7 +677,11 @@ use {{invokerPackage}}\ObjectSerializer; if (isset(${{paramName}})) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization(${{paramName}})); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = ${{paramName}}; } @@ -702,7 +706,11 @@ use {{invokerPackage}}\ObjectSerializer; } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Api/BodyApi.php b/samples/client/echo_api/php-nextgen-streaming/src/Api/BodyApi.php index 91ea7dadd148..d420d1f2fe1f 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Api/BodyApi.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Api/BodyApi.php @@ -598,7 +598,11 @@ public function testBodyApplicationOctetstreamBinaryRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -619,7 +623,11 @@ public function testBodyApplicationOctetstreamBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -896,7 +904,11 @@ public function testBodyMultipartFormdataArrayOfBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1167,7 +1179,11 @@ public function testBodyMultipartFormdataSingleBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1415,7 +1431,11 @@ public function testEchoBodyAllOfPetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1436,7 +1456,11 @@ public function testEchoBodyAllOfPetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1684,7 +1708,11 @@ public function testEchoBodyFreeFormObjectResponseStringRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -1705,7 +1733,11 @@ public function testEchoBodyFreeFormObjectResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1953,7 +1985,11 @@ public function testEchoBodyPetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1974,7 +2010,11 @@ public function testEchoBodyPetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2222,7 +2262,11 @@ public function testEchoBodyPetResponseStringRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -2243,7 +2287,11 @@ public function testEchoBodyPetResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2491,7 +2539,11 @@ public function testEchoBodyStringEnumRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -2512,7 +2564,11 @@ public function testEchoBodyStringEnumRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2760,7 +2816,11 @@ public function testEchoBodyTagResponseStringRequest( if (isset($tag)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($tag)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($tag), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $tag; } @@ -2781,7 +2841,11 @@ public function testEchoBodyTagResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Api/FormApi.php b/samples/client/echo_api/php-nextgen-streaming/src/Api/FormApi.php index d0320a8a14da..529c247dd986 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Api/FormApi.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Api/FormApi.php @@ -395,7 +395,11 @@ public function testFormIntegerBooleanStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -672,7 +676,11 @@ public function testFormObjectMultipartRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -998,7 +1006,11 @@ public function testFormOneofRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php index 4a469a23c2cc..fbb8ec2a6532 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/BodyApi.php @@ -598,7 +598,11 @@ public function testBodyApplicationOctetstreamBinaryRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -619,7 +623,11 @@ public function testBodyApplicationOctetstreamBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -896,7 +904,11 @@ public function testBodyMultipartFormdataArrayOfBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1167,7 +1179,11 @@ public function testBodyMultipartFormdataSingleBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1415,7 +1431,11 @@ public function testEchoBodyAllOfPetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1436,7 +1456,11 @@ public function testEchoBodyAllOfPetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1684,7 +1708,11 @@ public function testEchoBodyFreeFormObjectResponseStringRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -1705,7 +1733,11 @@ public function testEchoBodyFreeFormObjectResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1953,7 +1985,11 @@ public function testEchoBodyPetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1974,7 +2010,11 @@ public function testEchoBodyPetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2222,7 +2262,11 @@ public function testEchoBodyPetResponseStringRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -2243,7 +2287,11 @@ public function testEchoBodyPetResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2491,7 +2539,11 @@ public function testEchoBodyStringEnumRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -2512,7 +2564,11 @@ public function testEchoBodyStringEnumRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2760,7 +2816,11 @@ public function testEchoBodyTagResponseStringRequest( if (isset($tag)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($tag)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($tag), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $tag; } @@ -2781,7 +2841,11 @@ public function testEchoBodyTagResponseStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/echo_api/php-nextgen/src/Api/FormApi.php b/samples/client/echo_api/php-nextgen/src/Api/FormApi.php index d0320a8a14da..529c247dd986 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/FormApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/FormApi.php @@ -395,7 +395,11 @@ public function testFormIntegerBooleanStringRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -672,7 +676,11 @@ public function testFormObjectMultipartRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -998,7 +1006,11 @@ public function testFormOneofRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php index ec16c2ae27b1..1f107cd2a699 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/AnotherFakeApi.php @@ -349,7 +349,11 @@ public function call123TestSpecialTagsRequest( if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -370,7 +374,11 @@ public function call123TestSpecialTagsRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php index 01b263844636..8c269716e5a2 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php @@ -1405,7 +1405,11 @@ public function fakeHttpSignatureTestRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1426,7 +1430,11 @@ public function fakeHttpSignatureTestRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1666,7 +1674,11 @@ public function fakeOuterBooleanSerializeRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -1687,7 +1699,11 @@ public function fakeOuterBooleanSerializeRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1927,7 +1943,11 @@ public function fakeOuterCompositeSerializeRequest( if (isset($outer_composite)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_composite)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($outer_composite), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $outer_composite; } @@ -1948,7 +1968,11 @@ public function fakeOuterCompositeSerializeRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2188,7 +2212,11 @@ public function fakeOuterNumberSerializeRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -2209,7 +2237,11 @@ public function fakeOuterNumberSerializeRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2449,7 +2481,11 @@ public function fakeOuterStringSerializeRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -2470,7 +2506,11 @@ public function fakeOuterStringSerializeRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2716,7 +2756,11 @@ public function fakePropertyEnumIntegerSerializeRequest( if (isset($outer_object_with_enum_property)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $outer_object_with_enum_property; } @@ -2737,7 +2781,11 @@ public function fakePropertyEnumIntegerSerializeRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3023,7 +3071,11 @@ public function fakeWith400And4xxRangeResponseEndpointRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3044,7 +3096,11 @@ public function fakeWith400And4xxRangeResponseEndpointRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3298,7 +3354,11 @@ public function fakeWith400And4xxRangeResponseNo4xxDatatypeEndpointRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3319,7 +3379,11 @@ public function fakeWith400And4xxRangeResponseNo4xxDatatypeEndpointRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3587,7 +3651,11 @@ public function fakeWith400ResponseEndpointRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3608,7 +3676,11 @@ public function fakeWith400ResponseEndpointRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3880,7 +3952,11 @@ public function fakeWith4xxRangeResponseEndpointRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3901,7 +3977,11 @@ public function fakeWith4xxRangeResponseEndpointRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4155,7 +4235,11 @@ public function fakeWith4xxRangeResponseNo4xxDatatypeEndpointRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -4176,7 +4260,11 @@ public function fakeWith4xxRangeResponseNo4xxDatatypeEndpointRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4383,7 +4471,11 @@ public function testAdditionalPropertiesReferenceRequest( if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -4404,7 +4496,11 @@ public function testAdditionalPropertiesReferenceRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4603,7 +4699,11 @@ public function testBodyWithBinaryRequest( if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -4624,7 +4724,11 @@ public function testBodyWithBinaryRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4823,7 +4927,11 @@ public function testBodyWithFileSchemaRequest( if (isset($file_schema_test_class)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $file_schema_test_class; } @@ -4844,7 +4952,11 @@ public function testBodyWithFileSchemaRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5068,7 +5180,11 @@ public function testBodyWithQueryParamsRequest( if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -5089,7 +5205,11 @@ public function testBodyWithQueryParamsRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5343,7 +5463,11 @@ public function testClientModelRequest( if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -5364,7 +5488,11 @@ public function testClientModelRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5794,7 +5922,11 @@ public function testEndpointParametersRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6160,7 +6292,11 @@ public function testEnumParametersRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6662,7 +6798,11 @@ public function testInlineAdditionalPropertiesRequest( if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -6683,7 +6823,11 @@ public function testInlineAdditionalPropertiesRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6890,7 +7034,11 @@ public function testInlineFreeformAdditionalPropertiesRequest( if (isset($test_inline_freeform_additional_properties_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($test_inline_freeform_additional_properties_request)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($test_inline_freeform_additional_properties_request), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $test_inline_freeform_additional_properties_request; } @@ -6911,7 +7059,11 @@ public function testInlineFreeformAdditionalPropertiesRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7158,7 +7310,11 @@ public function testJsonFormDataRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7365,7 +7521,11 @@ public function testNullableRequest( if (isset($child_with_nullable)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($child_with_nullable)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($child_with_nullable), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $child_with_nullable; } @@ -7386,7 +7546,11 @@ public function testNullableRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7640,7 +7804,11 @@ public function testOneOfRequest( if (isset($mammal)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($mammal)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($mammal), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $mammal; } @@ -7661,7 +7829,11 @@ public function testOneOfRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -8209,7 +8381,11 @@ public function testStringMapReferenceRequest( if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -8230,7 +8406,11 @@ public function testStringMapReferenceRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php index 5f80ce89bcb8..0fae81baf5ba 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeClassnameTags123Api.php @@ -349,7 +349,11 @@ public function testClassnameRequest( if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -370,7 +374,11 @@ public function testClassnameRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php index cb673129dd09..9ef367844caa 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/PetApi.php @@ -433,7 +433,11 @@ public function addPetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -454,7 +458,11 @@ public function addPetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1830,7 +1838,11 @@ public function updatePetRequest( if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1851,7 +1863,11 @@ public function updatePetRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2175,7 +2191,11 @@ public function updatePetWithFormRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2486,7 +2506,11 @@ public function uploadFileRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2803,7 +2827,11 @@ public function uploadFileWithRequiredFileRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php index e5e9d9a0c98a..181173487850 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/StoreApi.php @@ -1052,7 +1052,11 @@ public function placeOrderRequest( if (isset($order)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($order)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($order), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $order; } @@ -1073,7 +1077,11 @@ public function placeOrderRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php index b7102ec38d60..37ee7d49df21 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/UserApi.php @@ -323,7 +323,11 @@ public function createUserRequest( if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -344,7 +348,11 @@ public function createUserRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -551,7 +559,11 @@ public function createUsersWithArrayInputRequest( if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -572,7 +584,11 @@ public function createUsersWithArrayInputRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -779,7 +795,11 @@ public function createUsersWithListInputRequest( if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -800,7 +820,11 @@ public function createUsersWithListInputRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1943,7 +1967,11 @@ public function updateUserRequest( if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -1964,7 +1992,11 @@ public function updateUserRequest( } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 c41f4f330e1e..7da1c4a9fe44 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -342,7 +342,11 @@ public function call123TestSpecialTagsRequest($client, string $contentType = sel if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -363,7 +367,11 @@ public function call123TestSpecialTagsRequest($client, string $contentType = sel } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 6d69a6b6a980..dafd37702db8 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -336,7 +336,11 @@ public function fooGetRequest(string $contentType = self::contentTypes['fooGet'] } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 ab6827b48529..2a55bca6e6f0 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -423,7 +423,11 @@ public function fakeBigDecimalMapRequest(string $contentType = self::contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -734,7 +738,11 @@ public function fakeEnumEndpointRequest($enum_class, $enum_class_array, $enum_cl } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -982,7 +990,11 @@ public function fakeHealthGetRequest(string $contentType = self::contentTypes['f } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1203,7 +1215,11 @@ public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1224,7 +1240,11 @@ public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1456,7 +1476,11 @@ public function fakeOuterBooleanSerializeRequest($body = null, string $contentTy if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -1477,7 +1501,11 @@ public function fakeOuterBooleanSerializeRequest($body = null, string $contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1709,7 +1737,11 @@ public function fakeOuterCompositeSerializeRequest($outer_composite = null, stri if (isset($outer_composite)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_composite)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($outer_composite), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $outer_composite; } @@ -1730,7 +1762,11 @@ public function fakeOuterCompositeSerializeRequest($outer_composite = null, stri } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1962,7 +1998,11 @@ public function fakeOuterNumberSerializeRequest($body = null, string $contentTyp if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -1983,7 +2023,11 @@ public function fakeOuterNumberSerializeRequest($body = null, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2215,7 +2259,11 @@ public function fakeOuterStringSerializeRequest($body = null, string $contentTyp if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -2236,7 +2284,11 @@ public function fakeOuterStringSerializeRequest($body = null, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2474,7 +2526,11 @@ public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_ if (isset($outer_object_with_enum_property)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($outer_object_with_enum_property), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $outer_object_with_enum_property; } @@ -2495,7 +2551,11 @@ public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2772,7 +2832,11 @@ public function fakeWith400And4xxRangeResponseEndpointRequest($pet, string $cont if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -2793,7 +2857,11 @@ public function fakeWith400And4xxRangeResponseEndpointRequest($pet, string $cont } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3039,7 +3107,11 @@ public function fakeWith400And4xxRangeResponseNo4xxDatatypeEndpointRequest($pet, if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3060,7 +3132,11 @@ public function fakeWith400And4xxRangeResponseNo4xxDatatypeEndpointRequest($pet, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3320,7 +3396,11 @@ public function fakeWith400ResponseEndpointRequest($pet, string $contentType = s if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3341,7 +3421,11 @@ public function fakeWith400ResponseEndpointRequest($pet, string $contentType = s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3604,7 +3688,11 @@ public function fakeWith4xxRangeResponseEndpointRequest($pet, string $contentTyp if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3625,7 +3713,11 @@ public function fakeWith4xxRangeResponseEndpointRequest($pet, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3871,7 +3963,11 @@ public function fakeWith4xxRangeResponseNo4xxDatatypeEndpointRequest($pet, strin if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -3892,7 +3988,11 @@ public function fakeWith4xxRangeResponseNo4xxDatatypeEndpointRequest($pet, strin } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4180,7 +4280,11 @@ public function getParameterNameMappingRequest($underscore_type, $type, $type_wi } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4376,7 +4480,11 @@ public function testAdditionalPropertiesReferenceRequest($request_body, string $ if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -4397,7 +4505,11 @@ public function testAdditionalPropertiesReferenceRequest($request_body, string $ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4585,7 +4697,11 @@ public function testBodyWithBinaryRequest($body, string $contentType = self::con if (isset($body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $body; } @@ -4606,7 +4722,11 @@ public function testBodyWithBinaryRequest($body, string $contentType = self::con } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -4794,7 +4914,11 @@ public function testBodyWithFileSchemaRequest($file_schema_test_class, string $c if (isset($file_schema_test_class)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($file_schema_test_class), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $file_schema_test_class; } @@ -4815,7 +4939,11 @@ public function testBodyWithFileSchemaRequest($file_schema_test_class, string $c } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5024,7 +5152,11 @@ public function testBodyWithQueryParamsRequest($query, $user, string $contentTyp if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -5045,7 +5177,11 @@ public function testBodyWithQueryParamsRequest($query, $user, string $contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5291,7 +5427,11 @@ public function testClientModelRequest($client, string $contentType = self::cont if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -5312,7 +5452,11 @@ public function testClientModelRequest($client, string $contentType = self::cont } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -5679,7 +5823,11 @@ public function testEndpointParametersRequest($number, $double, $pattern_without } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6001,7 +6149,11 @@ public function testEnumParametersRequest($enum_header_string_array = null, $enu } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6315,7 +6467,11 @@ public function testGroupParametersRequest($associative_array) } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6515,7 +6671,11 @@ public function testInlineAdditionalPropertiesRequest($request_body, string $con if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -6536,7 +6696,11 @@ public function testInlineAdditionalPropertiesRequest($request_body, string $con } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6732,7 +6896,11 @@ public function testInlineFreeformAdditionalPropertiesRequest($test_inline_freef if (isset($test_inline_freeform_additional_properties_request)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($test_inline_freeform_additional_properties_request)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($test_inline_freeform_additional_properties_request), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $test_inline_freeform_additional_properties_request; } @@ -6753,7 +6921,11 @@ public function testInlineFreeformAdditionalPropertiesRequest($test_inline_freef } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -6985,7 +7157,11 @@ public function testJsonFormDataRequest($param, $param2, string $contentType = s } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7316,7 +7492,11 @@ public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -7512,7 +7692,11 @@ public function testStringMapReferenceRequest($request_body, string $contentType if (isset($request_body)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($request_body)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($request_body), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $request_body; } @@ -7533,7 +7717,11 @@ public function testStringMapReferenceRequest($request_body, string $contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 02d8553f3651..0894f328ffe5 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -342,7 +342,11 @@ public function testClassnameRequest($client, string $contentType = self::conten if (isset($client)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($client)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $client; } @@ -363,7 +367,11 @@ public function testClassnameRequest($client, string $contentType = self::conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 aeb5e541e181..514f2d498f56 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -419,7 +419,11 @@ public function addPetRequest($pet, ?int $hostIndex = null, array $variables = [ if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -440,7 +444,11 @@ public function addPetRequest($pet, ?int $hostIndex = null, array $variables = [ } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -728,7 +736,11 @@ public function deletePetRequest($pet_id, $api_key = null, string $contentType = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1001,7 +1013,11 @@ public function findPetsByStatusRequest($status, string $contentType = self::con } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1279,7 +1295,11 @@ public function findPetsByTagsRequest($tags, string $contentType = self::content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1551,7 +1571,11 @@ public function getPetByIdRequest($pet_id, string $contentType = self::contentTy } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1847,7 +1871,11 @@ public function updatePetRequest($pet, ?int $hostIndex = null, array $variables if (isset($pet)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($pet)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($pet), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $pet; } @@ -1868,7 +1896,11 @@ public function updatePetRequest($pet, ?int $hostIndex = null, array $variables } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2168,7 +2200,11 @@ public function updatePetWithFormRequest($pet_id, $name = null, $status = null, } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2463,7 +2499,11 @@ public function uploadFileRequest($pet_id, $additional_metadata = null, $file = } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -2764,7 +2804,11 @@ public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $addi } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3113,7 +3157,11 @@ public function uploadImageFullFormDataRequest($pet_id, $name, $photo_urls, $id } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -3401,7 +3449,11 @@ public function uploadImageFullFormDataNestedRequest($pet_id, $pet = null, strin } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 76f82e65b73e..6391f355679d 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -323,7 +323,11 @@ public function deleteOrderRequest($order_id, string $contentType = self::conten } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -571,7 +575,11 @@ public function getInventoryRequest(string $contentType = self::contentTypes['ge } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -850,7 +858,11 @@ public function getOrderByIdRequest($order_id, string $contentType = self::conte } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1096,7 +1108,11 @@ public function placeOrderRequest($order, string $contentType = self::contentTyp if (isset($order)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($order)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($order), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $order; } @@ -1117,7 +1133,11 @@ public function placeOrderRequest($order, string $contentType = self::contentTyp } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } 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 52c47f97fed1..8f940d027ba1 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -313,7 +313,11 @@ public function createUserRequest($user, string $contentType = self::contentType if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -334,7 +338,11 @@ public function createUserRequest($user, string $contentType = self::contentType } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -530,7 +538,11 @@ public function createUsersWithArrayInputRequest($user, string $contentType = se if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -551,7 +563,11 @@ public function createUsersWithArrayInputRequest($user, string $contentType = se } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -747,7 +763,11 @@ public function createUsersWithListInputRequest($user, string $contentType = sel if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -768,7 +788,11 @@ public function createUsersWithListInputRequest($user, string $contentType = sel } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -986,7 +1010,11 @@ public function deleteUserRequest($username, string $contentType = self::content } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1254,7 +1282,11 @@ public function getUserByNameRequest($username, string $contentType = self::cont } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1544,7 +1576,11 @@ public function loginUserRequest($username, $password, string $contentType = sel } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1742,7 +1778,11 @@ public function logoutUserRequest(string $contentType = self::contentTypes['logo } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); @@ -1958,7 +1998,11 @@ public function updateUserRequest($username, $user, string $contentType = self:: if (isset($user)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body - $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($user)); + try { + $httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($user), JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { $httpBody = $user; } @@ -1979,7 +2023,11 @@ public function updateUserRequest($username, $user, string $contentType = self:: } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + try { + $httpBody = json_encode($formParams, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e); + } } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams);