diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.php_cs b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.php_cs deleted file mode 100644 index 4fbe53ec5ff..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.php_cs +++ /dev/null @@ -1,23 +0,0 @@ -setUsingCache(true) - ->setRules([ - '@PSR2' => true, - 'ordered_imports' => true, - 'phpdoc_order' => true, - 'array_syntax' => [ 'syntax' => 'short' ], - 'strict_comparison' => true, - 'strict_param' => true, - 'no_trailing_whitespace' => false, - 'no_trailing_whitespace_in_comment' => false, - 'braces' => false, - 'single_blank_line_at_eof' => false, - 'blank_line_after_namespace' => false, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('test') - ->exclude('tests') - ->in(__DIR__) - ); diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.phplint.dist.yml b/samples/client/petstore/php-nextgen/OpenAPIClient-php/.phplint.dist.yml deleted file mode 100644 index 2c81c7a4308..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/.phplint.dist.yml +++ /dev/null @@ -1,12 +0,0 @@ -path: - - ./lib - - ./test - - ./tests -jobs: 10 -extensions: - - php -exclude: - - vendor -warning: true -memory-limit: -1 -no-cache: true diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/CatAllOf.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/CatAllOf.md deleted file mode 100644 index 3452570c1e7..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/CatAllOf.md +++ /dev/null @@ -1,9 +0,0 @@ -# # CatAllOf - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**declawed** | **bool** | | [optional] - -[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/DogAllOf.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/DogAllOf.md deleted file mode 100644 index 88effd4297b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/DogAllOf.md +++ /dev/null @@ -1,9 +0,0 @@ -# # DogAllOf - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**breed** | **string** | | [optional] - -[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/InlineResponseDefault.md b/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/InlineResponseDefault.md deleted file mode 100644 index 57ae8e09d5c..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/docs/Model/InlineResponseDefault.md +++ /dev/null @@ -1,9 +0,0 @@ -# # InlineResponseDefault - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**string** | [**\OpenAPI\Client\Model\Foo**](Foo.md) | | [optional] - -[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md) diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/AnotherFakeApi.php deleted file mode 100644 index 713a4944f64..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/AnotherFakeApi.php +++ /dev/null @@ -1,425 +0,0 @@ - [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation call123TestSpecialTags - * - * To test special tags - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Client - */ - public function call123TestSpecialTags($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) - { - list($response) = $this->call123TestSpecialTagsWithHttpInfo($client, $contentType); - return $response; - } - - /** - * Operation call123TestSpecialTagsWithHttpInfo - * - * To test special tags - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) - */ - public function call123TestSpecialTagsWithHttpInfo($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) - { - $request = $this->call123TestSpecialTagsRequest($client, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Client'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Client', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation call123TestSpecialTagsAsync - * - * To test special tags - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function call123TestSpecialTagsAsync($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) - { - return $this->call123TestSpecialTagsAsyncWithHttpInfo($client, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation call123TestSpecialTagsAsyncWithHttpInfo - * - * To test special tags - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function call123TestSpecialTagsAsyncWithHttpInfo($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) - { - $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->call123TestSpecialTagsRequest($client, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'call123TestSpecialTags' - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['call123TestSpecialTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function call123TestSpecialTagsRequest($client, string $contentType = self::contentTypes['call123TestSpecialTags'][0]) - { - - // verify the required parameter 'client' is set - if ($client === null || (is_array($client) && count($client) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $client when calling call123TestSpecialTags' - ); - } - - - $resourcePath = '/another-fake/dummy'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $client; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PATCH', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/DefaultApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/DefaultApi.php deleted file mode 100644 index 834ef80ffb1..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/DefaultApi.php +++ /dev/null @@ -1,398 +0,0 @@ - [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation fooGet - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\FooGetDefaultResponse - */ - public function fooGet(string $contentType = self::contentTypes['fooGet'][0]) - { - list($response) = $this->fooGetWithHttpInfo($contentType); - return $response; - } - - /** - * Operation fooGetWithHttpInfo - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\FooGetDefaultResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function fooGetWithHttpInfo(string $contentType = self::contentTypes['fooGet'][0]) - { - $request = $this->fooGetRequest($contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - default: - if ('\OpenAPI\Client\Model\FooGetDefaultResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\FooGetDefaultResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\FooGetDefaultResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - default: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\FooGetDefaultResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fooGetAsync - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fooGetAsync(string $contentType = self::contentTypes['fooGet'][0]) - { - return $this->fooGetAsyncWithHttpInfo($contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fooGetAsyncWithHttpInfo - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fooGetAsyncWithHttpInfo(string $contentType = self::contentTypes['fooGet'][0]) - { - $returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse'; - $request = $this->fooGetRequest($contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fooGet' - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fooGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fooGetRequest(string $contentType = self::contentTypes['fooGet'][0]) - { - - - $resourcePath = '/foo'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeApi.php deleted file mode 100644 index 6e5344684c4..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeApi.php +++ /dev/null @@ -1,4908 +0,0 @@ - [ - 'application/json', - ], - 'fakeHttpSignatureTest' => [ - 'application/json', - 'application/xml', - ], - 'fakeOuterBooleanSerialize' => [ - 'application/json', - ], - 'fakeOuterCompositeSerialize' => [ - 'application/json', - ], - 'fakeOuterNumberSerialize' => [ - 'application/json', - ], - 'fakeOuterStringSerialize' => [ - 'application/json', - ], - 'fakePropertyEnumIntegerSerialize' => [ - 'application/json', - ], - 'testBodyWithBinary' => [ - 'image/png', - ], - 'testBodyWithFileSchema' => [ - 'application/json', - ], - 'testBodyWithQueryParams' => [ - 'application/json', - ], - 'testClientModel' => [ - 'application/json', - ], - 'testEndpointParameters' => [ - 'application/x-www-form-urlencoded', - ], - 'testEnumParameters' => [ - 'application/x-www-form-urlencoded', - ], - 'testGroupParameters' => [ - 'application/json', - ], - 'testInlineAdditionalProperties' => [ - 'application/json', - ], - 'testJsonFormData' => [ - 'application/x-www-form-urlencoded', - ], - 'testQueryParameterCollectionFormat' => [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation fakeHealthGet - * - * Health check endpoint - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\HealthCheckResult - */ - public function fakeHealthGet(string $contentType = self::contentTypes['fakeHealthGet'][0]) - { - list($response) = $this->fakeHealthGetWithHttpInfo($contentType); - return $response; - } - - /** - * Operation fakeHealthGetWithHttpInfo - * - * Health check endpoint - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\HealthCheckResult, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeHealthGetWithHttpInfo(string $contentType = self::contentTypes['fakeHealthGet'][0]) - { - $request = $this->fakeHealthGetRequest($contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\HealthCheckResult' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\HealthCheckResult' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\HealthCheckResult', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\HealthCheckResult'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\HealthCheckResult', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakeHealthGetAsync - * - * Health check endpoint - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeHealthGetAsync(string $contentType = self::contentTypes['fakeHealthGet'][0]) - { - return $this->fakeHealthGetAsyncWithHttpInfo($contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeHealthGetAsyncWithHttpInfo - * - * Health check endpoint - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeHealthGetAsyncWithHttpInfo(string $contentType = self::contentTypes['fakeHealthGet'][0]) - { - $returnType = '\OpenAPI\Client\Model\HealthCheckResult'; - $request = $this->fakeHealthGetRequest($contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeHealthGet' - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHealthGet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeHealthGetRequest(string $contentType = self::contentTypes['fakeHealthGet'][0]) - { - - - $resourcePath = '/fake/health'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakeHttpSignatureTest - * - * test http signature authentication - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param string $query_1 query parameter (optional) - * @param string $header_1 header parameter (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function fakeHttpSignatureTest($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) - { - $this->fakeHttpSignatureTestWithHttpInfo($pet, $query_1, $header_1, $contentType); - } - - /** - * Operation fakeHttpSignatureTestWithHttpInfo - * - * test http signature authentication - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param string $query_1 query parameter (optional) - * @param string $header_1 header parameter (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeHttpSignatureTestWithHttpInfo($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) - { - $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation fakeHttpSignatureTestAsync - * - * test http signature authentication - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param string $query_1 query parameter (optional) - * @param string $header_1 header parameter (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeHttpSignatureTestAsync($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) - { - return $this->fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1, $header_1, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeHttpSignatureTestAsyncWithHttpInfo - * - * test http signature authentication - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param string $query_1 query parameter (optional) - * @param string $header_1 header parameter (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeHttpSignatureTestAsyncWithHttpInfo($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) - { - $returnType = ''; - $request = $this->fakeHttpSignatureTestRequest($pet, $query_1, $header_1, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeHttpSignatureTest' - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param string $query_1 query parameter (optional) - * @param string $header_1 header parameter (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeHttpSignatureTest'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeHttpSignatureTestRequest($pet, $query_1 = null, $header_1 = null, string $contentType = self::contentTypes['fakeHttpSignatureTest'][0]) - { - - // verify the required parameter 'pet' is set - if ($pet === null || (is_array($pet) && count($pet) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet when calling fakeHttpSignatureTest' - ); - } - - - - - $resourcePath = '/fake/http-signature-test'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $query_1, - 'query_1', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - // header params - if ($header_1 !== null) { - $headerParams['header_1'] = ObjectSerializer::toHeaderValue($header_1); - } - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $pet; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakeOuterBooleanSerialize - * - * @param bool $body Input boolean as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return bool - */ - public function fakeOuterBooleanSerialize($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) - { - list($response) = $this->fakeOuterBooleanSerializeWithHttpInfo($body, $contentType); - return $response; - } - - /** - * Operation fakeOuterBooleanSerializeWithHttpInfo - * - * @param bool $body Input boolean as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of bool, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeOuterBooleanSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) - { - $request = $this->fakeOuterBooleanSerializeRequest($body, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('bool' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('bool' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, 'bool', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = 'bool'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'bool', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakeOuterBooleanSerializeAsync - * - * @param bool $body Input boolean as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterBooleanSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) - { - return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeOuterBooleanSerializeAsyncWithHttpInfo - * - * @param bool $body Input boolean as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) - { - $returnType = 'bool'; - $request = $this->fakeOuterBooleanSerializeRequest($body, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeOuterBooleanSerialize' - * - * @param bool $body Input boolean as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterBooleanSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeOuterBooleanSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterBooleanSerialize'][0]) - { - - - - $resourcePath = '/fake/outer/boolean'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $body; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakeOuterCompositeSerialize - * - * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\OuterComposite - */ - public function fakeOuterCompositeSerialize($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) - { - list($response) = $this->fakeOuterCompositeSerializeWithHttpInfo($outer_composite, $contentType); - return $response; - } - - /** - * Operation fakeOuterCompositeSerializeWithHttpInfo - * - * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\OuterComposite, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeOuterCompositeSerializeWithHttpInfo($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) - { - $request = $this->fakeOuterCompositeSerializeRequest($outer_composite, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\OuterComposite' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\OuterComposite' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\OuterComposite', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\OuterComposite'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\OuterComposite', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakeOuterCompositeSerializeAsync - * - * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterCompositeSerializeAsync($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) - { - return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeOuterCompositeSerializeAsyncWithHttpInfo - * - * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) - { - $returnType = '\OpenAPI\Client\Model\OuterComposite'; - $request = $this->fakeOuterCompositeSerializeRequest($outer_composite, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeOuterCompositeSerialize' - * - * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterCompositeSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeOuterCompositeSerializeRequest($outer_composite = null, string $contentType = self::contentTypes['fakeOuterCompositeSerialize'][0]) - { - - - - $resourcePath = '/fake/outer/composite'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $outer_composite; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakeOuterNumberSerialize - * - * @param float $body Input number as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return float - */ - public function fakeOuterNumberSerialize($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) - { - list($response) = $this->fakeOuterNumberSerializeWithHttpInfo($body, $contentType); - return $response; - } - - /** - * Operation fakeOuterNumberSerializeWithHttpInfo - * - * @param float $body Input number as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of float, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeOuterNumberSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) - { - $request = $this->fakeOuterNumberSerializeRequest($body, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('float' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('float' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, 'float', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = 'float'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'float', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakeOuterNumberSerializeAsync - * - * @param float $body Input number as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterNumberSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) - { - return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeOuterNumberSerializeAsyncWithHttpInfo - * - * @param float $body Input number as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) - { - $returnType = 'float'; - $request = $this->fakeOuterNumberSerializeRequest($body, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeOuterNumberSerialize' - * - * @param float $body Input number as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterNumberSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeOuterNumberSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterNumberSerialize'][0]) - { - - - - $resourcePath = '/fake/outer/number'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $body; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakeOuterStringSerialize - * - * @param string $body Input string as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return string - */ - public function fakeOuterStringSerialize($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) - { - list($response) = $this->fakeOuterStringSerializeWithHttpInfo($body, $contentType); - return $response; - } - - /** - * Operation fakeOuterStringSerializeWithHttpInfo - * - * @param string $body Input string as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of string, HTTP status code, HTTP response headers (array of strings) - */ - public function fakeOuterStringSerializeWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) - { - $request = $this->fakeOuterStringSerializeRequest($body, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('string' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('string' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, 'string', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = 'string'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'string', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakeOuterStringSerializeAsync - * - * @param string $body Input string as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterStringSerializeAsync($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) - { - return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakeOuterStringSerializeAsyncWithHttpInfo - * - * @param string $body Input string as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) - { - $returnType = 'string'; - $request = $this->fakeOuterStringSerializeRequest($body, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakeOuterStringSerialize' - * - * @param string $body Input string as post body (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeOuterStringSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakeOuterStringSerializeRequest($body = null, string $contentType = self::contentTypes['fakeOuterStringSerialize'][0]) - { - - - - $resourcePath = '/fake/outer/string'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $body; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation fakePropertyEnumIntegerSerialize - * - * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\OuterObjectWithEnumProperty - */ - public function fakePropertyEnumIntegerSerialize($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) - { - list($response) = $this->fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property, $contentType); - return $response; - } - - /** - * Operation fakePropertyEnumIntegerSerializeWithHttpInfo - * - * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\OuterObjectWithEnumProperty, HTTP status code, HTTP response headers (array of strings) - */ - public function fakePropertyEnumIntegerSerializeWithHttpInfo($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) - { - $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\OuterObjectWithEnumProperty' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\OuterObjectWithEnumProperty' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\OuterObjectWithEnumProperty', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\OuterObjectWithEnumProperty'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\OuterObjectWithEnumProperty', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation fakePropertyEnumIntegerSerializeAsync - * - * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakePropertyEnumIntegerSerializeAsync($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) - { - return $this->fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation fakePropertyEnumIntegerSerializeAsyncWithHttpInfo - * - * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function fakePropertyEnumIntegerSerializeAsyncWithHttpInfo($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) - { - $returnType = '\OpenAPI\Client\Model\OuterObjectWithEnumProperty'; - $request = $this->fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'fakePropertyEnumIntegerSerialize' - * - * @param \OpenAPI\Client\Model\OuterObjectWithEnumProperty $outer_object_with_enum_property Input enum (int) as post body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakePropertyEnumIntegerSerialize'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function fakePropertyEnumIntegerSerializeRequest($outer_object_with_enum_property, string $contentType = self::contentTypes['fakePropertyEnumIntegerSerialize'][0]) - { - - // verify the required parameter 'outer_object_with_enum_property' is set - if ($outer_object_with_enum_property === null || (is_array($outer_object_with_enum_property) && count($outer_object_with_enum_property) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $outer_object_with_enum_property when calling fakePropertyEnumIntegerSerialize' - ); - } - - - $resourcePath = '/fake/property/enum-int'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['*/*', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $outer_object_with_enum_property; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testBodyWithBinary - * - * @param \SplFileObject $body image to upload (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testBodyWithBinary($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) - { - $this->testBodyWithBinaryWithHttpInfo($body, $contentType); - } - - /** - * Operation testBodyWithBinaryWithHttpInfo - * - * @param \SplFileObject $body image to upload (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testBodyWithBinaryWithHttpInfo($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) - { - $request = $this->testBodyWithBinaryRequest($body, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testBodyWithBinaryAsync - * - * @param \SplFileObject $body image to upload (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithBinaryAsync($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) - { - return $this->testBodyWithBinaryAsyncWithHttpInfo($body, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testBodyWithBinaryAsyncWithHttpInfo - * - * @param \SplFileObject $body image to upload (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithBinaryAsyncWithHttpInfo($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) - { - $returnType = ''; - $request = $this->testBodyWithBinaryRequest($body, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testBodyWithBinary' - * - * @param \SplFileObject $body image to upload (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testBodyWithBinaryRequest($body, string $contentType = self::contentTypes['testBodyWithBinary'][0]) - { - - // verify the required parameter 'body' is set - if ($body === null || (is_array($body) && count($body) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $body when calling testBodyWithBinary' - ); - } - - - $resourcePath = '/fake/body-with-binary'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $body; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testBodyWithFileSchema - * - * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class file_schema_test_class (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testBodyWithFileSchema($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) - { - $this->testBodyWithFileSchemaWithHttpInfo($file_schema_test_class, $contentType); - } - - /** - * Operation testBodyWithFileSchemaWithHttpInfo - * - * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testBodyWithFileSchemaWithHttpInfo($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) - { - $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testBodyWithFileSchemaAsync - * - * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithFileSchemaAsync($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) - { - return $this->testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testBodyWithFileSchemaAsyncWithHttpInfo - * - * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithFileSchemaAsyncWithHttpInfo($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) - { - $returnType = ''; - $request = $this->testBodyWithFileSchemaRequest($file_schema_test_class, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testBodyWithFileSchema' - * - * @param \OpenAPI\Client\Model\FileSchemaTestClass $file_schema_test_class (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithFileSchema'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testBodyWithFileSchemaRequest($file_schema_test_class, string $contentType = self::contentTypes['testBodyWithFileSchema'][0]) - { - - // verify the required parameter 'file_schema_test_class' is set - if ($file_schema_test_class === null || (is_array($file_schema_test_class) && count($file_schema_test_class) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $file_schema_test_class when calling testBodyWithFileSchema' - ); - } - - - $resourcePath = '/fake/body-with-file-schema'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $file_schema_test_class; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testBodyWithQueryParams - * - * @param string $query query (required) - * @param \OpenAPI\Client\Model\User $user user (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testBodyWithQueryParams($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) - { - $this->testBodyWithQueryParamsWithHttpInfo($query, $user, $contentType); - } - - /** - * Operation testBodyWithQueryParamsWithHttpInfo - * - * @param string $query (required) - * @param \OpenAPI\Client\Model\User $user (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testBodyWithQueryParamsWithHttpInfo($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) - { - $request = $this->testBodyWithQueryParamsRequest($query, $user, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testBodyWithQueryParamsAsync - * - * @param string $query (required) - * @param \OpenAPI\Client\Model\User $user (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithQueryParamsAsync($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) - { - return $this->testBodyWithQueryParamsAsyncWithHttpInfo($query, $user, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testBodyWithQueryParamsAsyncWithHttpInfo - * - * @param string $query (required) - * @param \OpenAPI\Client\Model\User $user (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testBodyWithQueryParamsAsyncWithHttpInfo($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) - { - $returnType = ''; - $request = $this->testBodyWithQueryParamsRequest($query, $user, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testBodyWithQueryParams' - * - * @param string $query (required) - * @param \OpenAPI\Client\Model\User $user (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithQueryParams'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testBodyWithQueryParamsRequest($query, $user, string $contentType = self::contentTypes['testBodyWithQueryParams'][0]) - { - - // verify the required parameter 'query' is set - if ($query === null || (is_array($query) && count($query) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $query when calling testBodyWithQueryParams' - ); - } - - // verify the required parameter 'user' is set - if ($user === null || (is_array($user) && count($user) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $user when calling testBodyWithQueryParams' - ); - } - - - $resourcePath = '/fake/body-with-query-params'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $query, - 'query', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $user; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testClientModel - * - * To test \"client\" model - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Client - */ - public function testClientModel($client, string $contentType = self::contentTypes['testClientModel'][0]) - { - list($response) = $this->testClientModelWithHttpInfo($client, $contentType); - return $response; - } - - /** - * Operation testClientModelWithHttpInfo - * - * To test \"client\" model - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) - */ - public function testClientModelWithHttpInfo($client, string $contentType = self::contentTypes['testClientModel'][0]) - { - $request = $this->testClientModelRequest($client, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Client'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Client', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation testClientModelAsync - * - * To test \"client\" model - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testClientModelAsync($client, string $contentType = self::contentTypes['testClientModel'][0]) - { - return $this->testClientModelAsyncWithHttpInfo($client, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testClientModelAsyncWithHttpInfo - * - * To test \"client\" model - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testClientModelAsyncWithHttpInfo($client, string $contentType = self::contentTypes['testClientModel'][0]) - { - $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->testClientModelRequest($client, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testClientModel' - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClientModel'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testClientModelRequest($client, string $contentType = self::contentTypes['testClientModel'][0]) - { - - // verify the required parameter 'client' is set - if ($client === null || (is_array($client) && count($client) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $client when calling testClientModel' - ); - } - - - $resourcePath = '/fake'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $client; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PATCH', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testEndpointParameters - * - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param float $number None (required) - * @param float $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param \SplFileObject $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) - { - $this->testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); - } - - /** - * Operation testEndpointParametersWithHttpInfo - * - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param float $number None (required) - * @param float $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param \SplFileObject $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) - { - $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testEndpointParametersAsync - * - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param float $number None (required) - * @param float $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param \SplFileObject $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testEndpointParametersAsync($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) - { - return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testEndpointParametersAsyncWithHttpInfo - * - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * - * @param float $number None (required) - * @param float $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param \SplFileObject $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) - { - $returnType = ''; - $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testEndpointParameters' - * - * @param float $number None (required) - * @param float $double None (required) - * @param string $pattern_without_delimiter None (required) - * @param string $byte None (required) - * @param int $integer None (optional) - * @param int $int32 None (optional) - * @param int $int64 None (optional) - * @param float $float None (optional) - * @param string $string None (optional) - * @param \SplFileObject $binary None (optional) - * @param \DateTime $date None (optional) - * @param \DateTime $date_time None (optional) - * @param string $password None (optional) - * @param string $callback None (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEndpointParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer = null, $int32 = null, $int64 = null, $float = null, $string = null, $binary = null, $date = null, $date_time = null, $password = null, $callback = null, string $contentType = self::contentTypes['testEndpointParameters'][0]) - { - - // verify the required parameter 'number' is set - if ($number === null || (is_array($number) && count($number) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $number when calling testEndpointParameters' - ); - } - if ($number > 543.2) { - throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 543.2.'); - } - if ($number < 32.1) { - throw new \InvalidArgumentException('invalid value for "$number" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 32.1.'); - } - - // verify the required parameter 'double' is set - if ($double === null || (is_array($double) && count($double) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $double when calling testEndpointParameters' - ); - } - if ($double > 123.4) { - throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 123.4.'); - } - if ($double < 67.8) { - throw new \InvalidArgumentException('invalid value for "$double" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 67.8.'); - } - - // verify the required parameter 'pattern_without_delimiter' is set - if ($pattern_without_delimiter === null || (is_array($pattern_without_delimiter) && count($pattern_without_delimiter) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pattern_without_delimiter when calling testEndpointParameters' - ); - } - if (!preg_match("/^[A-Z].*/", $pattern_without_delimiter)) { - throw new \InvalidArgumentException("invalid value for \"pattern_without_delimiter\" when calling FakeApi.testEndpointParameters, must conform to the pattern /^[A-Z].*/."); - } - - // verify the required parameter 'byte' is set - if ($byte === null || (is_array($byte) && count($byte) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $byte when calling testEndpointParameters' - ); - } - - if ($integer !== null && $integer > 100) { - throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 100.'); - } - if ($integer !== null && $integer < 10) { - throw new \InvalidArgumentException('invalid value for "$integer" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); - } - - if ($int32 !== null && $int32 > 200) { - throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 200.'); - } - if ($int32 !== null && $int32 < 20) { - throw new \InvalidArgumentException('invalid value for "$int32" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 20.'); - } - - - if ($float !== null && $float > 987.6) { - throw new \InvalidArgumentException('invalid value for "$float" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 987.6.'); - } - - if ($string !== null && !preg_match("/[a-z]/i", $string)) { - throw new \InvalidArgumentException("invalid value for \"string\" when calling FakeApi.testEndpointParameters, must conform to the pattern /[a-z]/i."); - } - - - - - if ($password !== null && strlen($password) > 64) { - throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be smaller than or equal to 64.'); - } - if ($password !== null && strlen($password) < 10) { - throw new \InvalidArgumentException('invalid length for "$password" when calling FakeApi.testEndpointParameters, must be bigger than or equal to 10.'); - } - - - - $resourcePath = '/fake'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - if ($integer !== null) { - $formParams['integer'] = ObjectSerializer::toFormValue($integer); - } - // form params - if ($int32 !== null) { - $formParams['int32'] = ObjectSerializer::toFormValue($int32); - } - // form params - if ($int64 !== null) { - $formParams['int64'] = ObjectSerializer::toFormValue($int64); - } - // form params - if ($number !== null) { - $formParams['number'] = ObjectSerializer::toFormValue($number); - } - // form params - if ($float !== null) { - $formParams['float'] = ObjectSerializer::toFormValue($float); - } - // form params - if ($double !== null) { - $formParams['double'] = ObjectSerializer::toFormValue($double); - } - // form params - if ($string !== null) { - $formParams['string'] = ObjectSerializer::toFormValue($string); - } - // form params - if ($pattern_without_delimiter !== null) { - $formParams['pattern_without_delimiter'] = ObjectSerializer::toFormValue($pattern_without_delimiter); - } - // form params - if ($byte !== null) { - $formParams['byte'] = ObjectSerializer::toFormValue($byte); - } - // form params - if ($binary !== null) { - $multipart = true; - $formParams['binary'] = []; - $paramFiles = is_array($binary) ? $binary : [$binary]; - foreach ($paramFiles as $paramFile) { - $formParams['binary'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } - // form params - if ($date !== null) { - $formParams['date'] = ObjectSerializer::toFormValue($date); - } - // form params - if ($date_time !== null) { - $formParams['dateTime'] = ObjectSerializer::toFormValue($date_time); - } - // form params - if ($password !== null) { - $formParams['password'] = ObjectSerializer::toFormValue($password); - } - // form params - if ($callback !== null) { - $formParams['callback'] = ObjectSerializer::toFormValue($callback); - } - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires HTTP basic authentication - if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { - $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testEnumParameters - * - * To test enum parameters - * - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to '-efg') - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to '-efg') - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param float $enum_query_double Query parameter enum test (double) (optional) - * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array enum_query_model_array (optional) - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') - * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testEnumParameters($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) - { - $this->testEnumParametersWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); - } - - /** - * Operation testEnumParametersWithHttpInfo - * - * To test enum parameters - * - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to '-efg') - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to '-efg') - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param float $enum_query_double Query parameter enum test (double) (optional) - * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') - * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testEnumParametersWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) - { - $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testEnumParametersAsync - * - * To test enum parameters - * - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to '-efg') - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to '-efg') - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param float $enum_query_double Query parameter enum test (double) (optional) - * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') - * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testEnumParametersAsync($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) - { - return $this->testEnumParametersAsyncWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testEnumParametersAsyncWithHttpInfo - * - * To test enum parameters - * - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to '-efg') - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to '-efg') - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param float $enum_query_double Query parameter enum test (double) (optional) - * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') - * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testEnumParametersAsyncWithHttpInfo($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) - { - $returnType = ''; - $request = $this->testEnumParametersRequest($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_query_model_array, $enum_form_string_array, $enum_form_string, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testEnumParameters' - * - * @param string[] $enum_header_string_array Header parameter enum test (string array) (optional) - * @param string $enum_header_string Header parameter enum test (string) (optional, default to '-efg') - * @param string[] $enum_query_string_array Query parameter enum test (string array) (optional) - * @param string $enum_query_string Query parameter enum test (string) (optional, default to '-efg') - * @param int $enum_query_integer Query parameter enum test (double) (optional) - * @param float $enum_query_double Query parameter enum test (double) (optional) - * @param \OpenAPI\Client\Model\EnumClass[] $enum_query_model_array (optional) - * @param string[] $enum_form_string_array Form parameter enum test (string array) (optional, default to '$') - * @param string $enum_form_string Form parameter enum test (string) (optional, default to '-efg') - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testEnumParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testEnumParametersRequest($enum_header_string_array = null, $enum_header_string = '-efg', $enum_query_string_array = null, $enum_query_string = '-efg', $enum_query_integer = null, $enum_query_double = null, $enum_query_model_array = null, $enum_form_string_array = '$', $enum_form_string = '-efg', string $contentType = self::contentTypes['testEnumParameters'][0]) - { - - - - - - - - - - - - $resourcePath = '/fake'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_query_string_array, - 'enum_query_string_array', // param base name - 'array', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_query_string, - 'enum_query_string', // param base name - 'string', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_query_integer, - 'enum_query_integer', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_query_double, - 'enum_query_double', // param base name - 'number', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_query_model_array, - 'enum_query_model_array', // param base name - 'array', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - // header params - if (is_array($enum_header_string_array)) { - $enum_header_string_array = ObjectSerializer::serializeCollection($enum_header_string_array, 'csv'); - } - if ($enum_header_string_array !== null) { - $headerParams['enum_header_string_array'] = ObjectSerializer::toHeaderValue($enum_header_string_array); - } - // header params - if ($enum_header_string !== null) { - $headerParams['enum_header_string'] = ObjectSerializer::toHeaderValue($enum_header_string); - } - - - // form params - if ($enum_form_string_array !== null) { - $formParams['enum_form_string_array'] = ObjectSerializer::toFormValue($enum_form_string_array); - } - // form params - if ($enum_form_string !== null) { - $formParams['enum_form_string'] = ObjectSerializer::toFormValue($enum_form_string); - } - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testGroupParameters - * - * Fake endpoint to test group parameters (optional) - * - * Note: the input parameter is an associative array with the keys listed as the parameter name below - * - * @param int $required_string_group Required String in group parameters (required) - * @param bool $required_boolean_group Required Boolean in group parameters (required) - * @param int $required_int64_group Required Integer in group parameters (required) - * @param int $string_group String in group parameters (optional) - * @param bool $boolean_group Boolean in group parameters (optional) - * @param int $int64_group Integer in group parameters (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testGroupParameters($associative_array) - { - $this->testGroupParametersWithHttpInfo($associative_array); - } - - /** - * Operation testGroupParametersWithHttpInfo - * - * Fake endpoint to test group parameters (optional) - * - * Note: the input parameter is an associative array with the keys listed as the parameter name below - * - * @param int $required_string_group Required String in group parameters (required) - * @param bool $required_boolean_group Required Boolean in group parameters (required) - * @param int $required_int64_group Required Integer in group parameters (required) - * @param int $string_group String in group parameters (optional) - * @param bool $boolean_group Boolean in group parameters (optional) - * @param int $int64_group Integer in group parameters (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testGroupParametersWithHttpInfo($associative_array) - { - $request = $this->testGroupParametersRequest($associative_array); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testGroupParametersAsync - * - * Fake endpoint to test group parameters (optional) - * - * Note: the input parameter is an associative array with the keys listed as the parameter name below - * - * @param int $required_string_group Required String in group parameters (required) - * @param bool $required_boolean_group Required Boolean in group parameters (required) - * @param int $required_int64_group Required Integer in group parameters (required) - * @param int $string_group String in group parameters (optional) - * @param bool $boolean_group Boolean in group parameters (optional) - * @param int $int64_group Integer in group parameters (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testGroupParametersAsync($associative_array) - { - return $this->testGroupParametersAsyncWithHttpInfo($associative_array) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testGroupParametersAsyncWithHttpInfo - * - * Fake endpoint to test group parameters (optional) - * - * Note: the input parameter is an associative array with the keys listed as the parameter name below - * - * @param int $required_string_group Required String in group parameters (required) - * @param bool $required_boolean_group Required Boolean in group parameters (required) - * @param int $required_int64_group Required Integer in group parameters (required) - * @param int $string_group String in group parameters (optional) - * @param bool $boolean_group Boolean in group parameters (optional) - * @param int $int64_group Integer in group parameters (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testGroupParametersAsyncWithHttpInfo($associative_array) - { - $returnType = ''; - $request = $this->testGroupParametersRequest($associative_array); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testGroupParameters' - * - * Note: the input parameter is an associative array with the keys listed as the parameter name below - * - * @param int $required_string_group Required String in group parameters (required) - * @param bool $required_boolean_group Required Boolean in group parameters (required) - * @param int $required_int64_group Required Integer in group parameters (required) - * @param int $string_group String in group parameters (optional) - * @param bool $boolean_group Boolean in group parameters (optional) - * @param int $int64_group Integer in group parameters (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testGroupParameters'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testGroupParametersRequest($associative_array) - { - // unbox the parameters from the associative array - $required_string_group = array_key_exists('required_string_group', $associative_array) ? $associative_array['required_string_group'] : null; - $required_boolean_group = array_key_exists('required_boolean_group', $associative_array) ? $associative_array['required_boolean_group'] : null; - $required_int64_group = array_key_exists('required_int64_group', $associative_array) ? $associative_array['required_int64_group'] : null; - $string_group = array_key_exists('string_group', $associative_array) ? $associative_array['string_group'] : null; - $boolean_group = array_key_exists('boolean_group', $associative_array) ? $associative_array['boolean_group'] : null; - $int64_group = array_key_exists('int64_group', $associative_array) ? $associative_array['int64_group'] : null; - $contentType = $associative_array['contentType'] ?? self::contentTypes['testGroupParameters'][0]; - - // verify the required parameter 'required_string_group' is set - if ($required_string_group === null || (is_array($required_string_group) && count($required_string_group) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $required_string_group when calling testGroupParameters' - ); - } - - // verify the required parameter 'required_boolean_group' is set - if ($required_boolean_group === null || (is_array($required_boolean_group) && count($required_boolean_group) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $required_boolean_group when calling testGroupParameters' - ); - } - - // verify the required parameter 'required_int64_group' is set - if ($required_int64_group === null || (is_array($required_int64_group) && count($required_int64_group) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $required_int64_group when calling testGroupParameters' - ); - } - - - - - - $resourcePath = '/fake'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $required_string_group, - 'required_string_group', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $required_int64_group, - 'required_int64_group', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $string_group, - 'string_group', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $int64_group, - 'int64_group', // param base name - 'integer', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - - // header params - if ($required_boolean_group !== null) { - $headerParams['required_boolean_group'] = ObjectSerializer::toHeaderValue($required_boolean_group); - } - // header params - if ($boolean_group !== null) { - $headerParams['boolean_group'] = ObjectSerializer::toHeaderValue($boolean_group); - } - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires Bearer (JWT) authentication (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'DELETE', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testInlineAdditionalProperties - * - * test inline additionalProperties - * - * @param array $request_body request body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testInlineAdditionalProperties($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) - { - $this->testInlineAdditionalPropertiesWithHttpInfo($request_body, $contentType); - } - - /** - * Operation testInlineAdditionalPropertiesWithHttpInfo - * - * test inline additionalProperties - * - * @param array $request_body request body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testInlineAdditionalPropertiesWithHttpInfo($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) - { - $request = $this->testInlineAdditionalPropertiesRequest($request_body, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testInlineAdditionalPropertiesAsync - * - * test inline additionalProperties - * - * @param array $request_body request body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testInlineAdditionalPropertiesAsync($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) - { - return $this->testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testInlineAdditionalPropertiesAsyncWithHttpInfo - * - * test inline additionalProperties - * - * @param array $request_body request body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) - { - $returnType = ''; - $request = $this->testInlineAdditionalPropertiesRequest($request_body, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testInlineAdditionalProperties' - * - * @param array $request_body request body (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testInlineAdditionalProperties'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testInlineAdditionalPropertiesRequest($request_body, string $contentType = self::contentTypes['testInlineAdditionalProperties'][0]) - { - - // verify the required parameter 'request_body' is set - if ($request_body === null || (is_array($request_body) && count($request_body) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $request_body when calling testInlineAdditionalProperties' - ); - } - - - $resourcePath = '/fake/inline-additionalProperties'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $request_body; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testJsonFormData - * - * test json serialization of form data - * - * @param string $param field1 (required) - * @param string $param2 field2 (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testJsonFormData($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) - { - $this->testJsonFormDataWithHttpInfo($param, $param2, $contentType); - } - - /** - * Operation testJsonFormDataWithHttpInfo - * - * test json serialization of form data - * - * @param string $param field1 (required) - * @param string $param2 field2 (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testJsonFormDataWithHttpInfo($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) - { - $request = $this->testJsonFormDataRequest($param, $param2, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testJsonFormDataAsync - * - * test json serialization of form data - * - * @param string $param field1 (required) - * @param string $param2 field2 (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testJsonFormDataAsync($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) - { - return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testJsonFormDataAsyncWithHttpInfo - * - * test json serialization of form data - * - * @param string $param field1 (required) - * @param string $param2 field2 (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testJsonFormDataAsyncWithHttpInfo($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) - { - $returnType = ''; - $request = $this->testJsonFormDataRequest($param, $param2, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testJsonFormData' - * - * @param string $param field1 (required) - * @param string $param2 field2 (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testJsonFormData'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testJsonFormDataRequest($param, $param2, string $contentType = self::contentTypes['testJsonFormData'][0]) - { - - // verify the required parameter 'param' is set - if ($param === null || (is_array($param) && count($param) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $param when calling testJsonFormData' - ); - } - - // verify the required parameter 'param2' is set - if ($param2 === null || (is_array($param2) && count($param2) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $param2 when calling testJsonFormData' - ); - } - - - $resourcePath = '/fake/jsonFormData'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - // form params - if ($param !== null) { - $formParams['param'] = ObjectSerializer::toFormValue($param); - } - // form params - if ($param2 !== null) { - $formParams['param2'] = ObjectSerializer::toFormValue($param2); - } - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation testQueryParameterCollectionFormat - * - * @param string[] $pipe pipe (required) - * @param string[] $ioutil ioutil (required) - * @param string[] $http http (required) - * @param string[] $url url (required) - * @param string[] $context context (required) - * @param string $allow_empty allow_empty (required) - * @param array $language language (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testQueryParameterCollectionFormat($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) - { - $this->testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); - } - - /** - * Operation testQueryParameterCollectionFormatWithHttpInfo - * - * @param string[] $pipe (required) - * @param string[] $ioutil (required) - * @param string[] $http (required) - * @param string[] $url (required) - * @param string[] $context (required) - * @param string $allow_empty (required) - * @param array $language (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testQueryParameterCollectionFormatWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) - { - $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation testQueryParameterCollectionFormatAsync - * - * @param string[] $pipe (required) - * @param string[] $ioutil (required) - * @param string[] $http (required) - * @param string[] $url (required) - * @param string[] $context (required) - * @param string $allow_empty (required) - * @param array $language (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testQueryParameterCollectionFormatAsync($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) - { - return $this->testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testQueryParameterCollectionFormatAsyncWithHttpInfo - * - * @param string[] $pipe (required) - * @param string[] $ioutil (required) - * @param string[] $http (required) - * @param string[] $url (required) - * @param string[] $context (required) - * @param string $allow_empty (required) - * @param array $language (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testQueryParameterCollectionFormatAsyncWithHttpInfo($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) - { - $returnType = ''; - $request = $this->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testQueryParameterCollectionFormat' - * - * @param string[] $pipe (required) - * @param string[] $ioutil (required) - * @param string[] $http (required) - * @param string[] $url (required) - * @param string[] $context (required) - * @param string $allow_empty (required) - * @param array $language (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testQueryParameterCollectionFormat'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language = null, string $contentType = self::contentTypes['testQueryParameterCollectionFormat'][0]) - { - - // verify the required parameter 'pipe' is set - if ($pipe === null || (is_array($pipe) && count($pipe) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pipe when calling testQueryParameterCollectionFormat' - ); - } - - // verify the required parameter 'ioutil' is set - if ($ioutil === null || (is_array($ioutil) && count($ioutil) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $ioutil when calling testQueryParameterCollectionFormat' - ); - } - - // verify the required parameter 'http' is set - if ($http === null || (is_array($http) && count($http) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $http when calling testQueryParameterCollectionFormat' - ); - } - - // verify the required parameter 'url' is set - if ($url === null || (is_array($url) && count($url) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $url when calling testQueryParameterCollectionFormat' - ); - } - - // verify the required parameter 'context' is set - if ($context === null || (is_array($context) && count($context) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $context when calling testQueryParameterCollectionFormat' - ); - } - - // verify the required parameter 'allow_empty' is set - if ($allow_empty === null || (is_array($allow_empty) && count($allow_empty) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $allow_empty when calling testQueryParameterCollectionFormat' - ); - } - - - - $resourcePath = '/fake/test-query-parameters'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $pipe, - 'pipe', // param base name - 'array', // openApiType - 'pipeDelimited', // style - false, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $ioutil, - 'ioutil', // param base name - 'array', // openApiType - 'form', // style - false, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $http, - 'http', // param base name - 'array', // openApiType - 'spaceDelimited', // style - false, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $url, - 'url', // param base name - 'array', // openApiType - 'form', // style - false, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $context, - 'context', // param base name - 'array', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $language, - 'language', // param base name - 'object', // openApiType - 'form', // style - true, // explode - false // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $allow_empty, - 'allowEmpty', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php deleted file mode 100644 index 131ded35741..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php +++ /dev/null @@ -1,430 +0,0 @@ - [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation testClassname - * - * To test class name in snake case - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Client - */ - public function testClassname($client, string $contentType = self::contentTypes['testClassname'][0]) - { - list($response) = $this->testClassnameWithHttpInfo($client, $contentType); - return $response; - } - - /** - * Operation testClassnameWithHttpInfo - * - * To test class name in snake case - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings) - */ - public function testClassnameWithHttpInfo($client, string $contentType = self::contentTypes['testClassname'][0]) - { - $request = $this->testClassnameRequest($client, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Client' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Client'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Client', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation testClassnameAsync - * - * To test class name in snake case - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testClassnameAsync($client, string $contentType = self::contentTypes['testClassname'][0]) - { - return $this->testClassnameAsyncWithHttpInfo($client, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testClassnameAsyncWithHttpInfo - * - * To test class name in snake case - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testClassnameAsyncWithHttpInfo($client, string $contentType = self::contentTypes['testClassname'][0]) - { - $returnType = '\OpenAPI\Client\Model\Client'; - $request = $this->testClassnameRequest($client, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'testClassname' - * - * @param \OpenAPI\Client\Model\Client $client client model (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['testClassname'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function testClassnameRequest($client, string $contentType = self::contentTypes['testClassname'][0]) - { - - // verify the required parameter 'client' is set - if ($client === null || (is_array($client) && count($client) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $client when calling testClassname' - ); - } - - - $resourcePath = '/fake_classname_test'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $client; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api_key_query'); - if ($apiKey !== null) { - $queryParams['api_key_query'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PATCH', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/PetApi.php deleted file mode 100644 index d75d7f469be..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/PetApi.php +++ /dev/null @@ -1,2918 +0,0 @@ - [ - 'application/json', - 'application/xml', - ], - 'deletePet' => [ - 'application/json', - ], - 'findPetsByStatus' => [ - 'application/json', - ], - 'findPetsByTags' => [ - 'application/json', - ], - 'getPetById' => [ - 'application/json', - ], - 'updatePet' => [ - 'application/json', - 'application/xml', - ], - 'updatePetWithForm' => [ - 'application/x-www-form-urlencoded', - ], - 'uploadFile' => [ - 'multipart/form-data', - ], - 'uploadFileWithRequiredFile' => [ - 'multipart/form-data', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation addPet - * - * Add a new pet to the store - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function addPet($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) - { - $this->addPetWithHttpInfo($pet, $hostIndex, $variables, $contentType); - } - - /** - * Operation addPetWithHttpInfo - * - * Add a new pet to the store - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function addPetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) - { - $request = $this->addPetRequest($pet, $hostIndex, $variables, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation addPetAsync - * - * Add a new pet to the store - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function addPetAsync($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) - { - return $this->addPetAsyncWithHttpInfo($pet, $hostIndex, $variables, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation addPetAsyncWithHttpInfo - * - * Add a new pet to the store - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function addPetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) - { - $returnType = ''; - $request = $this->addPetRequest($pet, $hostIndex, $variables, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'addPet' - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['addPet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function addPetRequest($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['addPet'][0]) - { - - // verify the required parameter 'pet' is set - if ($pet === null || (is_array($pet) && count($pet) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet when calling addPet' - ); - } - - - $resourcePath = '/pet'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $pet; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - # Preserve the original behavior of server indexing. - if ($hostIndex === null) { - $hostIndex = $this->hostIndex; - } - - $hostSettings = $this->getHostSettingsForaddPet(); - - if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { - throw new \InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings)); - } - $operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Returns an array of host settings for Operation addPet - * - * @return array an array of host settings - */ - protected function getHostSettingsForaddPet(): array - { - return [ - [ - "url" => "http://petstore.swagger.io/v2", - "description" => "No description provided", - ], - [ - "url" => "http://path-server-test.petstore.local/v2", - "description" => "No description provided", - ], - [ - "url" => "http://{server}.swagger.io:{port}/v2", - "description" => "test server with variables", - "variables" => [ - "server" => [ - "description" => "target server", - "default_value" => "petstore", - "enum_values" => [ - "petstore", - "qa-petstore", - "dev-petstore", - ] - ], - "port" => [ - "description" => "No description provided", - "default_value" => "80", - "enum_values" => [ - "80", - "8080", - ] - ] - ] - ] - ]; - } - - /** - * Operation deletePet - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key api_key (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function deletePet($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) - { - $this->deletePetWithHttpInfo($pet_id, $api_key, $contentType); - } - - /** - * Operation deletePetWithHttpInfo - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function deletePetWithHttpInfo($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) - { - $request = $this->deletePetRequest($pet_id, $api_key, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation deletePetAsync - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deletePetAsync($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) - { - return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation deletePetAsyncWithHttpInfo - * - * Deletes a pet - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) - { - $returnType = ''; - $request = $this->deletePetRequest($pet_id, $api_key, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'deletePet' - * - * @param int $pet_id Pet id to delete (required) - * @param string $api_key (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deletePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function deletePetRequest($pet_id, $api_key = null, string $contentType = self::contentTypes['deletePet'][0]) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet_id when calling deletePet' - ); - } - - - - $resourcePath = '/pet/{petId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - // header params - if ($api_key !== null) { - $headerParams['api_key'] = ObjectSerializer::toHeaderValue($api_key); - } - - // path params - if ($pet_id !== null) { - $resourcePath = str_replace( - '{' . 'petId' . '}', - ObjectSerializer::toPathValue($pet_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'DELETE', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation findPetsByStatus - * - * Finds Pets by status - * - * @param string[] $status Status values that need to be considered for filter (required) (deprecated) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Pet[] - */ - public function findPetsByStatus($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) - { - list($response) = $this->findPetsByStatusWithHttpInfo($status, $contentType); - return $response; - } - - /** - * Operation findPetsByStatusWithHttpInfo - * - * Finds Pets by status - * - * @param string[] $status Status values that need to be considered for filter (required) (deprecated) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) - */ - public function findPetsByStatusWithHttpInfo($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) - { - $request = $this->findPetsByStatusRequest($status, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Pet[]' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet[]', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Pet[]'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Pet[]', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation findPetsByStatusAsync - * - * Finds Pets by status - * - * @param string[] $status Status values that need to be considered for filter (required) (deprecated) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function findPetsByStatusAsync($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) - { - return $this->findPetsByStatusAsyncWithHttpInfo($status, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation findPetsByStatusAsyncWithHttpInfo - * - * Finds Pets by status - * - * @param string[] $status Status values that need to be considered for filter (required) (deprecated) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function findPetsByStatusAsyncWithHttpInfo($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) - { - $returnType = '\OpenAPI\Client\Model\Pet[]'; - $request = $this->findPetsByStatusRequest($status, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'findPetsByStatus' - * - * @param string[] $status Status values that need to be considered for filter (required) (deprecated) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByStatus'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function findPetsByStatusRequest($status, string $contentType = self::contentTypes['findPetsByStatus'][0]) - { - - // verify the required parameter 'status' is set - if ($status === null || (is_array($status) && count($status) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $status when calling findPetsByStatus' - ); - } - - - $resourcePath = '/pet/findByStatus'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $status, - 'status', // param base name - 'array', // openApiType - 'form', // style - false, // explode - true // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation findPetsByTags - * - * Finds Pets by tags - * - * @param string[] $tags Tags to filter by (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Pet[] - * @deprecated - */ - public function findPetsByTags($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) - { - list($response) = $this->findPetsByTagsWithHttpInfo($tags, $contentType); - return $response; - } - - /** - * Operation findPetsByTagsWithHttpInfo - * - * Finds Pets by tags - * - * @param string[] $tags Tags to filter by (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings) - * @deprecated - */ - public function findPetsByTagsWithHttpInfo($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) - { - $request = $this->findPetsByTagsRequest($tags, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Pet[]' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Pet[]' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet[]', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Pet[]'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Pet[]', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation findPetsByTagsAsync - * - * Finds Pets by tags - * - * @param string[] $tags Tags to filter by (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - * @deprecated - */ - public function findPetsByTagsAsync($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) - { - return $this->findPetsByTagsAsyncWithHttpInfo($tags, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation findPetsByTagsAsyncWithHttpInfo - * - * Finds Pets by tags - * - * @param string[] $tags Tags to filter by (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - * @deprecated - */ - public function findPetsByTagsAsyncWithHttpInfo($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) - { - $returnType = '\OpenAPI\Client\Model\Pet[]'; - $request = $this->findPetsByTagsRequest($tags, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'findPetsByTags' - * - * @param string[] $tags Tags to filter by (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['findPetsByTags'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - * @deprecated - */ - public function findPetsByTagsRequest($tags, string $contentType = self::contentTypes['findPetsByTags'][0]) - { - - // verify the required parameter 'tags' is set - if ($tags === null || (is_array($tags) && count($tags) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $tags when calling findPetsByTags' - ); - } - - - $resourcePath = '/pet/findByTags'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $tags, - 'tags', // param base name - 'array', // openApiType - 'form', // style - false, // explode - true // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getPetById - * - * Find pet by ID - * - * @param int $pet_id ID of pet to return (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Pet - */ - public function getPetById($pet_id, string $contentType = self::contentTypes['getPetById'][0]) - { - list($response) = $this->getPetByIdWithHttpInfo($pet_id, $contentType); - return $response; - } - - /** - * Operation getPetByIdWithHttpInfo - * - * Find pet by ID - * - * @param int $pet_id ID of pet to return (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings) - */ - public function getPetByIdWithHttpInfo($pet_id, string $contentType = self::contentTypes['getPetById'][0]) - { - $request = $this->getPetByIdRequest($pet_id, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Pet' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Pet' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Pet', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Pet'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Pet', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getPetByIdAsync - * - * Find pet by ID - * - * @param int $pet_id ID of pet to return (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPetByIdAsync($pet_id, string $contentType = self::contentTypes['getPetById'][0]) - { - return $this->getPetByIdAsyncWithHttpInfo($pet_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getPetByIdAsyncWithHttpInfo - * - * Find pet by ID - * - * @param int $pet_id ID of pet to return (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getPetByIdAsyncWithHttpInfo($pet_id, string $contentType = self::contentTypes['getPetById'][0]) - { - $returnType = '\OpenAPI\Client\Model\Pet'; - $request = $this->getPetByIdRequest($pet_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getPetById' - * - * @param int $pet_id ID of pet to return (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPetById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getPetByIdRequest($pet_id, string $contentType = self::contentTypes['getPetById'][0]) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet_id when calling getPetById' - ); - } - - - $resourcePath = '/pet/{petId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($pet_id !== null) { - $resourcePath = str_replace( - '{' . 'petId' . '}', - ObjectSerializer::toPathValue($pet_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api_key'); - if ($apiKey !== null) { - $headers['api_key'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation updatePet - * - * Update an existing pet - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function updatePet($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) - { - $this->updatePetWithHttpInfo($pet, $hostIndex, $variables, $contentType); - } - - /** - * Operation updatePetWithHttpInfo - * - * Update an existing pet - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function updatePetWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) - { - $request = $this->updatePetRequest($pet, $hostIndex, $variables, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation updatePetAsync - * - * Update an existing pet - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updatePetAsync($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) - { - return $this->updatePetAsyncWithHttpInfo($pet, $hostIndex, $variables, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation updatePetAsyncWithHttpInfo - * - * Update an existing pet - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updatePetAsyncWithHttpInfo($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) - { - $returnType = ''; - $request = $this->updatePetRequest($pet, $hostIndex, $variables, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'updatePet' - * - * This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host. - * if needed, use the 'variables' parameter to pass variables to the host. - * URL: http://petstore.swagger.io/v2 - * URL: http://path-server-test.petstore.local/v2 - * URL: http://{server}.swagger.io:{port}/v2 - * Variables: - * - server: target server - * Allowed values: - * - petstore - * - qa-petstore - * - dev-petstore - * - port: No description provided - * Allowed values: - * - 80 - * - 8080 - * - * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param null|int $hostIndex Host index. Defaults to null. If null, then the library will use $this->hostIndex instead - * @param array $variables Associative array of variables to pass to the host. Defaults to empty array. - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePet'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function updatePetRequest($pet, ?int $hostIndex = null, array $variables = [], string $contentType = self::contentTypes['updatePet'][0]) - { - - // verify the required parameter 'pet' is set - if ($pet === null || (is_array($pet) && count($pet) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet when calling updatePet' - ); - } - - - $resourcePath = '/pet'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $pet; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - # Preserve the original behavior of server indexing. - if ($hostIndex === null) { - $hostIndex = $this->hostIndex; - } - - $hostSettings = $this->getHostSettingsForupdatePet(); - - if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) { - throw new \InvalidArgumentException("Invalid index {$hostIndex} when selecting the host. Must be less than ".count($hostSettings)); - } - $operationHost = Configuration::getHostString($hostSettings, $hostIndex, $variables); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Returns an array of host settings for Operation updatePet - * - * @return array an array of host settings - */ - protected function getHostSettingsForupdatePet(): array - { - return [ - [ - "url" => "http://petstore.swagger.io/v2", - "description" => "No description provided", - ], - [ - "url" => "http://path-server-test.petstore.local/v2", - "description" => "No description provided", - ], - [ - "url" => "http://{server}.swagger.io:{port}/v2", - "description" => "test server with variables", - "variables" => [ - "server" => [ - "description" => "target server", - "default_value" => "petstore", - "enum_values" => [ - "petstore", - "qa-petstore", - "dev-petstore", - ] - ], - "port" => [ - "description" => "No description provided", - "default_value" => "80", - "enum_values" => [ - "80", - "8080", - ] - ] - ] - ] - ]; - } - - /** - * Operation updatePetWithForm - * - * Updates a pet in the store with form data - * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function updatePetWithForm($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) - { - $this->updatePetWithFormWithHttpInfo($pet_id, $name, $status, $contentType); - } - - /** - * Operation updatePetWithFormWithHttpInfo - * - * Updates a pet in the store with form data - * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) - { - $request = $this->updatePetWithFormRequest($pet_id, $name, $status, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation updatePetWithFormAsync - * - * Updates a pet in the store with form data - * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updatePetWithFormAsync($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) - { - return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation updatePetWithFormAsyncWithHttpInfo - * - * Updates a pet in the store with form data - * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) - { - $returnType = ''; - $request = $this->updatePetWithFormRequest($pet_id, $name, $status, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'updatePetWithForm' - * - * @param int $pet_id ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updatePetWithForm'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function updatePetWithFormRequest($pet_id, $name = null, $status = null, string $contentType = self::contentTypes['updatePetWithForm'][0]) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet_id when calling updatePetWithForm' - ); - } - - - - - $resourcePath = '/pet/{petId}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($pet_id !== null) { - $resourcePath = str_replace( - '{' . 'petId' . '}', - ObjectSerializer::toPathValue($pet_id), - $resourcePath - ); - } - - // form params - if ($name !== null) { - $formParams['name'] = ObjectSerializer::toFormValue($name); - } - // form params - if ($status !== null) { - $formParams['status'] = ObjectSerializer::toFormValue($status); - } - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation uploadFile - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\ApiResponse - */ - public function uploadFile($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) - { - list($response) = $this->uploadFileWithHttpInfo($pet_id, $additional_metadata, $file, $contentType); - return $response; - } - - /** - * Operation uploadFileWithHttpInfo - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) - { - $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\ApiResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\ApiResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation uploadFileAsync - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) - { - return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation uploadFileAsyncWithHttpInfo - * - * uploads an image - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) - { - $returnType = '\OpenAPI\Client\Model\ApiResponse'; - $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'uploadFile' - * - * @param int $pet_id ID of pet to update (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param \SplFileObject $file file to upload (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function uploadFileRequest($pet_id, $additional_metadata = null, $file = null, string $contentType = self::contentTypes['uploadFile'][0]) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet_id when calling uploadFile' - ); - } - - - - - $resourcePath = '/pet/{petId}/uploadImage'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($pet_id !== null) { - $resourcePath = str_replace( - '{' . 'petId' . '}', - ObjectSerializer::toPathValue($pet_id), - $resourcePath - ); - } - - // form params - if ($additional_metadata !== null) { - $formParams['additionalMetadata'] = ObjectSerializer::toFormValue($additional_metadata); - } - // form params - if ($file !== null) { - $multipart = true; - $formParams['file'] = []; - $paramFiles = is_array($file) ? $file : [$file]; - foreach ($paramFiles as $paramFile) { - $formParams['file'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation uploadFileWithRequiredFile - * - * uploads an image (required) - * - * @param int $pet_id ID of pet to update (required) - * @param \SplFileObject $required_file file to upload (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\ApiResponse - */ - public function uploadFileWithRequiredFile($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) - { - list($response) = $this->uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata, $contentType); - return $response; - } - - /** - * Operation uploadFileWithRequiredFileWithHttpInfo - * - * uploads an image (required) - * - * @param int $pet_id ID of pet to update (required) - * @param \SplFileObject $required_file file to upload (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\ApiResponse, HTTP status code, HTTP response headers (array of strings) - */ - public function uploadFileWithRequiredFileWithHttpInfo($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) - { - $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\ApiResponse' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\ApiResponse' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\ApiResponse', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\ApiResponse'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\ApiResponse', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation uploadFileWithRequiredFileAsync - * - * uploads an image (required) - * - * @param int $pet_id ID of pet to update (required) - * @param \SplFileObject $required_file file to upload (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function uploadFileWithRequiredFileAsync($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) - { - return $this->uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation uploadFileWithRequiredFileAsyncWithHttpInfo - * - * uploads an image (required) - * - * @param int $pet_id ID of pet to update (required) - * @param \SplFileObject $required_file file to upload (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function uploadFileWithRequiredFileAsyncWithHttpInfo($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) - { - $returnType = '\OpenAPI\Client\Model\ApiResponse'; - $request = $this->uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'uploadFileWithRequiredFile' - * - * @param int $pet_id ID of pet to update (required) - * @param \SplFileObject $required_file file to upload (required) - * @param string $additional_metadata Additional data to pass to server (optional) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['uploadFileWithRequiredFile'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function uploadFileWithRequiredFileRequest($pet_id, $required_file, $additional_metadata = null, string $contentType = self::contentTypes['uploadFileWithRequiredFile'][0]) - { - - // verify the required parameter 'pet_id' is set - if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $pet_id when calling uploadFileWithRequiredFile' - ); - } - - // verify the required parameter 'required_file' is set - if ($required_file === null || (is_array($required_file) && count($required_file) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $required_file when calling uploadFileWithRequiredFile' - ); - } - - - - $resourcePath = '/fake/{petId}/uploadImageWithRequiredFile'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($pet_id !== null) { - $resourcePath = str_replace( - '{' . 'petId' . '}', - ObjectSerializer::toPathValue($pet_id), - $resourcePath - ); - } - - // form params - if ($additional_metadata !== null) { - $formParams['additionalMetadata'] = ObjectSerializer::toFormValue($additional_metadata); - } - // form params - if ($required_file !== null) { - $multipart = true; - $formParams['requiredFile'] = []; - $paramFiles = is_array($required_file) ? $required_file : [$required_file]; - foreach ($paramFiles as $paramFile) { - $formParams['requiredFile'][] = \GuzzleHttp\Psr7\Utils::tryFopen( - ObjectSerializer::toFormValue($paramFile), - 'rb' - ); - } - } - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires OAuth (access token) - if (!empty($this->config->getAccessToken())) { - $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/StoreApi.php deleted file mode 100644 index 54f31f8a921..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/StoreApi.php +++ /dev/null @@ -1,1220 +0,0 @@ - [ - 'application/json', - ], - 'getInventory' => [ - 'application/json', - ], - 'getOrderById' => [ - 'application/json', - ], - 'placeOrder' => [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation deleteOrder - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function deleteOrder($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) - { - $this->deleteOrderWithHttpInfo($order_id, $contentType); - } - - /** - * Operation deleteOrderWithHttpInfo - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteOrderWithHttpInfo($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) - { - $request = $this->deleteOrderRequest($order_id, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation deleteOrderAsync - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteOrderAsync($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) - { - return $this->deleteOrderAsyncWithHttpInfo($order_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation deleteOrderAsyncWithHttpInfo - * - * Delete purchase order by ID - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteOrderAsyncWithHttpInfo($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) - { - $returnType = ''; - $request = $this->deleteOrderRequest($order_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'deleteOrder' - * - * @param string $order_id ID of the order that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function deleteOrderRequest($order_id, string $contentType = self::contentTypes['deleteOrder'][0]) - { - - // verify the required parameter 'order_id' is set - if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $order_id when calling deleteOrder' - ); - } - - - $resourcePath = '/store/order/{order_id}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($order_id !== null) { - $resourcePath = str_replace( - '{' . 'order_id' . '}', - ObjectSerializer::toPathValue($order_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'DELETE', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getInventory - * - * Returns pet inventories by status - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array - */ - public function getInventory(string $contentType = self::contentTypes['getInventory'][0]) - { - list($response) = $this->getInventoryWithHttpInfo($contentType); - return $response; - } - - /** - * Operation getInventoryWithHttpInfo - * - * Returns pet inventories by status - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of array, HTTP status code, HTTP response headers (array of strings) - */ - public function getInventoryWithHttpInfo(string $contentType = self::contentTypes['getInventory'][0]) - { - $request = $this->getInventoryRequest($contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('array' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('array' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, 'array', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = 'array'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'array', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getInventoryAsync - * - * Returns pet inventories by status - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getInventoryAsync(string $contentType = self::contentTypes['getInventory'][0]) - { - return $this->getInventoryAsyncWithHttpInfo($contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getInventoryAsyncWithHttpInfo - * - * Returns pet inventories by status - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getInventoryAsyncWithHttpInfo(string $contentType = self::contentTypes['getInventory'][0]) - { - $returnType = 'array'; - $request = $this->getInventoryRequest($contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getInventory' - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getInventory'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getInventoryRequest(string $contentType = self::contentTypes['getInventory'][0]) - { - - - $resourcePath = '/store/inventory'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - // this endpoint requires API key authentication - $apiKey = $this->config->getApiKeyWithPrefix('api_key'); - if ($apiKey !== null) { - $headers['api_key'] = $apiKey; - } - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getOrderById - * - * Find purchase order by ID - * - * @param int $order_id ID of pet that needs to be fetched (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Order - */ - public function getOrderById($order_id, string $contentType = self::contentTypes['getOrderById'][0]) - { - list($response) = $this->getOrderByIdWithHttpInfo($order_id, $contentType); - return $response; - } - - /** - * Operation getOrderByIdWithHttpInfo - * - * Find purchase order by ID - * - * @param int $order_id ID of pet that needs to be fetched (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) - */ - public function getOrderByIdWithHttpInfo($order_id, string $contentType = self::contentTypes['getOrderById'][0]) - { - $request = $this->getOrderByIdRequest($order_id, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Order' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Order', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Order'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Order', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getOrderByIdAsync - * - * Find purchase order by ID - * - * @param int $order_id ID of pet that needs to be fetched (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getOrderByIdAsync($order_id, string $contentType = self::contentTypes['getOrderById'][0]) - { - return $this->getOrderByIdAsyncWithHttpInfo($order_id, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getOrderByIdAsyncWithHttpInfo - * - * Find purchase order by ID - * - * @param int $order_id ID of pet that needs to be fetched (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getOrderByIdAsyncWithHttpInfo($order_id, string $contentType = self::contentTypes['getOrderById'][0]) - { - $returnType = '\OpenAPI\Client\Model\Order'; - $request = $this->getOrderByIdRequest($order_id, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getOrderById' - * - * @param int $order_id ID of pet that needs to be fetched (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getOrderById'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getOrderByIdRequest($order_id, string $contentType = self::contentTypes['getOrderById'][0]) - { - - // verify the required parameter 'order_id' is set - if ($order_id === null || (is_array($order_id) && count($order_id) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $order_id when calling getOrderById' - ); - } - if ($order_id > 5) { - throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be smaller than or equal to 5.'); - } - if ($order_id < 1) { - throw new \InvalidArgumentException('invalid value for "$order_id" when calling StoreApi.getOrderById, must be bigger than or equal to 1.'); - } - - - $resourcePath = '/store/order/{order_id}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($order_id !== null) { - $resourcePath = str_replace( - '{' . 'order_id' . '}', - ObjectSerializer::toPathValue($order_id), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation placeOrder - * - * Place an order for a pet - * - * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\Order - */ - public function placeOrder($order, string $contentType = self::contentTypes['placeOrder'][0]) - { - list($response) = $this->placeOrderWithHttpInfo($order, $contentType); - return $response; - } - - /** - * Operation placeOrderWithHttpInfo - * - * Place an order for a pet - * - * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\Order, HTTP status code, HTTP response headers (array of strings) - */ - public function placeOrderWithHttpInfo($order, string $contentType = self::contentTypes['placeOrder'][0]) - { - $request = $this->placeOrderRequest($order, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\Order' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\Order' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Order', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\Order'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\Order', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation placeOrderAsync - * - * Place an order for a pet - * - * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeOrderAsync($order, string $contentType = self::contentTypes['placeOrder'][0]) - { - return $this->placeOrderAsyncWithHttpInfo($order, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation placeOrderAsyncWithHttpInfo - * - * Place an order for a pet - * - * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function placeOrderAsyncWithHttpInfo($order, string $contentType = self::contentTypes['placeOrder'][0]) - { - $returnType = '\OpenAPI\Client\Model\Order'; - $request = $this->placeOrderRequest($order, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'placeOrder' - * - * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['placeOrder'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function placeOrderRequest($order, string $contentType = self::contentTypes['placeOrder'][0]) - { - - // verify the required parameter 'order' is set - if ($order === null || (is_array($order) && count($order) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $order when calling placeOrder' - ); - } - - - $resourcePath = '/store/order'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $order; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/UserApi.php deleted file mode 100644 index 43831c86827..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Api/UserApi.php +++ /dev/null @@ -1,2122 +0,0 @@ - [ - 'application/json', - ], - 'createUsersWithArrayInput' => [ - 'application/json', - ], - 'createUsersWithListInput' => [ - 'application/json', - ], - 'deleteUser' => [ - 'application/json', - ], - 'getUserByName' => [ - 'application/json', - ], - 'loginUser' => [ - 'application/json', - ], - 'logoutUser' => [ - 'application/json', - ], - 'updateUser' => [ - 'application/json', - ], - ]; - -/** - * @param ClientInterface $client - * @param Configuration $config - * @param HeaderSelector $selector - * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec - */ - public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 - ) { - $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - $this->hostIndex = $hostIndex; - } - - /** - * Set the host index - * - * @param int $hostIndex Host index (required) - */ - public function setHostIndex($hostIndex): void - { - $this->hostIndex = $hostIndex; - } - - /** - * Get the host index - * - * @return int Host index - */ - public function getHostIndex() - { - return $this->hostIndex; - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation createUser - * - * Create user - * - * @param \OpenAPI\Client\Model\User $user Created user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function createUser($user, string $contentType = self::contentTypes['createUser'][0]) - { - $this->createUserWithHttpInfo($user, $contentType); - } - - /** - * Operation createUserWithHttpInfo - * - * Create user - * - * @param \OpenAPI\Client\Model\User $user Created user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function createUserWithHttpInfo($user, string $contentType = self::contentTypes['createUser'][0]) - { - $request = $this->createUserRequest($user, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation createUserAsync - * - * Create user - * - * @param \OpenAPI\Client\Model\User $user Created user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUserAsync($user, string $contentType = self::contentTypes['createUser'][0]) - { - return $this->createUserAsyncWithHttpInfo($user, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation createUserAsyncWithHttpInfo - * - * Create user - * - * @param \OpenAPI\Client\Model\User $user Created user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUserAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUser'][0]) - { - $returnType = ''; - $request = $this->createUserRequest($user, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'createUser' - * - * @param \OpenAPI\Client\Model\User $user Created user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function createUserRequest($user, string $contentType = self::contentTypes['createUser'][0]) - { - - // verify the required parameter 'user' is set - if ($user === null || (is_array($user) && count($user) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $user when calling createUser' - ); - } - - - $resourcePath = '/user'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $user; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation createUsersWithArrayInput - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function createUsersWithArrayInput($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) - { - $this->createUsersWithArrayInputWithHttpInfo($user, $contentType); - } - - /** - * Operation createUsersWithArrayInputWithHttpInfo - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function createUsersWithArrayInputWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) - { - $request = $this->createUsersWithArrayInputRequest($user, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation createUsersWithArrayInputAsync - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUsersWithArrayInputAsync($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) - { - return $this->createUsersWithArrayInputAsyncWithHttpInfo($user, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation createUsersWithArrayInputAsyncWithHttpInfo - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUsersWithArrayInputAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) - { - $returnType = ''; - $request = $this->createUsersWithArrayInputRequest($user, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'createUsersWithArrayInput' - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithArrayInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function createUsersWithArrayInputRequest($user, string $contentType = self::contentTypes['createUsersWithArrayInput'][0]) - { - - // verify the required parameter 'user' is set - if ($user === null || (is_array($user) && count($user) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $user when calling createUsersWithArrayInput' - ); - } - - - $resourcePath = '/user/createWithArray'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $user; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation createUsersWithListInput - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function createUsersWithListInput($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) - { - $this->createUsersWithListInputWithHttpInfo($user, $contentType); - } - - /** - * Operation createUsersWithListInputWithHttpInfo - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function createUsersWithListInputWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) - { - $request = $this->createUsersWithListInputRequest($user, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation createUsersWithListInputAsync - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUsersWithListInputAsync($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) - { - return $this->createUsersWithListInputAsyncWithHttpInfo($user, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation createUsersWithListInputAsyncWithHttpInfo - * - * Creates list of users with given input array - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function createUsersWithListInputAsyncWithHttpInfo($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) - { - $returnType = ''; - $request = $this->createUsersWithListInputRequest($user, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'createUsersWithListInput' - * - * @param \OpenAPI\Client\Model\User[] $user List of user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['createUsersWithListInput'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function createUsersWithListInputRequest($user, string $contentType = self::contentTypes['createUsersWithListInput'][0]) - { - - // verify the required parameter 'user' is set - if ($user === null || (is_array($user) && count($user) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $user when calling createUsersWithListInput' - ); - } - - - $resourcePath = '/user/createWithList'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $user; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'POST', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation deleteUser - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function deleteUser($username, string $contentType = self::contentTypes['deleteUser'][0]) - { - $this->deleteUserWithHttpInfo($username, $contentType); - } - - /** - * Operation deleteUserWithHttpInfo - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function deleteUserWithHttpInfo($username, string $contentType = self::contentTypes['deleteUser'][0]) - { - $request = $this->deleteUserRequest($username, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation deleteUserAsync - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteUserAsync($username, string $contentType = self::contentTypes['deleteUser'][0]) - { - return $this->deleteUserAsyncWithHttpInfo($username, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation deleteUserAsyncWithHttpInfo - * - * Delete user - * - * @param string $username The name that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function deleteUserAsyncWithHttpInfo($username, string $contentType = self::contentTypes['deleteUser'][0]) - { - $returnType = ''; - $request = $this->deleteUserRequest($username, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'deleteUser' - * - * @param string $username The name that needs to be deleted (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['deleteUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function deleteUserRequest($username, string $contentType = self::contentTypes['deleteUser'][0]) - { - - // verify the required parameter 'username' is set - if ($username === null || (is_array($username) && count($username) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $username when calling deleteUser' - ); - } - - - $resourcePath = '/user/{username}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($username !== null) { - $resourcePath = str_replace( - '{' . 'username' . '}', - ObjectSerializer::toPathValue($username), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'DELETE', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation getUserByName - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return \OpenAPI\Client\Model\User - */ - public function getUserByName($username, string $contentType = self::contentTypes['getUserByName'][0]) - { - list($response) = $this->getUserByNameWithHttpInfo($username, $contentType); - return $response; - } - - /** - * Operation getUserByNameWithHttpInfo - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of \OpenAPI\Client\Model\User, HTTP status code, HTTP response headers (array of strings) - */ - public function getUserByNameWithHttpInfo($username, string $contentType = self::contentTypes['getUserByName'][0]) - { - $request = $this->getUserByNameRequest($username, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('\OpenAPI\Client\Model\User' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('\OpenAPI\Client\Model\User' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\User', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = '\OpenAPI\Client\Model\User'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - '\OpenAPI\Client\Model\User', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation getUserByNameAsync - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUserByNameAsync($username, string $contentType = self::contentTypes['getUserByName'][0]) - { - return $this->getUserByNameAsyncWithHttpInfo($username, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation getUserByNameAsyncWithHttpInfo - * - * Get user by user name - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function getUserByNameAsyncWithHttpInfo($username, string $contentType = self::contentTypes['getUserByName'][0]) - { - $returnType = '\OpenAPI\Client\Model\User'; - $request = $this->getUserByNameRequest($username, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'getUserByName' - * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getUserByName'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function getUserByNameRequest($username, string $contentType = self::contentTypes['getUserByName'][0]) - { - - // verify the required parameter 'username' is set - if ($username === null || (is_array($username) && count($username) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $username when calling getUserByName' - ); - } - - - $resourcePath = '/user/{username}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($username !== null) { - $resourcePath = str_replace( - '{' . 'username' . '}', - ObjectSerializer::toPathValue($username), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation loginUser - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return string - */ - public function loginUser($username, $password, string $contentType = self::contentTypes['loginUser'][0]) - { - list($response) = $this->loginUserWithHttpInfo($username, $password, $contentType); - return $response; - } - - /** - * Operation loginUserWithHttpInfo - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of string, HTTP status code, HTTP response headers (array of strings) - */ - public function loginUserWithHttpInfo($username, $password, string $contentType = self::contentTypes['loginUser'][0]) - { - $request = $this->loginUserRequest($username, $password, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - switch($statusCode) { - case 200: - if ('string' === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ('string' !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, 'string', []), - $response->getStatusCode(), - $response->getHeaders() - ]; - } - - $returnType = 'string'; - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - case 200: - $data = ObjectSerializer::deserialize( - $e->getResponseBody(), - 'string', - $e->getResponseHeaders() - ); - $e->setResponseObject($data); - break; - } - throw $e; - } - } - - /** - * Operation loginUserAsync - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function loginUserAsync($username, $password, string $contentType = self::contentTypes['loginUser'][0]) - { - return $this->loginUserAsyncWithHttpInfo($username, $password, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation loginUserAsyncWithHttpInfo - * - * Logs user into the system - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function loginUserAsyncWithHttpInfo($username, $password, string $contentType = self::contentTypes['loginUser'][0]) - { - $returnType = 'string'; - $request = $this->loginUserRequest($username, $password, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - if ($returnType === '\SplFileObject') { - $content = $response->getBody(); //stream goes to serializer - } else { - $content = (string) $response->getBody(); - if ($returnType !== 'string') { - $content = json_decode($content); - } - } - - return [ - ObjectSerializer::deserialize($content, $returnType, []), - $response->getStatusCode(), - $response->getHeaders() - ]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'loginUser' - * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['loginUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function loginUserRequest($username, $password, string $contentType = self::contentTypes['loginUser'][0]) - { - - // verify the required parameter 'username' is set - if ($username === null || (is_array($username) && count($username) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $username when calling loginUser' - ); - } - - // verify the required parameter 'password' is set - if ($password === null || (is_array($password) && count($password) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $password when calling loginUser' - ); - } - - - $resourcePath = '/user/login'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $username, - 'username', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - // query params - $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $password, - 'password', // param base name - 'string', // openApiType - 'form', // style - true, // explode - true // required - ) ?? []); - - - - - $headers = $this->headerSelector->selectHeaders( - ['application/xml', 'application/json', ], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation logoutUser - * - * Logs out current logged in user session - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function logoutUser(string $contentType = self::contentTypes['logoutUser'][0]) - { - $this->logoutUserWithHttpInfo($contentType); - } - - /** - * Operation logoutUserWithHttpInfo - * - * Logs out current logged in user session - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function logoutUserWithHttpInfo(string $contentType = self::contentTypes['logoutUser'][0]) - { - $request = $this->logoutUserRequest($contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation logoutUserAsync - * - * Logs out current logged in user session - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function logoutUserAsync(string $contentType = self::contentTypes['logoutUser'][0]) - { - return $this->logoutUserAsyncWithHttpInfo($contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation logoutUserAsyncWithHttpInfo - * - * Logs out current logged in user session - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function logoutUserAsyncWithHttpInfo(string $contentType = self::contentTypes['logoutUser'][0]) - { - $returnType = ''; - $request = $this->logoutUserRequest($contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'logoutUser' - * - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['logoutUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function logoutUserRequest(string $contentType = self::contentTypes['logoutUser'][0]) - { - - - $resourcePath = '/user/logout'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - if (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'GET', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Operation updateUser - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param \OpenAPI\Client\Model\User $user Updated user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function updateUser($username, $user, string $contentType = self::contentTypes['updateUser'][0]) - { - $this->updateUserWithHttpInfo($username, $user, $contentType); - } - - /** - * Operation updateUserWithHttpInfo - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param \OpenAPI\Client\Model\User $user Updated user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation - * - * @throws \OpenAPI\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function updateUserWithHttpInfo($username, $user, string $contentType = self::contentTypes['updateUser'][0]) - { - $request = $this->updateUserRequest($username, $user, $contentType); - - try { - $options = $this->createHttpClientOption(); - try { - $response = $this->client->send($request, $options); - } catch (RequestException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - $e->getResponse() ? $e->getResponse()->getHeaders() : null, - $e->getResponse() ? (string) $e->getResponse()->getBody() : null - ); - } catch (ConnectException $e) { - throw new ApiException( - "[{$e->getCode()}] {$e->getMessage()}", - (int) $e->getCode(), - null, - null - ); - } - - $statusCode = $response->getStatusCode(); - - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - - return [null, $statusCode, $response->getHeaders()]; - - } catch (ApiException $e) { - switch ($e->getCode()) { - } - throw $e; - } - } - - /** - * Operation updateUserAsync - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param \OpenAPI\Client\Model\User $user Updated user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateUserAsync($username, $user, string $contentType = self::contentTypes['updateUser'][0]) - { - return $this->updateUserAsyncWithHttpInfo($username, $user, $contentType) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation updateUserAsyncWithHttpInfo - * - * Updated user - * - * @param string $username name that need to be deleted (required) - * @param \OpenAPI\Client\Model\User $user Updated user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function updateUserAsyncWithHttpInfo($username, $user, string $contentType = self::contentTypes['updateUser'][0]) - { - $returnType = ''; - $request = $this->updateUserRequest($username, $user, $contentType); - - return $this->client - ->sendAsync($request, $this->createHttpClientOption()) - ->then( - function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; - }, - function ($exception) { - $response = $exception->getResponse(); - $statusCode = $response->getStatusCode(); - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - $exception->getRequest()->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } - ); - } - - /** - * Create request for operation 'updateUser' - * - * @param string $username name that need to be deleted (required) - * @param \OpenAPI\Client\Model\User $user Updated user object (required) - * @param string $contentType The value for the Content-Type header. Check self::contentTypes['updateUser'] to see the possible values for this operation - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - public function updateUserRequest($username, $user, string $contentType = self::contentTypes['updateUser'][0]) - { - - // verify the required parameter 'username' is set - if ($username === null || (is_array($username) && count($username) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $username when calling updateUser' - ); - } - - // verify the required parameter 'user' is set - if ($user === null || (is_array($user) && count($user) === 0)) { - throw new \InvalidArgumentException( - 'Missing the required parameter $user when calling updateUser' - ); - } - - - $resourcePath = '/user/{username}'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // path params - if ($username !== null) { - $resourcePath = str_replace( - '{' . 'username' . '}', - ObjectSerializer::toPathValue($username), - $resourcePath - ); - } - - - $headers = $this->headerSelector->selectHeaders( - [], - $contentType, - $multipart - ); - - // for model (json/xml) - 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)); - } else { - $httpBody = $user; - } - } elseif (count($formParams) > 0) { - if ($multipart) { - $multipartContents = []; - foreach ($formParams as $formParamName => $formParamValue) { - $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; - foreach ($formParamValueItems as $formParamValueItem) { - $multipartContents[] = [ - 'name' => $formParamName, - 'contents' => $formParamValueItem - ]; - } - } - // for HTTP post (form) - $httpBody = new MultipartStream($multipartContents); - - } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { - # if Content-Type contains "application/json", json_encode the form parameters - $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); - } else { - // for HTTP post (form) - $httpBody = ObjectSerializer::buildQuery($formParams); - } - } - - - $defaultHeaders = []; - if ($this->config->getUserAgent()) { - $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); - } - - $headers = array_merge( - $defaultHeaders, - $headerParams, - $headers - ); - - $operationHost = $this->config->getHost(); - $query = ObjectSerializer::buildQuery($queryParams); - return new Request( - 'PUT', - $operationHost . $resourcePath . ($query ? "?{$query}" : ''), - $headers, - $httpBody - ); - } - - /** - * Create http client option - * - * @throws \RuntimeException on file opening failure - * @return array of http client options - */ - protected function createHttpClientOption() - { - $options = []; - if ($this->config->getDebug()) { - $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); - if (!$options[RequestOptions::DEBUG]) { - throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); - } - } - - return $options; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ApiException.php deleted file mode 100644 index bffc807b9a2..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ApiException.php +++ /dev/null @@ -1,119 +0,0 @@ -responseHeaders = $responseHeaders; - $this->responseBody = $responseBody; - } - - /** - * Gets the HTTP response header - * - * @return string[]|null HTTP response header - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * Gets the HTTP body of the server response either as Json or string - * - * @return \stdClass|string|null HTTP body of the server response either as \stdClass or string - */ - public function getResponseBody() - { - return $this->responseBody; - } - - /** - * Sets the deserialized response object (during deserialization) - * - * @param mixed $obj Deserialized response object - * - * @return void - */ - public function setResponseObject($obj) - { - $this->responseObject = $obj; - } - - /** - * Gets the deserialized response object (during deserialization) - * - * @return mixed the deserialized response object - */ - public function getResponseObject() - { - return $this->responseObject; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Configuration.php deleted file mode 100644 index c08e07f8cdf..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Configuration.php +++ /dev/null @@ -1,567 +0,0 @@ -tempFolderPath = sys_get_temp_dir(); - } - - /** - * Sets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $key API key or token - * - * @return $this - */ - public function setApiKey($apiKeyIdentifier, $key) - { - $this->apiKeys[$apiKeyIdentifier] = $key; - return $this; - } - - /** - * Gets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string API key or token - */ - public function getApiKey($apiKeyIdentifier) - { - return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null; - } - - /** - * Sets the prefix for API key (e.g. Bearer) - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $prefix API key prefix, e.g. Bearer - * - * @return $this - */ - public function setApiKeyPrefix($apiKeyIdentifier, $prefix) - { - $this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix; - return $this; - } - - /** - * Gets API key prefix - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return null|string - */ - public function getApiKeyPrefix($apiKeyIdentifier) - { - return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null; - } - - /** - * Sets the access token for OAuth - * - * @param string $accessToken Token for OAuth - * - * @return $this - */ - public function setAccessToken($accessToken) - { - $this->accessToken = $accessToken; - return $this; - } - - /** - * Gets the access token for OAuth - * - * @return string Access token for OAuth - */ - public function getAccessToken() - { - return $this->accessToken; - } - - /** - * Sets boolean format for query string. - * - * @param string $booleanFormatForQueryString Boolean format for query string - * - * @return $this - */ - public function setBooleanFormatForQueryString(string $booleanFormat) - { - $this->booleanFormatForQueryString = $booleanFormat; - - return $this; - } - - /** - * Gets boolean format for query string. - * - * @return string Boolean format for query string - */ - public function getBooleanFormatForQueryString(): string - { - return $this->booleanFormatForQueryString; - } - - /** - * Sets the username for HTTP basic authentication - * - * @param string $username Username for HTTP basic authentication - * - * @return $this - */ - public function setUsername($username) - { - $this->username = $username; - return $this; - } - - /** - * Gets the username for HTTP basic authentication - * - * @return string Username for HTTP basic authentication - */ - public function getUsername() - { - return $this->username; - } - - /** - * Sets the password for HTTP basic authentication - * - * @param string $password Password for HTTP basic authentication - * - * @return $this - */ - public function setPassword($password) - { - $this->password = $password; - return $this; - } - - /** - * Gets the password for HTTP basic authentication - * - * @return string Password for HTTP basic authentication - */ - public function getPassword() - { - return $this->password; - } - - /** - * Sets the host - * - * @param string $host Host - * - * @return $this - */ - public function setHost($host) - { - $this->host = $host; - return $this; - } - - /** - * Gets the host - * - * @return string Host - */ - public function getHost() - { - return $this->host; - } - - /** - * Sets the user agent of the api client - * - * @param string $userAgent the user agent of the api client - * - * @throws \InvalidArgumentException - * @return $this - */ - public function setUserAgent($userAgent) - { - if (!is_string($userAgent)) { - throw new \InvalidArgumentException('User-agent must be a string.'); - } - - $this->userAgent = $userAgent; - return $this; - } - - /** - * Gets the user agent of the api client - * - * @return string user agent - */ - public function getUserAgent() - { - return $this->userAgent; - } - - /** - * Sets debug flag - * - * @param bool $debug Debug flag - * - * @return $this - */ - public function setDebug($debug) - { - $this->debug = $debug; - return $this; - } - - /** - * Gets the debug flag - * - * @return bool - */ - public function getDebug() - { - return $this->debug; - } - - /** - * Sets the debug file - * - * @param string $debugFile Debug file - * - * @return $this - */ - public function setDebugFile($debugFile) - { - $this->debugFile = $debugFile; - return $this; - } - - /** - * Gets the debug file - * - * @return string - */ - public function getDebugFile() - { - return $this->debugFile; - } - - /** - * Sets the temp folder path - * - * @param string $tempFolderPath Temp folder path - * - * @return $this - */ - public function setTempFolderPath($tempFolderPath) - { - $this->tempFolderPath = $tempFolderPath; - return $this; - } - - /** - * Gets the temp folder path - * - * @return string Temp folder path - */ - public function getTempFolderPath() - { - return $this->tempFolderPath; - } - - /** - * Gets the default configuration instance - * - * @return Configuration - */ - public static function getDefaultConfiguration() - { - if (self::$defaultConfiguration === null) { - self::$defaultConfiguration = new Configuration(); - } - - return self::$defaultConfiguration; - } - - /** - * Sets the default configuration instance - * - * @param Configuration $config An instance of the Configuration Object - * - * @return void - */ - public static function setDefaultConfiguration(Configuration $config) - { - self::$defaultConfiguration = $config; - } - - /** - * Gets the essential information for debugging - * - * @return string The report for debugging - */ - public static function toDebugReport() - { - $report = 'PHP SDK (OpenAPI\Client) Debug Report:' . PHP_EOL; - $report .= ' OS: ' . php_uname() . PHP_EOL; - $report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL; - $report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL; - $report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL; - - return $report; - } - - /** - * Get API key (with prefix if set) - * - * @param string $apiKeyIdentifier name of apikey - * - * @return null|string API key with the prefix - */ - public function getApiKeyWithPrefix($apiKeyIdentifier) - { - $prefix = $this->getApiKeyPrefix($apiKeyIdentifier); - $apiKey = $this->getApiKey($apiKeyIdentifier); - - if ($apiKey === null) { - return null; - } - - if ($prefix === null) { - $keyWithPrefix = $apiKey; - } else { - $keyWithPrefix = $prefix . ' ' . $apiKey; - } - - return $keyWithPrefix; - } - - /** - * Returns an array of host settings - * - * @return array an array of host settings - */ - public function getHostSettings() - { - return [ - [ - "url" => "http://{server}.swagger.io:{port}/v2", - "description" => "petstore server", - "variables" => [ - "server" => [ - "description" => "No description provided", - "default_value" => "petstore", - "enum_values" => [ - "petstore", - "qa-petstore", - "dev-petstore" - ] - ], - "port" => [ - "description" => "No description provided", - "default_value" => "80", - "enum_values" => [ - "80", - "8080" - ] - ] - ] - ], - [ - "url" => "https://localhost:8080/{version}", - "description" => "The local server", - "variables" => [ - "version" => [ - "description" => "No description provided", - "default_value" => "v2", - "enum_values" => [ - "v1", - "v2" - ] - ] - ] - ], - [ - "url" => "https://127.0.0.1/no_varaible", - "description" => "The local server without variables", - ] - ]; - } - - /** - * Returns URL based on host settings, index and variables - * - * @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients - * @param int $hostIndex index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings - */ - public static function getHostString(array $hostsSettings, $hostIndex, array $variables = null) - { - if (null === $variables) { - $variables = []; - } - - // check array index out of bound - if ($hostIndex < 0 || $hostIndex >= count($hostsSettings)) { - throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostsSettings)); - } - - $host = $hostsSettings[$hostIndex]; - $url = $host["url"]; - - // go through variable and assign a value - foreach ($host["variables"] ?? [] as $name => $variable) { - if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user - if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum - $url = str_replace("{".$name."}", $variables[$name], $url); - } else { - throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); - } - } else { - // use default value - $url = str_replace("{".$name."}", $variable["default_value"], $url); - } - } - - return $url; - } - - /** - * Returns URL based on the index and variables - * - * @param int $index index of the host settings - * @param array|null $variables hash of variable and the corresponding value (optional) - * @return string URL based on host settings - */ - public function getHostFromSettings($index, $variables = null) - { - return self::getHostString($this->getHostSettings(), $index, $variables); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/HeaderSelector.php deleted file mode 100644 index 611975603c8..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/HeaderSelector.php +++ /dev/null @@ -1,245 +0,0 @@ -selectAcceptHeader($accept); - if ($accept !== null) { - $headers['Accept'] = $accept; - } - - if (!$isMultipart) { - if($contentType === '') { - $contentType = 'application/json'; - } - - $headers['Content-Type'] = $contentType; - } - - return $headers; - } - - /** - * Return the header 'Accept' based on an array of Accept provided. - * - * @param string[] $accept Array of header - * - * @return null|string Accept (e.g. application/json) - */ - private function selectAcceptHeader(array $accept): ?string - { - # filter out empty entries - $accept = array_filter($accept); - - if (count($accept) === 0) { - return null; - } - - # If there's only one Accept header, just use it - if (count($accept) === 1) { - return reset($accept); - } - - # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); - if (count($headersWithJson) === 0) { - return implode(',', $accept); - } - - # If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1, - # to give the highest priority to json-like headers - recalculating the existing ones, if needed - return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); - } - - /** - * Create an Accept header string from the given "Accept" headers array, recalculating all weights - * - * @param string[] $accept Array of Accept Headers - * @param string[] $headersWithJson Array of Accept Headers of type "json" - * - * @return string "Accept" Header (e.g. "application/json, text/html; q=0.9") - */ - private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string - { - $processedHeaders = [ - 'withApplicationJson' => [], - 'withJson' => [], - 'withoutJson' => [], - ]; - - foreach ($accept as $header) { - - $headerData = $this->getHeaderAndWeight($header); - - if (stripos($headerData['header'], 'application/json') === 0) { - $processedHeaders['withApplicationJson'][] = $headerData; - } elseif (in_array($header, $headersWithJson, true)) { - $processedHeaders['withJson'][] = $headerData; - } else { - $processedHeaders['withoutJson'][] = $headerData; - } - } - - $acceptHeaders = []; - $currentWeight = 1000; - - $hasMoreThan28Headers = count($accept) > 28; - - foreach($processedHeaders as $headers) { - if (count($headers) > 0) { - $acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers); - } - } - - $acceptHeaders = array_merge(...$acceptHeaders); - - return implode(',', $acceptHeaders); - } - - /** - * Given an Accept header, returns an associative array splitting the header and its weight - * - * @param string $header "Accept" Header - * - * @return array with the header and its weight - */ - private function getHeaderAndWeight(string $header): array - { - # matches headers with weight, splitting the header and the weight in $outputArray - if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) { - $headerData = [ - 'header' => $outputArray[1], - 'weight' => (int)($outputArray[2] * 1000), - ]; - } else { - $headerData = [ - 'header' => trim($header), - 'weight' => 1000, - ]; - } - - return $headerData; - } - - /** - * @param array[] $headers - * @param float $currentWeight - * @param bool $hasMoreThan28Headers - * @return string[] array of adjusted "Accept" headers - */ - private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array - { - usort($headers, function (array $a, array $b) { - return $b['weight'] - $a['weight']; - }); - - $acceptHeaders = []; - foreach ($headers as $index => $header) { - if($index > 0 && $headers[$index - 1]['weight'] > $header['weight']) - { - $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); - } - - $weight = $currentWeight; - - $acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight); - } - - $currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers); - - return $acceptHeaders; - } - - /** - * @param string $header - * @param int $weight - * @return string - */ - private function buildAcceptHeader(string $header, int $weight): string - { - if($weight === 1000) { - return $header; - } - - return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0'); - } - - /** - * Calculate the next weight, based on the current one. - * - * If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the - * following formula: - * - * next weight = current weight - 10 ^ (floor(log(current weight - 1))) - * - * ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) ) - * - * Starting from 1000, this generates the following series: - * - * 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 - * - * The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works - * if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1 - * decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc. - * - * @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value) - * @param bool $hasMoreThan28Headers - * @return int - */ - public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int - { - if ($currentWeight <= 1) { - return 1; - } - - if ($hasMoreThan28Headers) { - return $currentWeight - 1; - } - - return $currentWeight - 10 ** floor( log10($currentWeight - 1) ); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php deleted file mode 100644 index 5a211d7e175..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class AdditionalPropertiesClass implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'AdditionalPropertiesClass'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'map_property' => 'array', - 'map_of_map_property' => 'array>' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'map_property' => null, - 'map_of_map_property' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'map_property' => false, - 'map_of_map_property' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'map_property' => 'map_property', - 'map_of_map_property' => 'map_of_map_property' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'map_property' => 'setMapProperty', - 'map_of_map_property' => 'setMapOfMapProperty' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'map_property' => 'getMapProperty', - 'map_of_map_property' => 'getMapOfMapProperty' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('map_property', $data ?? [], null); - $this->setIfExists('map_of_map_property', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets map_property - * - * @return array|null - */ - public function getMapProperty() - { - return $this->container['map_property']; - } - - /** - * Sets map_property - * - * @param array|null $map_property map_property - * - * @return self - */ - public function setMapProperty($map_property) - { - if (is_null($map_property)) { - throw new \InvalidArgumentException('non-nullable map_property cannot be null'); - } - $this->container['map_property'] = $map_property; - - return $this; - } - - /** - * Gets map_of_map_property - * - * @return array>|null - */ - public function getMapOfMapProperty() - { - return $this->container['map_of_map_property']; - } - - /** - * Sets map_of_map_property - * - * @param array>|null $map_of_map_property map_of_map_property - * - * @return self - */ - public function setMapOfMapProperty($map_of_map_property) - { - if (is_null($map_of_map_property)) { - throw new \InvalidArgumentException('non-nullable map_of_map_property cannot be null'); - } - $this->container['map_of_map_property'] = $map_of_map_property; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php deleted file mode 100644 index 9091da224f3..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class AllOfWithSingleRef implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'AllOfWithSingleRef'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'username' => 'string', - 'single_ref_type' => 'SingleRefType' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'username' => null, - 'single_ref_type' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'username' => false, - 'single_ref_type' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'username' => 'username', - 'single_ref_type' => 'SingleRefType' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'username' => 'setUsername', - 'single_ref_type' => 'setSingleRefType' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'username' => 'getUsername', - 'single_ref_type' => 'getSingleRefType' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('username', $data ?? [], null); - $this->setIfExists('single_ref_type', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets username - * - * @return string|null - */ - public function getUsername() - { - return $this->container['username']; - } - - /** - * Sets username - * - * @param string|null $username username - * - * @return self - */ - public function setUsername($username) - { - if (is_null($username)) { - throw new \InvalidArgumentException('non-nullable username cannot be null'); - } - $this->container['username'] = $username; - - return $this; - } - - /** - * Gets single_ref_type - * - * @return SingleRefType|null - */ - public function getSingleRefType() - { - return $this->container['single_ref_type']; - } - - /** - * Sets single_ref_type - * - * @param SingleRefType|null $single_ref_type single_ref_type - * - * @return self - */ - public function setSingleRefType($single_ref_type) - { - if (is_null($single_ref_type)) { - throw new \InvalidArgumentException('non-nullable single_ref_type cannot be null'); - } - $this->container['single_ref_type'] = $single_ref_type; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Animal.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Animal.php deleted file mode 100644 index 415a6528614..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Animal.php +++ /dev/null @@ -1,449 +0,0 @@ - - */ -class Animal implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = 'class_name'; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Animal'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'class_name' => 'string', - 'color' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'class_name' => null, - 'color' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'class_name' => false, - 'color' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'class_name' => 'className', - 'color' => 'color' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'class_name' => 'setClassName', - 'color' => 'setColor' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'class_name' => 'getClassName', - 'color' => 'getColor' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('class_name', $data ?? [], null); - $this->setIfExists('color', $data ?? [], 'red'); - - // Initialize discriminator property with the model name. - $this->container['class_name'] = static::$openAPIModelName; - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['class_name'] === null) { - $invalidProperties[] = "'class_name' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets class_name - * - * @return string - */ - public function getClassName() - { - return $this->container['class_name']; - } - - /** - * Sets class_name - * - * @param string $class_name class_name - * - * @return self - */ - public function setClassName($class_name) - { - if (is_null($class_name)) { - throw new \InvalidArgumentException('non-nullable class_name cannot be null'); - } - $this->container['class_name'] = $class_name; - - return $this; - } - - /** - * Gets color - * - * @return string|null - */ - public function getColor() - { - return $this->container['color']; - } - - /** - * Sets color - * - * @param string|null $color color - * - * @return self - */ - public function setColor($color) - { - if (is_null($color)) { - throw new \InvalidArgumentException('non-nullable color cannot be null'); - } - $this->container['color'] = $color; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ApiResponse.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ApiResponse.php deleted file mode 100644 index f624e8182af..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ApiResponse.php +++ /dev/null @@ -1,477 +0,0 @@ - - */ -class ApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ApiResponse'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'code' => 'int', - 'type' => 'string', - 'message' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'code' => 'int32', - 'type' => null, - 'message' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'code' => false, - 'type' => false, - 'message' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'code' => 'code', - 'type' => 'type', - 'message' => 'message' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'code' => 'setCode', - 'type' => 'setType', - 'message' => 'setMessage' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'code' => 'getCode', - 'type' => 'getType', - 'message' => 'getMessage' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('code', $data ?? [], null); - $this->setIfExists('type', $data ?? [], null); - $this->setIfExists('message', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets code - * - * @return int|null - */ - public function getCode() - { - return $this->container['code']; - } - - /** - * Sets code - * - * @param int|null $code code - * - * @return self - */ - public function setCode($code) - { - if (is_null($code)) { - throw new \InvalidArgumentException('non-nullable code cannot be null'); - } - $this->container['code'] = $code; - - return $this; - } - - /** - * Gets type - * - * @return string|null - */ - public function getType() - { - return $this->container['type']; - } - - /** - * Sets type - * - * @param string|null $type type - * - * @return self - */ - public function setType($type) - { - if (is_null($type)) { - throw new \InvalidArgumentException('non-nullable type cannot be null'); - } - $this->container['type'] = $type; - - return $this; - } - - /** - * Gets message - * - * @return string|null - */ - public function getMessage() - { - return $this->container['message']; - } - - /** - * Sets message - * - * @param string|null $message message - * - * @return self - */ - public function setMessage($message) - { - if (is_null($message)) { - throw new \InvalidArgumentException('non-nullable message cannot be null'); - } - $this->container['message'] = $message; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php deleted file mode 100644 index b09e0c111bc..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ArrayOfArrayOfNumberOnly'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'array_array_number' => 'float[][]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'array_array_number' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'array_array_number' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'array_array_number' => 'ArrayArrayNumber' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'array_array_number' => 'setArrayArrayNumber' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'array_array_number' => 'getArrayArrayNumber' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('array_array_number', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets array_array_number - * - * @return float[][]|null - */ - public function getArrayArrayNumber() - { - return $this->container['array_array_number']; - } - - /** - * Sets array_array_number - * - * @param float[][]|null $array_array_number array_array_number - * - * @return self - */ - public function setArrayArrayNumber($array_array_number) - { - if (is_null($array_array_number)) { - throw new \InvalidArgumentException('non-nullable array_array_number cannot be null'); - } - $this->container['array_array_number'] = $array_array_number; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php deleted file mode 100644 index 27606ad1816..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class ArrayOfNumberOnly implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ArrayOfNumberOnly'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'array_number' => 'float[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'array_number' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'array_number' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'array_number' => 'ArrayNumber' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'array_number' => 'setArrayNumber' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'array_number' => 'getArrayNumber' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('array_number', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets array_number - * - * @return float[]|null - */ - public function getArrayNumber() - { - return $this->container['array_number']; - } - - /** - * Sets array_number - * - * @param float[]|null $array_number array_number - * - * @return self - */ - public function setArrayNumber($array_number) - { - if (is_null($array_number)) { - throw new \InvalidArgumentException('non-nullable array_number cannot be null'); - } - $this->container['array_number'] = $array_number; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayTest.php deleted file mode 100644 index f8da0740ca5..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ArrayTest.php +++ /dev/null @@ -1,492 +0,0 @@ - - */ -class ArrayTest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ArrayTest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'array_of_string' => 'string[]', - 'array_array_of_integer' => 'int[][]', - 'array_array_of_model' => '\OpenAPI\Client\Model\ReadOnlyFirst[][]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'array_of_string' => null, - 'array_array_of_integer' => 'int64', - 'array_array_of_model' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'array_of_string' => false, - 'array_array_of_integer' => false, - 'array_array_of_model' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'array_of_string' => 'array_of_string', - 'array_array_of_integer' => 'array_array_of_integer', - 'array_array_of_model' => 'array_array_of_model' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'array_of_string' => 'setArrayOfString', - 'array_array_of_integer' => 'setArrayArrayOfInteger', - 'array_array_of_model' => 'setArrayArrayOfModel' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'array_of_string' => 'getArrayOfString', - 'array_array_of_integer' => 'getArrayArrayOfInteger', - 'array_array_of_model' => 'getArrayArrayOfModel' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('array_of_string', $data ?? [], null); - $this->setIfExists('array_array_of_integer', $data ?? [], null); - $this->setIfExists('array_array_of_model', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if (!is_null($this->container['array_of_string']) && (count($this->container['array_of_string']) > 3)) { - $invalidProperties[] = "invalid value for 'array_of_string', number of items must be less than or equal to 3."; - } - - if (!is_null($this->container['array_of_string']) && (count($this->container['array_of_string']) < 0)) { - $invalidProperties[] = "invalid value for 'array_of_string', number of items must be greater than or equal to 0."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets array_of_string - * - * @return string[]|null - */ - public function getArrayOfString() - { - return $this->container['array_of_string']; - } - - /** - * Sets array_of_string - * - * @param string[]|null $array_of_string array_of_string - * - * @return self - */ - public function setArrayOfString($array_of_string) - { - if (is_null($array_of_string)) { - throw new \InvalidArgumentException('non-nullable array_of_string cannot be null'); - } - - if ((count($array_of_string) > 3)) { - throw new \InvalidArgumentException('invalid value for $array_of_string when calling ArrayTest., number of items must be less than or equal to 3.'); - } - if ((count($array_of_string) < 0)) { - throw new \InvalidArgumentException('invalid length for $array_of_string when calling ArrayTest., number of items must be greater than or equal to 0.'); - } - $this->container['array_of_string'] = $array_of_string; - - return $this; - } - - /** - * Gets array_array_of_integer - * - * @return int[][]|null - */ - public function getArrayArrayOfInteger() - { - return $this->container['array_array_of_integer']; - } - - /** - * Sets array_array_of_integer - * - * @param int[][]|null $array_array_of_integer array_array_of_integer - * - * @return self - */ - public function setArrayArrayOfInteger($array_array_of_integer) - { - if (is_null($array_array_of_integer)) { - throw new \InvalidArgumentException('non-nullable array_array_of_integer cannot be null'); - } - $this->container['array_array_of_integer'] = $array_array_of_integer; - - return $this; - } - - /** - * Gets array_array_of_model - * - * @return \OpenAPI\Client\Model\ReadOnlyFirst[][]|null - */ - public function getArrayArrayOfModel() - { - return $this->container['array_array_of_model']; - } - - /** - * Sets array_array_of_model - * - * @param \OpenAPI\Client\Model\ReadOnlyFirst[][]|null $array_array_of_model array_array_of_model - * - * @return self - */ - public function setArrayArrayOfModel($array_array_of_model) - { - if (is_null($array_array_of_model)) { - throw new \InvalidArgumentException('non-nullable array_array_of_model cannot be null'); - } - $this->container['array_array_of_model'] = $array_array_of_model; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Capitalization.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Capitalization.php deleted file mode 100644 index 1bbb0ff5dcd..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Capitalization.php +++ /dev/null @@ -1,579 +0,0 @@ - - */ -class Capitalization implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Capitalization'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'small_camel' => 'string', - 'capital_camel' => 'string', - 'small_snake' => 'string', - 'capital_snake' => 'string', - 'sca_eth_flow_points' => 'string', - 'att_name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'small_camel' => null, - 'capital_camel' => null, - 'small_snake' => null, - 'capital_snake' => null, - 'sca_eth_flow_points' => null, - 'att_name' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'small_camel' => false, - 'capital_camel' => false, - 'small_snake' => false, - 'capital_snake' => false, - 'sca_eth_flow_points' => false, - 'att_name' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'small_camel' => 'smallCamel', - 'capital_camel' => 'CapitalCamel', - 'small_snake' => 'small_Snake', - 'capital_snake' => 'Capital_Snake', - 'sca_eth_flow_points' => 'SCA_ETH_Flow_Points', - 'att_name' => 'ATT_NAME' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'small_camel' => 'setSmallCamel', - 'capital_camel' => 'setCapitalCamel', - 'small_snake' => 'setSmallSnake', - 'capital_snake' => 'setCapitalSnake', - 'sca_eth_flow_points' => 'setScaEthFlowPoints', - 'att_name' => 'setAttName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'small_camel' => 'getSmallCamel', - 'capital_camel' => 'getCapitalCamel', - 'small_snake' => 'getSmallSnake', - 'capital_snake' => 'getCapitalSnake', - 'sca_eth_flow_points' => 'getScaEthFlowPoints', - 'att_name' => 'getAttName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('small_camel', $data ?? [], null); - $this->setIfExists('capital_camel', $data ?? [], null); - $this->setIfExists('small_snake', $data ?? [], null); - $this->setIfExists('capital_snake', $data ?? [], null); - $this->setIfExists('sca_eth_flow_points', $data ?? [], null); - $this->setIfExists('att_name', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets small_camel - * - * @return string|null - */ - public function getSmallCamel() - { - return $this->container['small_camel']; - } - - /** - * Sets small_camel - * - * @param string|null $small_camel small_camel - * - * @return self - */ - public function setSmallCamel($small_camel) - { - if (is_null($small_camel)) { - throw new \InvalidArgumentException('non-nullable small_camel cannot be null'); - } - $this->container['small_camel'] = $small_camel; - - return $this; - } - - /** - * Gets capital_camel - * - * @return string|null - */ - public function getCapitalCamel() - { - return $this->container['capital_camel']; - } - - /** - * Sets capital_camel - * - * @param string|null $capital_camel capital_camel - * - * @return self - */ - public function setCapitalCamel($capital_camel) - { - if (is_null($capital_camel)) { - throw new \InvalidArgumentException('non-nullable capital_camel cannot be null'); - } - $this->container['capital_camel'] = $capital_camel; - - return $this; - } - - /** - * Gets small_snake - * - * @return string|null - */ - public function getSmallSnake() - { - return $this->container['small_snake']; - } - - /** - * Sets small_snake - * - * @param string|null $small_snake small_snake - * - * @return self - */ - public function setSmallSnake($small_snake) - { - if (is_null($small_snake)) { - throw new \InvalidArgumentException('non-nullable small_snake cannot be null'); - } - $this->container['small_snake'] = $small_snake; - - return $this; - } - - /** - * Gets capital_snake - * - * @return string|null - */ - public function getCapitalSnake() - { - return $this->container['capital_snake']; - } - - /** - * Sets capital_snake - * - * @param string|null $capital_snake capital_snake - * - * @return self - */ - public function setCapitalSnake($capital_snake) - { - if (is_null($capital_snake)) { - throw new \InvalidArgumentException('non-nullable capital_snake cannot be null'); - } - $this->container['capital_snake'] = $capital_snake; - - return $this; - } - - /** - * Gets sca_eth_flow_points - * - * @return string|null - */ - public function getScaEthFlowPoints() - { - return $this->container['sca_eth_flow_points']; - } - - /** - * Sets sca_eth_flow_points - * - * @param string|null $sca_eth_flow_points sca_eth_flow_points - * - * @return self - */ - public function setScaEthFlowPoints($sca_eth_flow_points) - { - if (is_null($sca_eth_flow_points)) { - throw new \InvalidArgumentException('non-nullable sca_eth_flow_points cannot be null'); - } - $this->container['sca_eth_flow_points'] = $sca_eth_flow_points; - - return $this; - } - - /** - * Gets att_name - * - * @return string|null - */ - public function getAttName() - { - return $this->container['att_name']; - } - - /** - * Sets att_name - * - * @param string|null $att_name Name of the pet - * - * @return self - */ - public function setAttName($att_name) - { - if (is_null($att_name)) { - throw new \InvalidArgumentException('non-nullable att_name cannot be null'); - } - $this->container['att_name'] = $att_name; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Cat.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Cat.php deleted file mode 100644 index 08f6ce14576..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Cat.php +++ /dev/null @@ -1,403 +0,0 @@ - - */ -class Cat extends Animal -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Cat'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'declawed' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'declawed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'declawed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables + parent::openAPINullables(); - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'declawed' => 'declawed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'declawed' => 'setDeclawed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'declawed' => 'getDeclawed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->setIfExists('declawed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets declawed - * - * @return bool|null - */ - public function getDeclawed() - { - return $this->container['declawed']; - } - - /** - * Sets declawed - * - * @param bool|null $declawed declawed - * - * @return self - */ - public function setDeclawed($declawed) - { - if (is_null($declawed)) { - throw new \InvalidArgumentException('non-nullable declawed cannot be null'); - } - $this->container['declawed'] = $declawed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/CatAllOf.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/CatAllOf.php deleted file mode 100644 index 823c4a7bb3b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/CatAllOf.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class CatAllOf implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Cat_allOf'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'declawed' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'declawed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'declawed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'declawed' => 'declawed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'declawed' => 'setDeclawed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'declawed' => 'getDeclawed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('declawed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets declawed - * - * @return bool|null - */ - public function getDeclawed() - { - return $this->container['declawed']; - } - - /** - * Sets declawed - * - * @param bool|null $declawed declawed - * - * @return self - */ - public function setDeclawed($declawed) - { - if (is_null($declawed)) { - throw new \InvalidArgumentException('non-nullable declawed cannot be null'); - } - $this->container['declawed'] = $declawed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Category.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Category.php deleted file mode 100644 index 1b3778ef9bf..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Category.php +++ /dev/null @@ -1,446 +0,0 @@ - - */ -class Category implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Category'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'int', - 'name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'id' => 'int64', - 'name' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'id' => false, - 'name' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'name' => 'setName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'name' => 'getName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('name', $data ?? [], 'default-name'); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return int|null - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets name - * - * @return string - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param string $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ClassModel.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ClassModel.php deleted file mode 100644 index 37689b34d46..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ClassModel.php +++ /dev/null @@ -1,410 +0,0 @@ - - */ -class ClassModel implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ClassModel'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - '_class' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - '_class' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - '_class' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - '_class' => '_class' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - '_class' => 'setClass' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - '_class' => 'getClass' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('_class', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets _class - * - * @return string|null - */ - public function getClass() - { - return $this->container['_class']; - } - - /** - * Sets _class - * - * @param string|null $_class _class - * - * @return self - */ - public function setClass($_class) - { - if (is_null($_class)) { - throw new \InvalidArgumentException('non-nullable _class cannot be null'); - } - $this->container['_class'] = $_class; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Client.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Client.php deleted file mode 100644 index 8e1156b2af8..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Client.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class Client implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Client'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'client' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'client' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'client' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'client' => 'client' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'client' => 'setClient' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'client' => 'getClient' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('client', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets client - * - * @return string|null - */ - public function getClient() - { - return $this->container['client']; - } - - /** - * Sets client - * - * @param string|null $client client - * - * @return self - */ - public function setClient($client) - { - if (is_null($client)) { - throw new \InvalidArgumentException('non-nullable client cannot be null'); - } - $this->container['client'] = $client; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DeprecatedObject.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DeprecatedObject.php deleted file mode 100644 index 29d7f737040..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DeprecatedObject.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class DeprecatedObject implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'DeprecatedObject'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'name' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'name' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'name' => 'setName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'name' => 'getName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('name', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets name - * - * @return string|null - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param string|null $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Dog.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Dog.php deleted file mode 100644 index f07e9a454d8..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Dog.php +++ /dev/null @@ -1,403 +0,0 @@ - - */ -class Dog extends Animal -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Dog'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'breed' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'breed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'breed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes + parent::openAPITypes(); - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats + parent::openAPIFormats(); - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables + parent::openAPINullables(); - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'breed' => 'breed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'breed' => 'setBreed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'breed' => 'getBreed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return parent::attributeMap() + self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return parent::setters() + self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return parent::getters() + self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - parent::__construct($data); - - $this->setIfExists('breed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = parent::listInvalidProperties(); - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets breed - * - * @return string|null - */ - public function getBreed() - { - return $this->container['breed']; - } - - /** - * Sets breed - * - * @param string|null $breed breed - * - * @return self - */ - public function setBreed($breed) - { - if (is_null($breed)) { - throw new \InvalidArgumentException('non-nullable breed cannot be null'); - } - $this->container['breed'] = $breed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DogAllOf.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DogAllOf.php deleted file mode 100644 index f35440ead3b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/DogAllOf.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class DogAllOf implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Dog_allOf'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'breed' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'breed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'breed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'breed' => 'breed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'breed' => 'setBreed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'breed' => 'getBreed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('breed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets breed - * - * @return string|null - */ - public function getBreed() - { - return $this->container['breed']; - } - - /** - * Sets breed - * - * @param string|null $breed breed - * - * @return self - */ - public function setBreed($breed) - { - if (is_null($breed)) { - throw new \InvalidArgumentException('non-nullable breed cannot be null'); - } - $this->container['breed'] = $breed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumArrays.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumArrays.php deleted file mode 100644 index eeb2b7c00ee..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumArrays.php +++ /dev/null @@ -1,501 +0,0 @@ - - */ -class EnumArrays implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'EnumArrays'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'just_symbol' => 'string', - 'array_enum' => 'string[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'just_symbol' => null, - 'array_enum' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'just_symbol' => false, - 'array_enum' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'just_symbol' => 'just_symbol', - 'array_enum' => 'array_enum' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'just_symbol' => 'setJustSymbol', - 'array_enum' => 'setArrayEnum' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'just_symbol' => 'getJustSymbol', - 'array_enum' => 'getArrayEnum' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>='; - public const JUST_SYMBOL_DOLLAR = '$'; - public const ARRAY_ENUM_FISH = 'fish'; - public const ARRAY_ENUM_CRAB = 'crab'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getJustSymbolAllowableValues() - { - return [ - self::JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO, - self::JUST_SYMBOL_DOLLAR, - ]; - } - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getArrayEnumAllowableValues() - { - return [ - self::ARRAY_ENUM_FISH, - self::ARRAY_ENUM_CRAB, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('just_symbol', $data ?? [], null); - $this->setIfExists('array_enum', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - $allowedValues = $this->getJustSymbolAllowableValues(); - if (!is_null($this->container['just_symbol']) && !in_array($this->container['just_symbol'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'just_symbol', must be one of '%s'", - $this->container['just_symbol'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets just_symbol - * - * @return string|null - */ - public function getJustSymbol() - { - return $this->container['just_symbol']; - } - - /** - * Sets just_symbol - * - * @param string|null $just_symbol just_symbol - * - * @return self - */ - public function setJustSymbol($just_symbol) - { - if (is_null($just_symbol)) { - throw new \InvalidArgumentException('non-nullable just_symbol cannot be null'); - } - $allowedValues = $this->getJustSymbolAllowableValues(); - if (!in_array($just_symbol, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'just_symbol', must be one of '%s'", - $just_symbol, - implode("', '", $allowedValues) - ) - ); - } - $this->container['just_symbol'] = $just_symbol; - - return $this; - } - - /** - * Gets array_enum - * - * @return string[]|null - */ - public function getArrayEnum() - { - return $this->container['array_enum']; - } - - /** - * Sets array_enum - * - * @param string[]|null $array_enum array_enum - * - * @return self - */ - public function setArrayEnum($array_enum) - { - if (is_null($array_enum)) { - throw new \InvalidArgumentException('non-nullable array_enum cannot be null'); - } - $allowedValues = $this->getArrayEnumAllowableValues(); - if (array_diff($array_enum, $allowedValues)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value for 'array_enum', must be one of '%s'", - implode("', '", $allowedValues) - ) - ); - } - $this->container['array_enum'] = $array_enum; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumClass.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumClass.php deleted file mode 100644 index ace27356ba5..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/EnumClass.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class EnumTest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Enum_Test'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'enum_string' => 'string', - 'enum_string_required' => 'string', - 'enum_integer' => 'int', - 'enum_number' => 'float', - 'outer_enum' => '\OpenAPI\Client\Model\OuterEnum', - 'outer_enum_integer' => '\OpenAPI\Client\Model\OuterEnumInteger', - 'outer_enum_default_value' => '\OpenAPI\Client\Model\OuterEnumDefaultValue', - 'outer_enum_integer_default_value' => '\OpenAPI\Client\Model\OuterEnumIntegerDefaultValue' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'enum_string' => null, - 'enum_string_required' => null, - 'enum_integer' => 'int32', - 'enum_number' => 'double', - 'outer_enum' => null, - 'outer_enum_integer' => null, - 'outer_enum_default_value' => null, - 'outer_enum_integer_default_value' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'enum_string' => false, - 'enum_string_required' => false, - 'enum_integer' => false, - 'enum_number' => false, - 'outer_enum' => true, - 'outer_enum_integer' => false, - 'outer_enum_default_value' => false, - 'outer_enum_integer_default_value' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'enum_string' => 'enum_string', - 'enum_string_required' => 'enum_string_required', - 'enum_integer' => 'enum_integer', - 'enum_number' => 'enum_number', - 'outer_enum' => 'outerEnum', - 'outer_enum_integer' => 'outerEnumInteger', - 'outer_enum_default_value' => 'outerEnumDefaultValue', - 'outer_enum_integer_default_value' => 'outerEnumIntegerDefaultValue' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'enum_string' => 'setEnumString', - 'enum_string_required' => 'setEnumStringRequired', - 'enum_integer' => 'setEnumInteger', - 'enum_number' => 'setEnumNumber', - 'outer_enum' => 'setOuterEnum', - 'outer_enum_integer' => 'setOuterEnumInteger', - 'outer_enum_default_value' => 'setOuterEnumDefaultValue', - 'outer_enum_integer_default_value' => 'setOuterEnumIntegerDefaultValue' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'enum_string' => 'getEnumString', - 'enum_string_required' => 'getEnumStringRequired', - 'enum_integer' => 'getEnumInteger', - 'enum_number' => 'getEnumNumber', - 'outer_enum' => 'getOuterEnum', - 'outer_enum_integer' => 'getOuterEnumInteger', - 'outer_enum_default_value' => 'getOuterEnumDefaultValue', - 'outer_enum_integer_default_value' => 'getOuterEnumIntegerDefaultValue' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const ENUM_STRING_UPPER = 'UPPER'; - public const ENUM_STRING_LOWER = 'lower'; - public const ENUM_STRING_EMPTY = ''; - public const ENUM_STRING_REQUIRED_UPPER = 'UPPER'; - public const ENUM_STRING_REQUIRED_LOWER = 'lower'; - public const ENUM_STRING_REQUIRED_EMPTY = ''; - public const ENUM_INTEGER_1 = 1; - public const ENUM_INTEGER_MINUS_1 = -1; - public const ENUM_NUMBER_1_DOT_1 = 1.1; - public const ENUM_NUMBER_MINUS_1_DOT_2 = -1.2; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getEnumStringAllowableValues() - { - return [ - self::ENUM_STRING_UPPER, - self::ENUM_STRING_LOWER, - self::ENUM_STRING_EMPTY, - ]; - } - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getEnumStringRequiredAllowableValues() - { - return [ - self::ENUM_STRING_REQUIRED_UPPER, - self::ENUM_STRING_REQUIRED_LOWER, - self::ENUM_STRING_REQUIRED_EMPTY, - ]; - } - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getEnumIntegerAllowableValues() - { - return [ - self::ENUM_INTEGER_1, - self::ENUM_INTEGER_MINUS_1, - ]; - } - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getEnumNumberAllowableValues() - { - return [ - self::ENUM_NUMBER_1_DOT_1, - self::ENUM_NUMBER_MINUS_1_DOT_2, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('enum_string', $data ?? [], null); - $this->setIfExists('enum_string_required', $data ?? [], null); - $this->setIfExists('enum_integer', $data ?? [], null); - $this->setIfExists('enum_number', $data ?? [], null); - $this->setIfExists('outer_enum', $data ?? [], null); - $this->setIfExists('outer_enum_integer', $data ?? [], null); - $this->setIfExists('outer_enum_default_value', $data ?? [], null); - $this->setIfExists('outer_enum_integer_default_value', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - $allowedValues = $this->getEnumStringAllowableValues(); - if (!is_null($this->container['enum_string']) && !in_array($this->container['enum_string'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'enum_string', must be one of '%s'", - $this->container['enum_string'], - implode("', '", $allowedValues) - ); - } - - if ($this->container['enum_string_required'] === null) { - $invalidProperties[] = "'enum_string_required' can't be null"; - } - $allowedValues = $this->getEnumStringRequiredAllowableValues(); - if (!is_null($this->container['enum_string_required']) && !in_array($this->container['enum_string_required'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'enum_string_required', must be one of '%s'", - $this->container['enum_string_required'], - implode("', '", $allowedValues) - ); - } - - $allowedValues = $this->getEnumIntegerAllowableValues(); - if (!is_null($this->container['enum_integer']) && !in_array($this->container['enum_integer'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'enum_integer', must be one of '%s'", - $this->container['enum_integer'], - implode("', '", $allowedValues) - ); - } - - $allowedValues = $this->getEnumNumberAllowableValues(); - if (!is_null($this->container['enum_number']) && !in_array($this->container['enum_number'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'enum_number', must be one of '%s'", - $this->container['enum_number'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets enum_string - * - * @return string|null - */ - public function getEnumString() - { - return $this->container['enum_string']; - } - - /** - * Sets enum_string - * - * @param string|null $enum_string enum_string - * - * @return self - */ - public function setEnumString($enum_string) - { - if (is_null($enum_string)) { - throw new \InvalidArgumentException('non-nullable enum_string cannot be null'); - } - $allowedValues = $this->getEnumStringAllowableValues(); - if (!in_array($enum_string, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'enum_string', must be one of '%s'", - $enum_string, - implode("', '", $allowedValues) - ) - ); - } - $this->container['enum_string'] = $enum_string; - - return $this; - } - - /** - * Gets enum_string_required - * - * @return string - */ - public function getEnumStringRequired() - { - return $this->container['enum_string_required']; - } - - /** - * Sets enum_string_required - * - * @param string $enum_string_required enum_string_required - * - * @return self - */ - public function setEnumStringRequired($enum_string_required) - { - if (is_null($enum_string_required)) { - throw new \InvalidArgumentException('non-nullable enum_string_required cannot be null'); - } - $allowedValues = $this->getEnumStringRequiredAllowableValues(); - if (!in_array($enum_string_required, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'enum_string_required', must be one of '%s'", - $enum_string_required, - implode("', '", $allowedValues) - ) - ); - } - $this->container['enum_string_required'] = $enum_string_required; - - return $this; - } - - /** - * Gets enum_integer - * - * @return int|null - */ - public function getEnumInteger() - { - return $this->container['enum_integer']; - } - - /** - * Sets enum_integer - * - * @param int|null $enum_integer enum_integer - * - * @return self - */ - public function setEnumInteger($enum_integer) - { - if (is_null($enum_integer)) { - throw new \InvalidArgumentException('non-nullable enum_integer cannot be null'); - } - $allowedValues = $this->getEnumIntegerAllowableValues(); - if (!in_array($enum_integer, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'enum_integer', must be one of '%s'", - $enum_integer, - implode("', '", $allowedValues) - ) - ); - } - $this->container['enum_integer'] = $enum_integer; - - return $this; - } - - /** - * Gets enum_number - * - * @return float|null - */ - public function getEnumNumber() - { - return $this->container['enum_number']; - } - - /** - * Sets enum_number - * - * @param float|null $enum_number enum_number - * - * @return self - */ - public function setEnumNumber($enum_number) - { - if (is_null($enum_number)) { - throw new \InvalidArgumentException('non-nullable enum_number cannot be null'); - } - $allowedValues = $this->getEnumNumberAllowableValues(); - if (!in_array($enum_number, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'enum_number', must be one of '%s'", - $enum_number, - implode("', '", $allowedValues) - ) - ); - } - $this->container['enum_number'] = $enum_number; - - return $this; - } - - /** - * Gets outer_enum - * - * @return \OpenAPI\Client\Model\OuterEnum|null - */ - public function getOuterEnum() - { - return $this->container['outer_enum']; - } - - /** - * Sets outer_enum - * - * @param \OpenAPI\Client\Model\OuterEnum|null $outer_enum outer_enum - * - * @return self - */ - public function setOuterEnum($outer_enum) - { - if (is_null($outer_enum)) { - array_push($this->openAPINullablesSetToNull, 'outer_enum'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('outer_enum', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['outer_enum'] = $outer_enum; - - return $this; - } - - /** - * Gets outer_enum_integer - * - * @return \OpenAPI\Client\Model\OuterEnumInteger|null - */ - public function getOuterEnumInteger() - { - return $this->container['outer_enum_integer']; - } - - /** - * Sets outer_enum_integer - * - * @param \OpenAPI\Client\Model\OuterEnumInteger|null $outer_enum_integer outer_enum_integer - * - * @return self - */ - public function setOuterEnumInteger($outer_enum_integer) - { - if (is_null($outer_enum_integer)) { - throw new \InvalidArgumentException('non-nullable outer_enum_integer cannot be null'); - } - $this->container['outer_enum_integer'] = $outer_enum_integer; - - return $this; - } - - /** - * Gets outer_enum_default_value - * - * @return \OpenAPI\Client\Model\OuterEnumDefaultValue|null - */ - public function getOuterEnumDefaultValue() - { - return $this->container['outer_enum_default_value']; - } - - /** - * Sets outer_enum_default_value - * - * @param \OpenAPI\Client\Model\OuterEnumDefaultValue|null $outer_enum_default_value outer_enum_default_value - * - * @return self - */ - public function setOuterEnumDefaultValue($outer_enum_default_value) - { - if (is_null($outer_enum_default_value)) { - throw new \InvalidArgumentException('non-nullable outer_enum_default_value cannot be null'); - } - $this->container['outer_enum_default_value'] = $outer_enum_default_value; - - return $this; - } - - /** - * Gets outer_enum_integer_default_value - * - * @return \OpenAPI\Client\Model\OuterEnumIntegerDefaultValue|null - */ - public function getOuterEnumIntegerDefaultValue() - { - return $this->container['outer_enum_integer_default_value']; - } - - /** - * Sets outer_enum_integer_default_value - * - * @param \OpenAPI\Client\Model\OuterEnumIntegerDefaultValue|null $outer_enum_integer_default_value outer_enum_integer_default_value - * - * @return self - */ - public function setOuterEnumIntegerDefaultValue($outer_enum_integer_default_value) - { - if (is_null($outer_enum_integer_default_value)) { - throw new \InvalidArgumentException('non-nullable outer_enum_integer_default_value cannot be null'); - } - $this->container['outer_enum_integer_default_value'] = $outer_enum_integer_default_value; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/File.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/File.php deleted file mode 100644 index 5227ccccf76..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/File.php +++ /dev/null @@ -1,410 +0,0 @@ - - */ -class File implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'File'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'source_uri' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'source_uri' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'source_uri' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'source_uri' => 'sourceURI' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'source_uri' => 'setSourceUri' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'source_uri' => 'getSourceUri' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('source_uri', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets source_uri - * - * @return string|null - */ - public function getSourceUri() - { - return $this->container['source_uri']; - } - - /** - * Sets source_uri - * - * @param string|null $source_uri Test capitalization - * - * @return self - */ - public function setSourceUri($source_uri) - { - if (is_null($source_uri)) { - throw new \InvalidArgumentException('non-nullable source_uri cannot be null'); - } - $this->container['source_uri'] = $source_uri; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php deleted file mode 100644 index 40477eccf03..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FileSchemaTestClass.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class FileSchemaTestClass implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'FileSchemaTestClass'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'file' => '\OpenAPI\Client\Model\File', - 'files' => '\OpenAPI\Client\Model\File[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'file' => null, - 'files' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'file' => false, - 'files' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'file' => 'file', - 'files' => 'files' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'file' => 'setFile', - 'files' => 'setFiles' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'file' => 'getFile', - 'files' => 'getFiles' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('file', $data ?? [], null); - $this->setIfExists('files', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets file - * - * @return \OpenAPI\Client\Model\File|null - */ - public function getFile() - { - return $this->container['file']; - } - - /** - * Sets file - * - * @param \OpenAPI\Client\Model\File|null $file file - * - * @return self - */ - public function setFile($file) - { - if (is_null($file)) { - throw new \InvalidArgumentException('non-nullable file cannot be null'); - } - $this->container['file'] = $file; - - return $this; - } - - /** - * Gets files - * - * @return \OpenAPI\Client\Model\File[]|null - */ - public function getFiles() - { - return $this->container['files']; - } - - /** - * Sets files - * - * @param \OpenAPI\Client\Model\File[]|null $files files - * - * @return self - */ - public function setFiles($files) - { - if (is_null($files)) { - throw new \InvalidArgumentException('non-nullable files cannot be null'); - } - $this->container['files'] = $files; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Foo.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Foo.php deleted file mode 100644 index 3f2bd008dee..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Foo.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class Foo implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Foo'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bar' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'bar' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'bar' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bar' => 'bar' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bar' => 'setBar' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bar' => 'getBar' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('bar', $data ?? [], 'bar'); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bar - * - * @return string|null - */ - public function getBar() - { - return $this->container['bar']; - } - - /** - * Sets bar - * - * @param string|null $bar bar - * - * @return self - */ - public function setBar($bar) - { - if (is_null($bar)) { - throw new \InvalidArgumentException('non-nullable bar cannot be null'); - } - $this->container['bar'] = $bar; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FooGetDefaultResponse.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FooGetDefaultResponse.php deleted file mode 100644 index f532f9e2e55..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FooGetDefaultResponse.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class FooGetDefaultResponse implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = '_foo_get_default_response'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'string' => '\OpenAPI\Client\Model\Foo' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'string' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'string' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'string' => 'string' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'string' => 'setString' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'string' => 'getString' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('string', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets string - * - * @return \OpenAPI\Client\Model\Foo|null - */ - public function getString() - { - return $this->container['string']; - } - - /** - * Sets string - * - * @param \OpenAPI\Client\Model\Foo|null $string string - * - * @return self - */ - public function setString($string) - { - if (is_null($string)) { - throw new \InvalidArgumentException('non-nullable string cannot be null'); - } - $this->container['string'] = $string; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FormatTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FormatTest.php deleted file mode 100644 index 4149df86c5c..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/FormatTest.php +++ /dev/null @@ -1,1053 +0,0 @@ - - */ -class FormatTest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'format_test'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'integer' => 'int', - 'int32' => 'int', - 'int64' => 'int', - 'number' => 'float', - 'float' => 'float', - 'double' => 'float', - 'decimal' => 'float', - 'string' => 'string', - 'byte' => 'string', - 'binary' => '\SplFileObject', - 'date' => '\DateTime', - 'date_time' => '\DateTime', - 'uuid' => 'string', - 'password' => 'string', - 'pattern_with_digits' => 'string', - 'pattern_with_digits_and_delimiter' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'integer' => null, - 'int32' => 'int32', - 'int64' => 'int64', - 'number' => null, - 'float' => 'float', - 'double' => 'double', - 'decimal' => 'number', - 'string' => null, - 'byte' => 'byte', - 'binary' => 'binary', - 'date' => 'date', - 'date_time' => 'date-time', - 'uuid' => 'uuid', - 'password' => 'password', - 'pattern_with_digits' => null, - 'pattern_with_digits_and_delimiter' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'integer' => false, - 'int32' => false, - 'int64' => false, - 'number' => false, - 'float' => false, - 'double' => false, - 'decimal' => false, - 'string' => false, - 'byte' => false, - 'binary' => false, - 'date' => false, - 'date_time' => false, - 'uuid' => false, - 'password' => false, - 'pattern_with_digits' => false, - 'pattern_with_digits_and_delimiter' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'integer' => 'integer', - 'int32' => 'int32', - 'int64' => 'int64', - 'number' => 'number', - 'float' => 'float', - 'double' => 'double', - 'decimal' => 'decimal', - 'string' => 'string', - 'byte' => 'byte', - 'binary' => 'binary', - 'date' => 'date', - 'date_time' => 'dateTime', - 'uuid' => 'uuid', - 'password' => 'password', - 'pattern_with_digits' => 'pattern_with_digits', - 'pattern_with_digits_and_delimiter' => 'pattern_with_digits_and_delimiter' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'integer' => 'setInteger', - 'int32' => 'setInt32', - 'int64' => 'setInt64', - 'number' => 'setNumber', - 'float' => 'setFloat', - 'double' => 'setDouble', - 'decimal' => 'setDecimal', - 'string' => 'setString', - 'byte' => 'setByte', - 'binary' => 'setBinary', - 'date' => 'setDate', - 'date_time' => 'setDateTime', - 'uuid' => 'setUuid', - 'password' => 'setPassword', - 'pattern_with_digits' => 'setPatternWithDigits', - 'pattern_with_digits_and_delimiter' => 'setPatternWithDigitsAndDelimiter' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'integer' => 'getInteger', - 'int32' => 'getInt32', - 'int64' => 'getInt64', - 'number' => 'getNumber', - 'float' => 'getFloat', - 'double' => 'getDouble', - 'decimal' => 'getDecimal', - 'string' => 'getString', - 'byte' => 'getByte', - 'binary' => 'getBinary', - 'date' => 'getDate', - 'date_time' => 'getDateTime', - 'uuid' => 'getUuid', - 'password' => 'getPassword', - 'pattern_with_digits' => 'getPatternWithDigits', - 'pattern_with_digits_and_delimiter' => 'getPatternWithDigitsAndDelimiter' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('integer', $data ?? [], null); - $this->setIfExists('int32', $data ?? [], null); - $this->setIfExists('int64', $data ?? [], null); - $this->setIfExists('number', $data ?? [], null); - $this->setIfExists('float', $data ?? [], null); - $this->setIfExists('double', $data ?? [], null); - $this->setIfExists('decimal', $data ?? [], null); - $this->setIfExists('string', $data ?? [], null); - $this->setIfExists('byte', $data ?? [], null); - $this->setIfExists('binary', $data ?? [], null); - $this->setIfExists('date', $data ?? [], null); - $this->setIfExists('date_time', $data ?? [], null); - $this->setIfExists('uuid', $data ?? [], null); - $this->setIfExists('password', $data ?? [], null); - $this->setIfExists('pattern_with_digits', $data ?? [], null); - $this->setIfExists('pattern_with_digits_and_delimiter', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if (!is_null($this->container['integer']) && ($this->container['integer'] > 100)) { - $invalidProperties[] = "invalid value for 'integer', must be smaller than or equal to 100."; - } - - if (!is_null($this->container['integer']) && ($this->container['integer'] < 10)) { - $invalidProperties[] = "invalid value for 'integer', must be bigger than or equal to 10."; - } - - if (!is_null($this->container['int32']) && ($this->container['int32'] > 200)) { - $invalidProperties[] = "invalid value for 'int32', must be smaller than or equal to 200."; - } - - if (!is_null($this->container['int32']) && ($this->container['int32'] < 20)) { - $invalidProperties[] = "invalid value for 'int32', must be bigger than or equal to 20."; - } - - if ($this->container['number'] === null) { - $invalidProperties[] = "'number' can't be null"; - } - if (($this->container['number'] > 543.2)) { - $invalidProperties[] = "invalid value for 'number', must be smaller than or equal to 543.2."; - } - - if (($this->container['number'] < 32.1)) { - $invalidProperties[] = "invalid value for 'number', must be bigger than or equal to 32.1."; - } - - if (!is_null($this->container['float']) && ($this->container['float'] > 987.6)) { - $invalidProperties[] = "invalid value for 'float', must be smaller than or equal to 987.6."; - } - - if (!is_null($this->container['float']) && ($this->container['float'] < 54.3)) { - $invalidProperties[] = "invalid value for 'float', must be bigger than or equal to 54.3."; - } - - if (!is_null($this->container['double']) && ($this->container['double'] > 123.4)) { - $invalidProperties[] = "invalid value for 'double', must be smaller than or equal to 123.4."; - } - - if (!is_null($this->container['double']) && ($this->container['double'] < 67.8)) { - $invalidProperties[] = "invalid value for 'double', must be bigger than or equal to 67.8."; - } - - if (!is_null($this->container['string']) && !preg_match("/[a-z]/i", $this->container['string'])) { - $invalidProperties[] = "invalid value for 'string', must be conform to the pattern /[a-z]/i."; - } - - if ($this->container['byte'] === null) { - $invalidProperties[] = "'byte' can't be null"; - } - if ($this->container['date'] === null) { - $invalidProperties[] = "'date' can't be null"; - } - if ($this->container['password'] === null) { - $invalidProperties[] = "'password' can't be null"; - } - if ((mb_strlen($this->container['password']) > 64)) { - $invalidProperties[] = "invalid value for 'password', the character length must be smaller than or equal to 64."; - } - - if ((mb_strlen($this->container['password']) < 10)) { - $invalidProperties[] = "invalid value for 'password', the character length must be bigger than or equal to 10."; - } - - if (!is_null($this->container['pattern_with_digits']) && !preg_match("/^\\d{10}$/", $this->container['pattern_with_digits'])) { - $invalidProperties[] = "invalid value for 'pattern_with_digits', must be conform to the pattern /^\\d{10}$/."; - } - - if (!is_null($this->container['pattern_with_digits_and_delimiter']) && !preg_match("/^image_\\d{1,3}$/i", $this->container['pattern_with_digits_and_delimiter'])) { - $invalidProperties[] = "invalid value for 'pattern_with_digits_and_delimiter', must be conform to the pattern /^image_\\d{1,3}$/i."; - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets integer - * - * @return int|null - */ - public function getInteger() - { - return $this->container['integer']; - } - - /** - * Sets integer - * - * @param int|null $integer integer - * - * @return self - */ - public function setInteger($integer) - { - if (is_null($integer)) { - throw new \InvalidArgumentException('non-nullable integer cannot be null'); - } - - if (($integer > 100)) { - throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be smaller than or equal to 100.'); - } - if (($integer < 10)) { - throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be bigger than or equal to 10.'); - } - - $this->container['integer'] = $integer; - - return $this; - } - - /** - * Gets int32 - * - * @return int|null - */ - public function getInt32() - { - return $this->container['int32']; - } - - /** - * Sets int32 - * - * @param int|null $int32 int32 - * - * @return self - */ - public function setInt32($int32) - { - if (is_null($int32)) { - throw new \InvalidArgumentException('non-nullable int32 cannot be null'); - } - - if (($int32 > 200)) { - throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be smaller than or equal to 200.'); - } - if (($int32 < 20)) { - throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be bigger than or equal to 20.'); - } - - $this->container['int32'] = $int32; - - return $this; - } - - /** - * Gets int64 - * - * @return int|null - */ - public function getInt64() - { - return $this->container['int64']; - } - - /** - * Sets int64 - * - * @param int|null $int64 int64 - * - * @return self - */ - public function setInt64($int64) - { - if (is_null($int64)) { - throw new \InvalidArgumentException('non-nullable int64 cannot be null'); - } - $this->container['int64'] = $int64; - - return $this; - } - - /** - * Gets number - * - * @return float - */ - public function getNumber() - { - return $this->container['number']; - } - - /** - * Sets number - * - * @param float $number number - * - * @return self - */ - public function setNumber($number) - { - if (is_null($number)) { - throw new \InvalidArgumentException('non-nullable number cannot be null'); - } - - if (($number > 543.2)) { - throw new \InvalidArgumentException('invalid value for $number when calling FormatTest., must be smaller than or equal to 543.2.'); - } - if (($number < 32.1)) { - throw new \InvalidArgumentException('invalid value for $number when calling FormatTest., must be bigger than or equal to 32.1.'); - } - - $this->container['number'] = $number; - - return $this; - } - - /** - * Gets float - * - * @return float|null - */ - public function getFloat() - { - return $this->container['float']; - } - - /** - * Sets float - * - * @param float|null $float float - * - * @return self - */ - public function setFloat($float) - { - if (is_null($float)) { - throw new \InvalidArgumentException('non-nullable float cannot be null'); - } - - if (($float > 987.6)) { - throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be smaller than or equal to 987.6.'); - } - if (($float < 54.3)) { - throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be bigger than or equal to 54.3.'); - } - - $this->container['float'] = $float; - - return $this; - } - - /** - * Gets double - * - * @return float|null - */ - public function getDouble() - { - return $this->container['double']; - } - - /** - * Sets double - * - * @param float|null $double double - * - * @return self - */ - public function setDouble($double) - { - if (is_null($double)) { - throw new \InvalidArgumentException('non-nullable double cannot be null'); - } - - if (($double > 123.4)) { - throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be smaller than or equal to 123.4.'); - } - if (($double < 67.8)) { - throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be bigger than or equal to 67.8.'); - } - - $this->container['double'] = $double; - - return $this; - } - - /** - * Gets decimal - * - * @return float|null - */ - public function getDecimal() - { - return $this->container['decimal']; - } - - /** - * Sets decimal - * - * @param float|null $decimal decimal - * - * @return self - */ - public function setDecimal($decimal) - { - if (is_null($decimal)) { - throw new \InvalidArgumentException('non-nullable decimal cannot be null'); - } - $this->container['decimal'] = $decimal; - - return $this; - } - - /** - * Gets string - * - * @return string|null - */ - public function getString() - { - return $this->container['string']; - } - - /** - * Sets string - * - * @param string|null $string string - * - * @return self - */ - public function setString($string) - { - if (is_null($string)) { - throw new \InvalidArgumentException('non-nullable string cannot be null'); - } - - if ((!preg_match("/[a-z]/i", $string))) { - throw new \InvalidArgumentException("invalid value for \$string when calling FormatTest., must conform to the pattern /[a-z]/i."); - } - - $this->container['string'] = $string; - - return $this; - } - - /** - * Gets byte - * - * @return string - */ - public function getByte() - { - return $this->container['byte']; - } - - /** - * Sets byte - * - * @param string $byte byte - * - * @return self - */ - public function setByte($byte) - { - if (is_null($byte)) { - throw new \InvalidArgumentException('non-nullable byte cannot be null'); - } - $this->container['byte'] = $byte; - - return $this; - } - - /** - * Gets binary - * - * @return \SplFileObject|null - */ - public function getBinary() - { - return $this->container['binary']; - } - - /** - * Sets binary - * - * @param \SplFileObject|null $binary binary - * - * @return self - */ - public function setBinary($binary) - { - if (is_null($binary)) { - throw new \InvalidArgumentException('non-nullable binary cannot be null'); - } - $this->container['binary'] = $binary; - - return $this; - } - - /** - * Gets date - * - * @return \DateTime - */ - public function getDate() - { - return $this->container['date']; - } - - /** - * Sets date - * - * @param \DateTime $date date - * - * @return self - */ - public function setDate($date) - { - if (is_null($date)) { - throw new \InvalidArgumentException('non-nullable date cannot be null'); - } - $this->container['date'] = $date; - - return $this; - } - - /** - * Gets date_time - * - * @return \DateTime|null - */ - public function getDateTime() - { - return $this->container['date_time']; - } - - /** - * Sets date_time - * - * @param \DateTime|null $date_time date_time - * - * @return self - */ - public function setDateTime($date_time) - { - if (is_null($date_time)) { - throw new \InvalidArgumentException('non-nullable date_time cannot be null'); - } - $this->container['date_time'] = $date_time; - - return $this; - } - - /** - * Gets uuid - * - * @return string|null - */ - public function getUuid() - { - return $this->container['uuid']; - } - - /** - * Sets uuid - * - * @param string|null $uuid uuid - * - * @return self - */ - public function setUuid($uuid) - { - if (is_null($uuid)) { - throw new \InvalidArgumentException('non-nullable uuid cannot be null'); - } - $this->container['uuid'] = $uuid; - - return $this; - } - - /** - * Gets password - * - * @return string - */ - public function getPassword() - { - return $this->container['password']; - } - - /** - * Sets password - * - * @param string $password password - * - * @return self - */ - public function setPassword($password) - { - if (is_null($password)) { - throw new \InvalidArgumentException('non-nullable password cannot be null'); - } - if ((mb_strlen($password) > 64)) { - throw new \InvalidArgumentException('invalid length for $password when calling FormatTest., must be smaller than or equal to 64.'); - } - if ((mb_strlen($password) < 10)) { - throw new \InvalidArgumentException('invalid length for $password when calling FormatTest., must be bigger than or equal to 10.'); - } - - $this->container['password'] = $password; - - return $this; - } - - /** - * Gets pattern_with_digits - * - * @return string|null - */ - public function getPatternWithDigits() - { - return $this->container['pattern_with_digits']; - } - - /** - * Sets pattern_with_digits - * - * @param string|null $pattern_with_digits A string that is a 10 digit number. Can have leading zeros. - * - * @return self - */ - public function setPatternWithDigits($pattern_with_digits) - { - if (is_null($pattern_with_digits)) { - throw new \InvalidArgumentException('non-nullable pattern_with_digits cannot be null'); - } - - if ((!preg_match("/^\\d{10}$/", $pattern_with_digits))) { - throw new \InvalidArgumentException("invalid value for \$pattern_with_digits when calling FormatTest., must conform to the pattern /^\\d{10}$/."); - } - - $this->container['pattern_with_digits'] = $pattern_with_digits; - - return $this; - } - - /** - * Gets pattern_with_digits_and_delimiter - * - * @return string|null - */ - public function getPatternWithDigitsAndDelimiter() - { - return $this->container['pattern_with_digits_and_delimiter']; - } - - /** - * Sets pattern_with_digits_and_delimiter - * - * @param string|null $pattern_with_digits_and_delimiter A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - * - * @return self - */ - public function setPatternWithDigitsAndDelimiter($pattern_with_digits_and_delimiter) - { - if (is_null($pattern_with_digits_and_delimiter)) { - throw new \InvalidArgumentException('non-nullable pattern_with_digits_and_delimiter cannot be null'); - } - - if ((!preg_match("/^image_\\d{1,3}$/i", $pattern_with_digits_and_delimiter))) { - throw new \InvalidArgumentException("invalid value for \$pattern_with_digits_and_delimiter when calling FormatTest., must conform to the pattern /^image_\\d{1,3}$/i."); - } - - $this->container['pattern_with_digits_and_delimiter'] = $pattern_with_digits_and_delimiter; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php deleted file mode 100644 index baa160cc19b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class HasOnlyReadOnly implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'hasOnlyReadOnly'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bar' => 'string', - 'foo' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'bar' => null, - 'foo' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'bar' => false, - 'foo' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bar' => 'bar', - 'foo' => 'foo' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bar' => 'setBar', - 'foo' => 'setFoo' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bar' => 'getBar', - 'foo' => 'getFoo' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('bar', $data ?? [], null); - $this->setIfExists('foo', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bar - * - * @return string|null - */ - public function getBar() - { - return $this->container['bar']; - } - - /** - * Sets bar - * - * @param string|null $bar bar - * - * @return self - */ - public function setBar($bar) - { - if (is_null($bar)) { - throw new \InvalidArgumentException('non-nullable bar cannot be null'); - } - $this->container['bar'] = $bar; - - return $this; - } - - /** - * Gets foo - * - * @return string|null - */ - public function getFoo() - { - return $this->container['foo']; - } - - /** - * Sets foo - * - * @param string|null $foo foo - * - * @return self - */ - public function setFoo($foo) - { - if (is_null($foo)) { - throw new \InvalidArgumentException('non-nullable foo cannot be null'); - } - $this->container['foo'] = $foo; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HealthCheckResult.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HealthCheckResult.php deleted file mode 100644 index 07ec049c096..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/HealthCheckResult.php +++ /dev/null @@ -1,417 +0,0 @@ - - */ -class HealthCheckResult implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'HealthCheckResult'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'nullable_message' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'nullable_message' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'nullable_message' => true - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'nullable_message' => 'NullableMessage' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'nullable_message' => 'setNullableMessage' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'nullable_message' => 'getNullableMessage' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('nullable_message', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets nullable_message - * - * @return string|null - */ - public function getNullableMessage() - { - return $this->container['nullable_message']; - } - - /** - * Sets nullable_message - * - * @param string|null $nullable_message nullable_message - * - * @return self - */ - public function setNullableMessage($nullable_message) - { - if (is_null($nullable_message)) { - array_push($this->openAPINullablesSetToNull, 'nullable_message'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('nullable_message', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['nullable_message'] = $nullable_message; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MapTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MapTest.php deleted file mode 100644 index 0bd72a04198..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MapTest.php +++ /dev/null @@ -1,535 +0,0 @@ - - */ -class MapTest implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'MapTest'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'map_map_of_string' => 'array>', - 'map_of_enum_string' => 'array', - 'direct_map' => 'array', - 'indirect_map' => 'array' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'map_map_of_string' => null, - 'map_of_enum_string' => null, - 'direct_map' => null, - 'indirect_map' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'map_map_of_string' => false, - 'map_of_enum_string' => false, - 'direct_map' => false, - 'indirect_map' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'map_map_of_string' => 'map_map_of_string', - 'map_of_enum_string' => 'map_of_enum_string', - 'direct_map' => 'direct_map', - 'indirect_map' => 'indirect_map' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'map_map_of_string' => 'setMapMapOfString', - 'map_of_enum_string' => 'setMapOfEnumString', - 'direct_map' => 'setDirectMap', - 'indirect_map' => 'setIndirectMap' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'map_map_of_string' => 'getMapMapOfString', - 'map_of_enum_string' => 'getMapOfEnumString', - 'direct_map' => 'getDirectMap', - 'indirect_map' => 'getIndirectMap' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const MAP_OF_ENUM_STRING_UPPER = 'UPPER'; - public const MAP_OF_ENUM_STRING_LOWER = 'lower'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getMapOfEnumStringAllowableValues() - { - return [ - self::MAP_OF_ENUM_STRING_UPPER, - self::MAP_OF_ENUM_STRING_LOWER, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('map_map_of_string', $data ?? [], null); - $this->setIfExists('map_of_enum_string', $data ?? [], null); - $this->setIfExists('direct_map', $data ?? [], null); - $this->setIfExists('indirect_map', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets map_map_of_string - * - * @return array>|null - */ - public function getMapMapOfString() - { - return $this->container['map_map_of_string']; - } - - /** - * Sets map_map_of_string - * - * @param array>|null $map_map_of_string map_map_of_string - * - * @return self - */ - public function setMapMapOfString($map_map_of_string) - { - if (is_null($map_map_of_string)) { - throw new \InvalidArgumentException('non-nullable map_map_of_string cannot be null'); - } - $this->container['map_map_of_string'] = $map_map_of_string; - - return $this; - } - - /** - * Gets map_of_enum_string - * - * @return array|null - */ - public function getMapOfEnumString() - { - return $this->container['map_of_enum_string']; - } - - /** - * Sets map_of_enum_string - * - * @param array|null $map_of_enum_string map_of_enum_string - * - * @return self - */ - public function setMapOfEnumString($map_of_enum_string) - { - if (is_null($map_of_enum_string)) { - throw new \InvalidArgumentException('non-nullable map_of_enum_string cannot be null'); - } - $allowedValues = $this->getMapOfEnumStringAllowableValues(); - if (array_diff($map_of_enum_string, $allowedValues)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value for 'map_of_enum_string', must be one of '%s'", - implode("', '", $allowedValues) - ) - ); - } - $this->container['map_of_enum_string'] = $map_of_enum_string; - - return $this; - } - - /** - * Gets direct_map - * - * @return array|null - */ - public function getDirectMap() - { - return $this->container['direct_map']; - } - - /** - * Sets direct_map - * - * @param array|null $direct_map direct_map - * - * @return self - */ - public function setDirectMap($direct_map) - { - if (is_null($direct_map)) { - throw new \InvalidArgumentException('non-nullable direct_map cannot be null'); - } - $this->container['direct_map'] = $direct_map; - - return $this; - } - - /** - * Gets indirect_map - * - * @return array|null - */ - public function getIndirectMap() - { - return $this->container['indirect_map']; - } - - /** - * Sets indirect_map - * - * @param array|null $indirect_map indirect_map - * - * @return self - */ - public function setIndirectMap($indirect_map) - { - if (is_null($indirect_map)) { - throw new \InvalidArgumentException('non-nullable indirect_map cannot be null'); - } - $this->container['indirect_map'] = $indirect_map; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php deleted file mode 100644 index e1b4aac2928..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php +++ /dev/null @@ -1,477 +0,0 @@ - - */ -class MixedPropertiesAndAdditionalPropertiesClass implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'MixedPropertiesAndAdditionalPropertiesClass'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'uuid' => 'string', - 'date_time' => '\DateTime', - 'map' => 'array' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'uuid' => 'uuid', - 'date_time' => 'date-time', - 'map' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'uuid' => false, - 'date_time' => false, - 'map' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'uuid' => 'uuid', - 'date_time' => 'dateTime', - 'map' => 'map' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'uuid' => 'setUuid', - 'date_time' => 'setDateTime', - 'map' => 'setMap' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'uuid' => 'getUuid', - 'date_time' => 'getDateTime', - 'map' => 'getMap' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('uuid', $data ?? [], null); - $this->setIfExists('date_time', $data ?? [], null); - $this->setIfExists('map', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets uuid - * - * @return string|null - */ - public function getUuid() - { - return $this->container['uuid']; - } - - /** - * Sets uuid - * - * @param string|null $uuid uuid - * - * @return self - */ - public function setUuid($uuid) - { - if (is_null($uuid)) { - throw new \InvalidArgumentException('non-nullable uuid cannot be null'); - } - $this->container['uuid'] = $uuid; - - return $this; - } - - /** - * Gets date_time - * - * @return \DateTime|null - */ - public function getDateTime() - { - return $this->container['date_time']; - } - - /** - * Sets date_time - * - * @param \DateTime|null $date_time date_time - * - * @return self - */ - public function setDateTime($date_time) - { - if (is_null($date_time)) { - throw new \InvalidArgumentException('non-nullable date_time cannot be null'); - } - $this->container['date_time'] = $date_time; - - return $this; - } - - /** - * Gets map - * - * @return array|null - */ - public function getMap() - { - return $this->container['map']; - } - - /** - * Sets map - * - * @param array|null $map map - * - * @return self - */ - public function setMap($map) - { - if (is_null($map)) { - throw new \InvalidArgumentException('non-nullable map cannot be null'); - } - $this->container['map'] = $map; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Model200Response.php deleted file mode 100644 index f0a8a439804..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Model200Response.php +++ /dev/null @@ -1,444 +0,0 @@ - - */ -class Model200Response implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = '200_response'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'name' => 'int', - 'class' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'name' => 'int32', - 'class' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'name' => false, - 'class' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'name' => 'name', - 'class' => 'class' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'name' => 'setName', - 'class' => 'setClass' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'name' => 'getName', - 'class' => 'getClass' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('name', $data ?? [], null); - $this->setIfExists('class', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets name - * - * @return int|null - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param int|null $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - - /** - * Gets class - * - * @return string|null - */ - public function getClass() - { - return $this->container['class']; - } - - /** - * Sets class - * - * @param string|null $class class - * - * @return self - */ - public function setClass($class) - { - if (is_null($class)) { - throw new \InvalidArgumentException('non-nullable class cannot be null'); - } - $this->container['class'] = $class; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelInterface.php deleted file mode 100644 index 822ef9d3c83..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelInterface.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ -class ModelList implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'List'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - '_123_list' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - '_123_list' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - '_123_list' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - '_123_list' => '123-list' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - '_123_list' => 'set123List' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - '_123_list' => 'get123List' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('_123_list', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets _123_list - * - * @return string|null - */ - public function get123List() - { - return $this->container['_123_list']; - } - - /** - * Sets _123_list - * - * @param string|null $_123_list _123_list - * - * @return self - */ - public function set123List($_123_list) - { - if (is_null($_123_list)) { - throw new \InvalidArgumentException('non-nullable _123_list cannot be null'); - } - $this->container['_123_list'] = $_123_list; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelReturn.php deleted file mode 100644 index 1ec62370f37..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ModelReturn.php +++ /dev/null @@ -1,410 +0,0 @@ - - */ -class ModelReturn implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Return'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'return' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'return' => 'int32' - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'return' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'return' => 'return' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'return' => 'setReturn' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'return' => 'getReturn' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('return', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets return - * - * @return int|null - */ - public function getReturn() - { - return $this->container['return']; - } - - /** - * Sets return - * - * @param int|null $return return - * - * @return self - */ - public function setReturn($return) - { - if (is_null($return)) { - throw new \InvalidArgumentException('non-nullable return cannot be null'); - } - $this->container['return'] = $return; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Name.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Name.php deleted file mode 100644 index 6718ae206f6..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Name.php +++ /dev/null @@ -1,515 +0,0 @@ - - */ -class Name implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Name'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'name' => 'int', - 'snake_case' => 'int', - 'property' => 'string', - '_123_number' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'name' => 'int32', - 'snake_case' => 'int32', - 'property' => null, - '_123_number' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'name' => false, - 'snake_case' => false, - 'property' => false, - '_123_number' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'name' => 'name', - 'snake_case' => 'snake_case', - 'property' => 'property', - '_123_number' => '123Number' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'name' => 'setName', - 'snake_case' => 'setSnakeCase', - 'property' => 'setProperty', - '_123_number' => 'set123Number' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'name' => 'getName', - 'snake_case' => 'getSnakeCase', - 'property' => 'getProperty', - '_123_number' => 'get123Number' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('name', $data ?? [], null); - $this->setIfExists('snake_case', $data ?? [], null); - $this->setIfExists('property', $data ?? [], null); - $this->setIfExists('_123_number', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets name - * - * @return int - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param int $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - - /** - * Gets snake_case - * - * @return int|null - */ - public function getSnakeCase() - { - return $this->container['snake_case']; - } - - /** - * Sets snake_case - * - * @param int|null $snake_case snake_case - * - * @return self - */ - public function setSnakeCase($snake_case) - { - if (is_null($snake_case)) { - throw new \InvalidArgumentException('non-nullable snake_case cannot be null'); - } - $this->container['snake_case'] = $snake_case; - - return $this; - } - - /** - * Gets property - * - * @return string|null - */ - public function getProperty() - { - return $this->container['property']; - } - - /** - * Sets property - * - * @param string|null $property property - * - * @return self - */ - public function setProperty($property) - { - if (is_null($property)) { - throw new \InvalidArgumentException('non-nullable property cannot be null'); - } - $this->container['property'] = $property; - - return $this; - } - - /** - * Gets _123_number - * - * @return int|null - */ - public function get123Number() - { - return $this->container['_123_number']; - } - - /** - * Sets _123_number - * - * @param int|null $_123_number _123_number - * - * @return self - */ - public function set123Number($_123_number) - { - if (is_null($_123_number)) { - throw new \InvalidArgumentException('non-nullable _123_number cannot be null'); - } - $this->container['_123_number'] = $_123_number; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NullableClass.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NullableClass.php deleted file mode 100644 index cecfc7a333d..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NullableClass.php +++ /dev/null @@ -1,853 +0,0 @@ - - */ -class NullableClass implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'NullableClass'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'integer_prop' => 'int', - 'number_prop' => 'float', - 'boolean_prop' => 'bool', - 'string_prop' => 'string', - 'date_prop' => '\DateTime', - 'datetime_prop' => '\DateTime', - 'array_nullable_prop' => 'object[]', - 'array_and_items_nullable_prop' => 'object[]', - 'array_items_nullable' => 'object[]', - 'object_nullable_prop' => 'array', - 'object_and_items_nullable_prop' => 'array', - 'object_items_nullable' => 'array' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'integer_prop' => null, - 'number_prop' => null, - 'boolean_prop' => null, - 'string_prop' => null, - 'date_prop' => 'date', - 'datetime_prop' => 'date-time', - 'array_nullable_prop' => null, - 'array_and_items_nullable_prop' => null, - 'array_items_nullable' => null, - 'object_nullable_prop' => null, - 'object_and_items_nullable_prop' => null, - 'object_items_nullable' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'integer_prop' => true, - 'number_prop' => true, - 'boolean_prop' => true, - 'string_prop' => true, - 'date_prop' => true, - 'datetime_prop' => true, - 'array_nullable_prop' => true, - 'array_and_items_nullable_prop' => true, - 'array_items_nullable' => false, - 'object_nullable_prop' => true, - 'object_and_items_nullable_prop' => true, - 'object_items_nullable' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'integer_prop' => 'integer_prop', - 'number_prop' => 'number_prop', - 'boolean_prop' => 'boolean_prop', - 'string_prop' => 'string_prop', - 'date_prop' => 'date_prop', - 'datetime_prop' => 'datetime_prop', - 'array_nullable_prop' => 'array_nullable_prop', - 'array_and_items_nullable_prop' => 'array_and_items_nullable_prop', - 'array_items_nullable' => 'array_items_nullable', - 'object_nullable_prop' => 'object_nullable_prop', - 'object_and_items_nullable_prop' => 'object_and_items_nullable_prop', - 'object_items_nullable' => 'object_items_nullable' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'integer_prop' => 'setIntegerProp', - 'number_prop' => 'setNumberProp', - 'boolean_prop' => 'setBooleanProp', - 'string_prop' => 'setStringProp', - 'date_prop' => 'setDateProp', - 'datetime_prop' => 'setDatetimeProp', - 'array_nullable_prop' => 'setArrayNullableProp', - 'array_and_items_nullable_prop' => 'setArrayAndItemsNullableProp', - 'array_items_nullable' => 'setArrayItemsNullable', - 'object_nullable_prop' => 'setObjectNullableProp', - 'object_and_items_nullable_prop' => 'setObjectAndItemsNullableProp', - 'object_items_nullable' => 'setObjectItemsNullable' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'integer_prop' => 'getIntegerProp', - 'number_prop' => 'getNumberProp', - 'boolean_prop' => 'getBooleanProp', - 'string_prop' => 'getStringProp', - 'date_prop' => 'getDateProp', - 'datetime_prop' => 'getDatetimeProp', - 'array_nullable_prop' => 'getArrayNullableProp', - 'array_and_items_nullable_prop' => 'getArrayAndItemsNullableProp', - 'array_items_nullable' => 'getArrayItemsNullable', - 'object_nullable_prop' => 'getObjectNullableProp', - 'object_and_items_nullable_prop' => 'getObjectAndItemsNullableProp', - 'object_items_nullable' => 'getObjectItemsNullable' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('integer_prop', $data ?? [], null); - $this->setIfExists('number_prop', $data ?? [], null); - $this->setIfExists('boolean_prop', $data ?? [], null); - $this->setIfExists('string_prop', $data ?? [], null); - $this->setIfExists('date_prop', $data ?? [], null); - $this->setIfExists('datetime_prop', $data ?? [], null); - $this->setIfExists('array_nullable_prop', $data ?? [], null); - $this->setIfExists('array_and_items_nullable_prop', $data ?? [], null); - $this->setIfExists('array_items_nullable', $data ?? [], null); - $this->setIfExists('object_nullable_prop', $data ?? [], null); - $this->setIfExists('object_and_items_nullable_prop', $data ?? [], null); - $this->setIfExists('object_items_nullable', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets integer_prop - * - * @return int|null - */ - public function getIntegerProp() - { - return $this->container['integer_prop']; - } - - /** - * Sets integer_prop - * - * @param int|null $integer_prop integer_prop - * - * @return self - */ - public function setIntegerProp($integer_prop) - { - if (is_null($integer_prop)) { - array_push($this->openAPINullablesSetToNull, 'integer_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('integer_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['integer_prop'] = $integer_prop; - - return $this; - } - - /** - * Gets number_prop - * - * @return float|null - */ - public function getNumberProp() - { - return $this->container['number_prop']; - } - - /** - * Sets number_prop - * - * @param float|null $number_prop number_prop - * - * @return self - */ - public function setNumberProp($number_prop) - { - if (is_null($number_prop)) { - array_push($this->openAPINullablesSetToNull, 'number_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('number_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['number_prop'] = $number_prop; - - return $this; - } - - /** - * Gets boolean_prop - * - * @return bool|null - */ - public function getBooleanProp() - { - return $this->container['boolean_prop']; - } - - /** - * Sets boolean_prop - * - * @param bool|null $boolean_prop boolean_prop - * - * @return self - */ - public function setBooleanProp($boolean_prop) - { - if (is_null($boolean_prop)) { - array_push($this->openAPINullablesSetToNull, 'boolean_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('boolean_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['boolean_prop'] = $boolean_prop; - - return $this; - } - - /** - * Gets string_prop - * - * @return string|null - */ - public function getStringProp() - { - return $this->container['string_prop']; - } - - /** - * Sets string_prop - * - * @param string|null $string_prop string_prop - * - * @return self - */ - public function setStringProp($string_prop) - { - if (is_null($string_prop)) { - array_push($this->openAPINullablesSetToNull, 'string_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('string_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['string_prop'] = $string_prop; - - return $this; - } - - /** - * Gets date_prop - * - * @return \DateTime|null - */ - public function getDateProp() - { - return $this->container['date_prop']; - } - - /** - * Sets date_prop - * - * @param \DateTime|null $date_prop date_prop - * - * @return self - */ - public function setDateProp($date_prop) - { - if (is_null($date_prop)) { - array_push($this->openAPINullablesSetToNull, 'date_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('date_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['date_prop'] = $date_prop; - - return $this; - } - - /** - * Gets datetime_prop - * - * @return \DateTime|null - */ - public function getDatetimeProp() - { - return $this->container['datetime_prop']; - } - - /** - * Sets datetime_prop - * - * @param \DateTime|null $datetime_prop datetime_prop - * - * @return self - */ - public function setDatetimeProp($datetime_prop) - { - if (is_null($datetime_prop)) { - array_push($this->openAPINullablesSetToNull, 'datetime_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('datetime_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['datetime_prop'] = $datetime_prop; - - return $this; - } - - /** - * Gets array_nullable_prop - * - * @return object[]|null - */ - public function getArrayNullableProp() - { - return $this->container['array_nullable_prop']; - } - - /** - * Sets array_nullable_prop - * - * @param object[]|null $array_nullable_prop array_nullable_prop - * - * @return self - */ - public function setArrayNullableProp($array_nullable_prop) - { - if (is_null($array_nullable_prop)) { - array_push($this->openAPINullablesSetToNull, 'array_nullable_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('array_nullable_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['array_nullable_prop'] = $array_nullable_prop; - - return $this; - } - - /** - * Gets array_and_items_nullable_prop - * - * @return object[]|null - */ - public function getArrayAndItemsNullableProp() - { - return $this->container['array_and_items_nullable_prop']; - } - - /** - * Sets array_and_items_nullable_prop - * - * @param object[]|null $array_and_items_nullable_prop array_and_items_nullable_prop - * - * @return self - */ - public function setArrayAndItemsNullableProp($array_and_items_nullable_prop) - { - if (is_null($array_and_items_nullable_prop)) { - array_push($this->openAPINullablesSetToNull, 'array_and_items_nullable_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('array_and_items_nullable_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['array_and_items_nullable_prop'] = $array_and_items_nullable_prop; - - return $this; - } - - /** - * Gets array_items_nullable - * - * @return object[]|null - */ - public function getArrayItemsNullable() - { - return $this->container['array_items_nullable']; - } - - /** - * Sets array_items_nullable - * - * @param object[]|null $array_items_nullable array_items_nullable - * - * @return self - */ - public function setArrayItemsNullable($array_items_nullable) - { - if (is_null($array_items_nullable)) { - throw new \InvalidArgumentException('non-nullable array_items_nullable cannot be null'); - } - $this->container['array_items_nullable'] = $array_items_nullable; - - return $this; - } - - /** - * Gets object_nullable_prop - * - * @return array|null - */ - public function getObjectNullableProp() - { - return $this->container['object_nullable_prop']; - } - - /** - * Sets object_nullable_prop - * - * @param array|null $object_nullable_prop object_nullable_prop - * - * @return self - */ - public function setObjectNullableProp($object_nullable_prop) - { - if (is_null($object_nullable_prop)) { - array_push($this->openAPINullablesSetToNull, 'object_nullable_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('object_nullable_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['object_nullable_prop'] = $object_nullable_prop; - - return $this; - } - - /** - * Gets object_and_items_nullable_prop - * - * @return array|null - */ - public function getObjectAndItemsNullableProp() - { - return $this->container['object_and_items_nullable_prop']; - } - - /** - * Sets object_and_items_nullable_prop - * - * @param array|null $object_and_items_nullable_prop object_and_items_nullable_prop - * - * @return self - */ - public function setObjectAndItemsNullableProp($object_and_items_nullable_prop) - { - if (is_null($object_and_items_nullable_prop)) { - array_push($this->openAPINullablesSetToNull, 'object_and_items_nullable_prop'); - } else { - $nullablesSetToNull = $this->getOpenAPINullablesSetToNull(); - $index = array_search('object_and_items_nullable_prop', $nullablesSetToNull); - if ($index !== FALSE) { - unset($nullablesSetToNull[$index]); - $this->setOpenAPINullablesSetToNull($nullablesSetToNull); - } - } - $this->container['object_and_items_nullable_prop'] = $object_and_items_nullable_prop; - - return $this; - } - - /** - * Gets object_items_nullable - * - * @return array|null - */ - public function getObjectItemsNullable() - { - return $this->container['object_items_nullable']; - } - - /** - * Sets object_items_nullable - * - * @param array|null $object_items_nullable object_items_nullable - * - * @return self - */ - public function setObjectItemsNullable($object_items_nullable) - { - if (is_null($object_items_nullable)) { - throw new \InvalidArgumentException('non-nullable object_items_nullable cannot be null'); - } - $this->container['object_items_nullable'] = $object_items_nullable; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NumberOnly.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NumberOnly.php deleted file mode 100644 index 73a78118a4f..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/NumberOnly.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class NumberOnly implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'NumberOnly'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'just_number' => 'float' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'just_number' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'just_number' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'just_number' => 'JustNumber' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'just_number' => 'setJustNumber' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'just_number' => 'getJustNumber' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('just_number', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets just_number - * - * @return float|null - */ - public function getJustNumber() - { - return $this->container['just_number']; - } - - /** - * Sets just_number - * - * @param float|null $just_number just_number - * - * @return self - */ - public function setJustNumber($just_number) - { - if (is_null($just_number)) { - throw new \InvalidArgumentException('non-nullable just_number cannot be null'); - } - $this->container['just_number'] = $just_number; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ObjectWithDeprecatedFields.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ObjectWithDeprecatedFields.php deleted file mode 100644 index 1bec3db84a3..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ObjectWithDeprecatedFields.php +++ /dev/null @@ -1,517 +0,0 @@ - - */ -class ObjectWithDeprecatedFields implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ObjectWithDeprecatedFields'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'uuid' => 'string', - 'id' => 'float', - 'deprecated_ref' => '\OpenAPI\Client\Model\DeprecatedObject', - 'bars' => 'string[]' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'uuid' => null, - 'id' => null, - 'deprecated_ref' => null, - 'bars' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'uuid' => false, - 'id' => false, - 'deprecated_ref' => false, - 'bars' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'uuid' => 'uuid', - 'id' => 'id', - 'deprecated_ref' => 'deprecatedRef', - 'bars' => 'bars' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'uuid' => 'setUuid', - 'id' => 'setId', - 'deprecated_ref' => 'setDeprecatedRef', - 'bars' => 'setBars' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'uuid' => 'getUuid', - 'id' => 'getId', - 'deprecated_ref' => 'getDeprecatedRef', - 'bars' => 'getBars' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('uuid', $data ?? [], null); - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('deprecated_ref', $data ?? [], null); - $this->setIfExists('bars', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets uuid - * - * @return string|null - */ - public function getUuid() - { - return $this->container['uuid']; - } - - /** - * Sets uuid - * - * @param string|null $uuid uuid - * - * @return self - */ - public function setUuid($uuid) - { - if (is_null($uuid)) { - throw new \InvalidArgumentException('non-nullable uuid cannot be null'); - } - $this->container['uuid'] = $uuid; - - return $this; - } - - /** - * Gets id - * - * @return float|null - * @deprecated - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param float|null $id id - * - * @return self - * @deprecated - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets deprecated_ref - * - * @return \OpenAPI\Client\Model\DeprecatedObject|null - * @deprecated - */ - public function getDeprecatedRef() - { - return $this->container['deprecated_ref']; - } - - /** - * Sets deprecated_ref - * - * @param \OpenAPI\Client\Model\DeprecatedObject|null $deprecated_ref deprecated_ref - * - * @return self - * @deprecated - */ - public function setDeprecatedRef($deprecated_ref) - { - if (is_null($deprecated_ref)) { - throw new \InvalidArgumentException('non-nullable deprecated_ref cannot be null'); - } - $this->container['deprecated_ref'] = $deprecated_ref; - - return $this; - } - - /** - * Gets bars - * - * @return string[]|null - * @deprecated - */ - public function getBars() - { - return $this->container['bars']; - } - - /** - * Sets bars - * - * @param string[]|null $bars bars - * - * @return self - * @deprecated - */ - public function setBars($bars) - { - if (is_null($bars)) { - throw new \InvalidArgumentException('non-nullable bars cannot be null'); - } - $this->container['bars'] = $bars; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Order.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Order.php deleted file mode 100644 index ebc4eae027e..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Order.php +++ /dev/null @@ -1,615 +0,0 @@ - - */ -class Order implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Order'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'int', - 'pet_id' => 'int', - 'quantity' => 'int', - 'ship_date' => '\DateTime', - 'status' => 'string', - 'complete' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'id' => 'int64', - 'pet_id' => 'int64', - 'quantity' => 'int32', - 'ship_date' => 'date-time', - 'status' => null, - 'complete' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'id' => false, - 'pet_id' => false, - 'quantity' => false, - 'ship_date' => false, - 'status' => false, - 'complete' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'pet_id' => 'petId', - 'quantity' => 'quantity', - 'ship_date' => 'shipDate', - 'status' => 'status', - 'complete' => 'complete' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'pet_id' => 'setPetId', - 'quantity' => 'setQuantity', - 'ship_date' => 'setShipDate', - 'status' => 'setStatus', - 'complete' => 'setComplete' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'pet_id' => 'getPetId', - 'quantity' => 'getQuantity', - 'ship_date' => 'getShipDate', - 'status' => 'getStatus', - 'complete' => 'getComplete' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const STATUS_PLACED = 'placed'; - public const STATUS_APPROVED = 'approved'; - public const STATUS_DELIVERED = 'delivered'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getStatusAllowableValues() - { - return [ - self::STATUS_PLACED, - self::STATUS_APPROVED, - self::STATUS_DELIVERED, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('pet_id', $data ?? [], null); - $this->setIfExists('quantity', $data ?? [], null); - $this->setIfExists('ship_date', $data ?? [], null); - $this->setIfExists('status', $data ?? [], null); - $this->setIfExists('complete', $data ?? [], false); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - $allowedValues = $this->getStatusAllowableValues(); - if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'status', must be one of '%s'", - $this->container['status'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return int|null - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets pet_id - * - * @return int|null - */ - public function getPetId() - { - return $this->container['pet_id']; - } - - /** - * Sets pet_id - * - * @param int|null $pet_id pet_id - * - * @return self - */ - public function setPetId($pet_id) - { - if (is_null($pet_id)) { - throw new \InvalidArgumentException('non-nullable pet_id cannot be null'); - } - $this->container['pet_id'] = $pet_id; - - return $this; - } - - /** - * Gets quantity - * - * @return int|null - */ - public function getQuantity() - { - return $this->container['quantity']; - } - - /** - * Sets quantity - * - * @param int|null $quantity quantity - * - * @return self - */ - public function setQuantity($quantity) - { - if (is_null($quantity)) { - throw new \InvalidArgumentException('non-nullable quantity cannot be null'); - } - $this->container['quantity'] = $quantity; - - return $this; - } - - /** - * Gets ship_date - * - * @return \DateTime|null - */ - public function getShipDate() - { - return $this->container['ship_date']; - } - - /** - * Sets ship_date - * - * @param \DateTime|null $ship_date ship_date - * - * @return self - */ - public function setShipDate($ship_date) - { - if (is_null($ship_date)) { - throw new \InvalidArgumentException('non-nullable ship_date cannot be null'); - } - $this->container['ship_date'] = $ship_date; - - return $this; - } - - /** - * Gets status - * - * @return string|null - */ - public function getStatus() - { - return $this->container['status']; - } - - /** - * Sets status - * - * @param string|null $status Order Status - * - * @return self - */ - public function setStatus($status) - { - if (is_null($status)) { - throw new \InvalidArgumentException('non-nullable status cannot be null'); - } - $allowedValues = $this->getStatusAllowableValues(); - if (!in_array($status, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'status', must be one of '%s'", - $status, - implode("', '", $allowedValues) - ) - ); - } - $this->container['status'] = $status; - - return $this; - } - - /** - * Gets complete - * - * @return bool|null - */ - public function getComplete() - { - return $this->container['complete']; - } - - /** - * Sets complete - * - * @param bool|null $complete complete - * - * @return self - */ - public function setComplete($complete) - { - if (is_null($complete)) { - throw new \InvalidArgumentException('non-nullable complete cannot be null'); - } - $this->container['complete'] = $complete; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterComposite.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterComposite.php deleted file mode 100644 index 1ad98982b70..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterComposite.php +++ /dev/null @@ -1,477 +0,0 @@ - - */ -class OuterComposite implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'OuterComposite'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'my_number' => 'float', - 'my_string' => 'string', - 'my_boolean' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'my_number' => null, - 'my_string' => null, - 'my_boolean' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'my_number' => false, - 'my_string' => false, - 'my_boolean' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'my_number' => 'my_number', - 'my_string' => 'my_string', - 'my_boolean' => 'my_boolean' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'my_number' => 'setMyNumber', - 'my_string' => 'setMyString', - 'my_boolean' => 'setMyBoolean' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'my_number' => 'getMyNumber', - 'my_string' => 'getMyString', - 'my_boolean' => 'getMyBoolean' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('my_number', $data ?? [], null); - $this->setIfExists('my_string', $data ?? [], null); - $this->setIfExists('my_boolean', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets my_number - * - * @return float|null - */ - public function getMyNumber() - { - return $this->container['my_number']; - } - - /** - * Sets my_number - * - * @param float|null $my_number my_number - * - * @return self - */ - public function setMyNumber($my_number) - { - if (is_null($my_number)) { - throw new \InvalidArgumentException('non-nullable my_number cannot be null'); - } - $this->container['my_number'] = $my_number; - - return $this; - } - - /** - * Gets my_string - * - * @return string|null - */ - public function getMyString() - { - return $this->container['my_string']; - } - - /** - * Sets my_string - * - * @param string|null $my_string my_string - * - * @return self - */ - public function setMyString($my_string) - { - if (is_null($my_string)) { - throw new \InvalidArgumentException('non-nullable my_string cannot be null'); - } - $this->container['my_string'] = $my_string; - - return $this; - } - - /** - * Gets my_boolean - * - * @return bool|null - */ - public function getMyBoolean() - { - return $this->container['my_boolean']; - } - - /** - * Sets my_boolean - * - * @param bool|null $my_boolean my_boolean - * - * @return self - */ - public function setMyBoolean($my_boolean) - { - if (is_null($my_boolean)) { - throw new \InvalidArgumentException('non-nullable my_boolean cannot be null'); - } - $this->container['my_boolean'] = $my_boolean; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterEnum.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterEnum.php deleted file mode 100644 index f4d09cf1f20..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/OuterEnum.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class OuterObjectWithEnumProperty implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'OuterObjectWithEnumProperty'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'value' => '\OpenAPI\Client\Model\OuterEnumInteger' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'value' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'value' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'value' => 'value' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'value' => 'setValue' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'value' => 'getValue' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('value', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['value'] === null) { - $invalidProperties[] = "'value' can't be null"; - } - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets value - * - * @return \OpenAPI\Client\Model\OuterEnumInteger - */ - public function getValue() - { - return $this->container['value']; - } - - /** - * Sets value - * - * @param \OpenAPI\Client\Model\OuterEnumInteger $value value - * - * @return self - */ - public function setValue($value) - { - if (is_null($value)) { - throw new \InvalidArgumentException('non-nullable value cannot be null'); - } - $this->container['value'] = $value; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Pet.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Pet.php deleted file mode 100644 index 6795d19e6aa..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Pet.php +++ /dev/null @@ -1,623 +0,0 @@ - - */ -class Pet implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Pet'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'int', - 'category' => '\OpenAPI\Client\Model\Category', - 'name' => 'string', - 'photo_urls' => 'string[]', - 'tags' => '\OpenAPI\Client\Model\Tag[]', - 'status' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'id' => 'int64', - 'category' => null, - 'name' => null, - 'photo_urls' => null, - 'tags' => null, - 'status' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'id' => false, - 'category' => false, - 'name' => false, - 'photo_urls' => false, - 'tags' => false, - 'status' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'category' => 'category', - 'name' => 'name', - 'photo_urls' => 'photoUrls', - 'tags' => 'tags', - 'status' => 'status' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'category' => 'setCategory', - 'name' => 'setName', - 'photo_urls' => 'setPhotoUrls', - 'tags' => 'setTags', - 'status' => 'setStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'category' => 'getCategory', - 'name' => 'getName', - 'photo_urls' => 'getPhotoUrls', - 'tags' => 'getTags', - 'status' => 'getStatus' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - public const STATUS_AVAILABLE = 'available'; - public const STATUS_PENDING = 'pending'; - public const STATUS_SOLD = 'sold'; - - /** - * Gets allowable values of the enum - * - * @return string[] - */ - public function getStatusAllowableValues() - { - return [ - self::STATUS_AVAILABLE, - self::STATUS_PENDING, - self::STATUS_SOLD, - ]; - } - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('category', $data ?? [], null); - $this->setIfExists('name', $data ?? [], null); - $this->setIfExists('photo_urls', $data ?? [], null); - $this->setIfExists('tags', $data ?? [], null); - $this->setIfExists('status', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - if ($this->container['name'] === null) { - $invalidProperties[] = "'name' can't be null"; - } - if ($this->container['photo_urls'] === null) { - $invalidProperties[] = "'photo_urls' can't be null"; - } - $allowedValues = $this->getStatusAllowableValues(); - if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { - $invalidProperties[] = sprintf( - "invalid value '%s' for 'status', must be one of '%s'", - $this->container['status'], - implode("', '", $allowedValues) - ); - } - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return int|null - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets category - * - * @return \OpenAPI\Client\Model\Category|null - */ - public function getCategory() - { - return $this->container['category']; - } - - /** - * Sets category - * - * @param \OpenAPI\Client\Model\Category|null $category category - * - * @return self - */ - public function setCategory($category) - { - if (is_null($category)) { - throw new \InvalidArgumentException('non-nullable category cannot be null'); - } - $this->container['category'] = $category; - - return $this; - } - - /** - * Gets name - * - * @return string - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param string $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - - /** - * Gets photo_urls - * - * @return string[] - */ - public function getPhotoUrls() - { - return $this->container['photo_urls']; - } - - /** - * Sets photo_urls - * - * @param string[] $photo_urls photo_urls - * - * @return self - */ - public function setPhotoUrls($photo_urls) - { - if (is_null($photo_urls)) { - throw new \InvalidArgumentException('non-nullable photo_urls cannot be null'); - } - - - $this->container['photo_urls'] = $photo_urls; - - return $this; - } - - /** - * Gets tags - * - * @return \OpenAPI\Client\Model\Tag[]|null - */ - public function getTags() - { - return $this->container['tags']; - } - - /** - * Sets tags - * - * @param \OpenAPI\Client\Model\Tag[]|null $tags tags - * - * @return self - */ - public function setTags($tags) - { - if (is_null($tags)) { - throw new \InvalidArgumentException('non-nullable tags cannot be null'); - } - $this->container['tags'] = $tags; - - return $this; - } - - /** - * Gets status - * - * @return string|null - */ - public function getStatus() - { - return $this->container['status']; - } - - /** - * Sets status - * - * @param string|null $status pet status in the store - * - * @return self - */ - public function setStatus($status) - { - if (is_null($status)) { - throw new \InvalidArgumentException('non-nullable status cannot be null'); - } - $allowedValues = $this->getStatusAllowableValues(); - if (!in_array($status, $allowedValues, true)) { - throw new \InvalidArgumentException( - sprintf( - "Invalid value '%s' for 'status', must be one of '%s'", - $status, - implode("', '", $allowedValues) - ) - ); - } - $this->container['status'] = $status; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php deleted file mode 100644 index 88a7bbaed1a..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class ReadOnlyFirst implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'ReadOnlyFirst'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'bar' => 'string', - 'baz' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'bar' => null, - 'baz' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'bar' => false, - 'baz' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'bar' => 'bar', - 'baz' => 'baz' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'bar' => 'setBar', - 'baz' => 'setBaz' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'bar' => 'getBar', - 'baz' => 'getBaz' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('bar', $data ?? [], null); - $this->setIfExists('baz', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets bar - * - * @return string|null - */ - public function getBar() - { - return $this->container['bar']; - } - - /** - * Sets bar - * - * @param string|null $bar bar - * - * @return self - */ - public function setBar($bar) - { - if (is_null($bar)) { - throw new \InvalidArgumentException('non-nullable bar cannot be null'); - } - $this->container['bar'] = $bar; - - return $this; - } - - /** - * Gets baz - * - * @return string|null - */ - public function getBaz() - { - return $this->container['baz']; - } - - /** - * Sets baz - * - * @param string|null $baz baz - * - * @return self - */ - public function setBaz($baz) - { - if (is_null($baz)) { - throw new \InvalidArgumentException('non-nullable baz cannot be null'); - } - $this->container['baz'] = $baz; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/SingleRefType.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/SingleRefType.php deleted file mode 100644 index a785e84e954..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/SingleRefType.php +++ /dev/null @@ -1,62 +0,0 @@ - - */ -class SpecialModelName implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = '_special_model.name_'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'special_property_name' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'special_property_name' => 'int64' - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'special_property_name' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'special_property_name' => '$special[property.name]' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'special_property_name' => 'setSpecialPropertyName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'special_property_name' => 'getSpecialPropertyName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('special_property_name', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets special_property_name - * - * @return int|null - */ - public function getSpecialPropertyName() - { - return $this->container['special_property_name']; - } - - /** - * Sets special_property_name - * - * @param int|null $special_property_name special_property_name - * - * @return self - */ - public function setSpecialPropertyName($special_property_name) - { - if (is_null($special_property_name)) { - throw new \InvalidArgumentException('non-nullable special_property_name cannot be null'); - } - $this->container['special_property_name'] = $special_property_name; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Tag.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Tag.php deleted file mode 100644 index 03742ae4215..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/Tag.php +++ /dev/null @@ -1,443 +0,0 @@ - - */ -class Tag implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Tag'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'int', - 'name' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'id' => 'int64', - 'name' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'id' => false, - 'name' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'name' => 'name' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'name' => 'setName' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'name' => 'getName' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('name', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return int|null - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets name - * - * @return string|null - */ - public function getName() - { - return $this->container['name']; - } - - /** - * Sets name - * - * @param string|null $name name - * - * @return self - */ - public function setName($name) - { - if (is_null($name)) { - throw new \InvalidArgumentException('non-nullable name cannot be null'); - } - $this->container['name'] = $name; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/User.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/User.php deleted file mode 100644 index d745bfc65ff..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/Model/User.php +++ /dev/null @@ -1,647 +0,0 @@ - - */ -class User implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'User'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'id' => 'int', - 'username' => 'string', - 'first_name' => 'string', - 'last_name' => 'string', - 'email' => 'string', - 'password' => 'string', - 'phone' => 'string', - 'user_status' => 'int' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'id' => 'int64', - 'username' => null, - 'first_name' => null, - 'last_name' => null, - 'email' => null, - 'password' => null, - 'phone' => null, - 'user_status' => 'int32' - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'id' => false, - 'username' => false, - 'first_name' => false, - 'last_name' => false, - 'email' => false, - 'password' => false, - 'phone' => false, - 'user_status' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'id' => 'id', - 'username' => 'username', - 'first_name' => 'firstName', - 'last_name' => 'lastName', - 'email' => 'email', - 'password' => 'password', - 'phone' => 'phone', - 'user_status' => 'userStatus' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'id' => 'setId', - 'username' => 'setUsername', - 'first_name' => 'setFirstName', - 'last_name' => 'setLastName', - 'email' => 'setEmail', - 'password' => 'setPassword', - 'phone' => 'setPhone', - 'user_status' => 'setUserStatus' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'id' => 'getId', - 'username' => 'getUsername', - 'first_name' => 'getFirstName', - 'last_name' => 'getLastName', - 'email' => 'getEmail', - 'password' => 'getPassword', - 'phone' => 'getPhone', - 'user_status' => 'getUserStatus' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('id', $data ?? [], null); - $this->setIfExists('username', $data ?? [], null); - $this->setIfExists('first_name', $data ?? [], null); - $this->setIfExists('last_name', $data ?? [], null); - $this->setIfExists('email', $data ?? [], null); - $this->setIfExists('password', $data ?? [], null); - $this->setIfExists('phone', $data ?? [], null); - $this->setIfExists('user_status', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets id - * - * @return int|null - */ - public function getId() - { - return $this->container['id']; - } - - /** - * Sets id - * - * @param int|null $id id - * - * @return self - */ - public function setId($id) - { - if (is_null($id)) { - throw new \InvalidArgumentException('non-nullable id cannot be null'); - } - $this->container['id'] = $id; - - return $this; - } - - /** - * Gets username - * - * @return string|null - */ - public function getUsername() - { - return $this->container['username']; - } - - /** - * Sets username - * - * @param string|null $username username - * - * @return self - */ - public function setUsername($username) - { - if (is_null($username)) { - throw new \InvalidArgumentException('non-nullable username cannot be null'); - } - $this->container['username'] = $username; - - return $this; - } - - /** - * Gets first_name - * - * @return string|null - */ - public function getFirstName() - { - return $this->container['first_name']; - } - - /** - * Sets first_name - * - * @param string|null $first_name first_name - * - * @return self - */ - public function setFirstName($first_name) - { - if (is_null($first_name)) { - throw new \InvalidArgumentException('non-nullable first_name cannot be null'); - } - $this->container['first_name'] = $first_name; - - return $this; - } - - /** - * Gets last_name - * - * @return string|null - */ - public function getLastName() - { - return $this->container['last_name']; - } - - /** - * Sets last_name - * - * @param string|null $last_name last_name - * - * @return self - */ - public function setLastName($last_name) - { - if (is_null($last_name)) { - throw new \InvalidArgumentException('non-nullable last_name cannot be null'); - } - $this->container['last_name'] = $last_name; - - return $this; - } - - /** - * Gets email - * - * @return string|null - */ - public function getEmail() - { - return $this->container['email']; - } - - /** - * Sets email - * - * @param string|null $email email - * - * @return self - */ - public function setEmail($email) - { - if (is_null($email)) { - throw new \InvalidArgumentException('non-nullable email cannot be null'); - } - $this->container['email'] = $email; - - return $this; - } - - /** - * Gets password - * - * @return string|null - */ - public function getPassword() - { - return $this->container['password']; - } - - /** - * Sets password - * - * @param string|null $password password - * - * @return self - */ - public function setPassword($password) - { - if (is_null($password)) { - throw new \InvalidArgumentException('non-nullable password cannot be null'); - } - $this->container['password'] = $password; - - return $this; - } - - /** - * Gets phone - * - * @return string|null - */ - public function getPhone() - { - return $this->container['phone']; - } - - /** - * Sets phone - * - * @param string|null $phone phone - * - * @return self - */ - public function setPhone($phone) - { - if (is_null($phone)) { - throw new \InvalidArgumentException('non-nullable phone cannot be null'); - } - $this->container['phone'] = $phone; - - return $this; - } - - /** - * Gets user_status - * - * @return int|null - */ - public function getUserStatus() - { - return $this->container['user_status']; - } - - /** - * Sets user_status - * - * @param int|null $user_status User Status - * - * @return self - */ - public function setUserStatus($user_status) - { - if (is_null($user_status)) { - throw new \InvalidArgumentException('non-nullable user_status cannot be null'); - } - $this->container['user_status'] = $user_status; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ObjectSerializer.php deleted file mode 100644 index 510540985d3..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/lib/ObjectSerializer.php +++ /dev/null @@ -1,616 +0,0 @@ -format('Y-m-d') : $data->format(self::$dateTimeFormat); - } - - if (is_array($data)) { - foreach ($data as $property => $value) { - $data[$property] = self::sanitizeForSerialization($value); - } - return $data; - } - - if (is_object($data)) { - $values = []; - if ($data instanceof ModelInterface) { - $formats = $data::openAPIFormats(); - foreach ($data::openAPITypes() as $property => $openAPIType) { - $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - $callable = [$openAPIType, 'getAllowableEnumValues']; - if (is_callable($callable)) { - /** array $callable */ - $allowedEnumTypes = $callable(); - if (!in_array($value, $allowedEnumTypes, true)) { - $imploded = implode("', '", $allowedEnumTypes); - throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); - } - } - } - if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); - } - } - } else { - foreach($data as $property => $value) { - $values[$property] = self::sanitizeForSerialization($value); - } - } - return (object)$values; - } else { - return (string)$data; - } - } - - /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param string $filename filename to be sanitized - * - * @return string the sanitized filename - */ - public static function sanitizeFilename($filename) - { - if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) { - return $match[1]; - } else { - return $filename; - } - } - - /** - * Shorter timestamp microseconds to 6 digits length. - * - * @param string $timestamp Original timestamp - * - * @return string the shorten timestamp - */ - public static function sanitizeTimestamp($timestamp) - { - if (!is_string($timestamp)) return $timestamp; - - return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp); - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the path, by url-encoding. - * - * @param string $value a string which will be part of the path - * - * @return string the serialized object - */ - public static function toPathValue($value) - { - return rawurlencode(self::toString($value)); - } - - /** - * Checks if a value is empty, based on its OpenAPI type. - * - * @param mixed $value - * @param string $openApiType - * - * @return bool true if $value is empty - */ - private static function isEmptyValue($value, string $openApiType): bool - { - # If empty() returns false, it is not empty regardless of its type. - if (!empty($value)) { - return false; - } - - # Null is always empty, as we cannot send a real "null" value in a query parameter. - if ($value === null) { - return true; - } - - switch ($openApiType) { - # For numeric values, false and '' are considered empty. - # This comparison is safe for floating point values, since the previous call to empty() will - # filter out values that don't match 0. - case 'int': - case 'integer': - return $value !== 0; - - case 'number': - case 'float': - return $value !== 0 && $value !== 0.0; - - # For boolean values, '' is considered empty - case 'bool': - case 'boolean': - return !in_array($value, [false, 0], true); - - # For all the other types, any value at this point can be considered empty. - default: - return true; - } - } - - /** - * Take query parameter properties and turn it into an array suitable for - * native http_build_query or GuzzleHttp\Psr7\Query::build. - * - * @param mixed $value Parameter value - * @param string $paramName Parameter name - * @param string $openApiType OpenAPIType eg. array or object - * @param string $style Parameter serialization style - * @param bool $explode Parameter explode option - * @param bool $required Whether query param is required or not - * - * @return array - */ - public static function toQueryValue( - $value, - string $paramName, - string $openApiType = 'string', - string $style = 'form', - bool $explode = true, - bool $required = true - ): array { - - # Check if we should omit this parameter from the query. This should only happen when: - # - Parameter is NOT required; AND - # - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For - # example, 0 as "int" or "boolean" is NOT an empty value. - if (self::isEmptyValue($value, $openApiType)) { - if ($required) { - return ["{$paramName}" => '']; - } else { - return []; - } - } - - # Handle DateTime objects in query - if($openApiType === "\\DateTime" && $value instanceof \DateTime) { - return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; - } - - $query = []; - $value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value; - - // since \GuzzleHttp\Psr7\Query::build fails with nested arrays - // need to flatten array first - $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { - if (!is_array($arr)) return $arr; - - foreach ($arr as $k => $v) { - $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; - - if (is_array($v)) { - $flattenArray($v, $prop, $result); - } else { - if ($style !== 'deepObject' && !$explode) { - // push key itself - $result[] = $prop; - } - $result[$prop] = $v; - } - } - return $result; - }; - - $value = $flattenArray($value, $paramName); - - if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { - return $value; - } - - if ('boolean' === $openApiType && is_bool($value)) { - $value = self::convertBoolToQueryStringFormat($value); - } - - // handle style in serializeCollection - $query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style); - - return $query; - } - - /** - * Convert boolean value to format for query string. - * - * @param bool $value Boolean value - * - * @return int|string Boolean value in format - */ - public static function convertBoolToQueryStringFormat(bool $value) - { - if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) { - return $value ? 'true' : 'false'; - } - - return (int) $value; - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the header. If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string $value a string which will be part of the header - * - * @return string the header string - */ - public static function toHeaderValue($value) - { - $callable = [$value, 'toHeaderValue']; - if (is_callable($callable)) { - return $callable(); - } - - return self::toString($value); - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the http body (form parameter). If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * - * @param string|\SplFileObject $value the value of the form parameter - * - * @return string the form string - */ - public static function toFormValue($value) - { - if ($value instanceof \SplFileObject) { - return $value->getRealPath(); - } else { - return self::toString($value); - } - } - - /** - * Take value and turn it into a string suitable for inclusion in - * the parameter. If it's a string, pass through unchanged - * If it's a datetime object, format it in ISO8601 - * If it's a boolean, convert it to "true" or "false". - * - * @param string|bool|\DateTime $value the value of the parameter - * - * @return string the header string - */ - public static function toString($value) - { - if ($value instanceof \DateTime) { // datetime in ISO8601 format - return $value->format(self::$dateTimeFormat); - } elseif (is_bool($value)) { - return $value ? 'true' : 'false'; - } else { - return (string) $value; - } - } - - /** - * Serialize an array to a string. - * - * @param array $collection collection to serialize to a string - * @param string $style the format use for serialization (csv, - * ssv, tsv, pipes, multi) - * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array - * - * @return string - */ - public static function serializeCollection(array $collection, $style, $allowCollectionFormatMulti = false) - { - if ($allowCollectionFormatMulti && ('multi' === $style)) { - // http_build_query() almost does the job for us. We just - // need to fix the result of multidimensional arrays. - return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&')); - } - switch ($style) { - case 'pipeDelimited': - case 'pipes': - return implode('|', $collection); - - case 'tsv': - return implode("\t", $collection); - - case 'spaceDelimited': - case 'ssv': - return implode(' ', $collection); - - case 'simple': - case 'csv': - // Deliberate fall through. CSV is default format. - default: - return implode(',', $collection); - } - } - - /** - * Deserialize a JSON string into an object - * - * @param mixed $data object or primitive to be deserialized - * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * - * @return object|array|null a single or an array of $class instances - */ - public static function deserialize($data, $class, $httpHeaders = null) - { - if (null === $data) { - return null; - } - - if (strcasecmp(substr($class, -2), '[]') === 0) { - $data = is_string($data) ? json_decode($data) : $data; - - if (!is_array($data)) { - throw new \InvalidArgumentException("Invalid array '$class'"); - } - - $subClass = substr($class, 0, -2); - $values = []; - foreach ($data as $key => $value) { - $values[] = self::deserialize($value, $subClass, null); - } - return $values; - } - - if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array - $data = is_string($data) ? json_decode($data) : $data; - settype($data, 'array'); - $inner = substr($class, 4, -1); - $deserialized = []; - if (strrpos($inner, ",") !== false) { - $subClass_array = explode(',', $inner, 2); - $subClass = $subClass_array[1]; - foreach ($data as $key => $value) { - $deserialized[$key] = self::deserialize($value, $subClass, null); - } - } - return $deserialized; - } - - if ($class === 'object') { - settype($data, 'array'); - return $data; - } elseif ($class === 'mixed') { - settype($data, gettype($data)); - return $data; - } - - if ($class === '\DateTime') { - // Some APIs return an invalid, empty string as a - // date-time property. DateTime::__construct() will return - // the current time for empty input which is probably not - // what is meant. The invalid empty string is probably to - // be interpreted as a missing field/value. Let's handle - // this graceful. - if (!empty($data)) { - try { - return new \DateTime($data); - } catch (\Exception $exception) { - // Some APIs return a date-time with too high nanosecond - // precision for php's DateTime to handle. - // With provided regexp 6 digits of microseconds saved - return new \DateTime(self::sanitizeTimestamp($data)); - } - } else { - return null; - } - } - - if ($class === '\SplFileObject') { - $data = Utils::streamFor($data); - - /** @var \Psr\Http\Message\StreamInterface $data */ - - // determine file name - if ( - is_array($httpHeaders) - && array_key_exists('Content-Disposition', $httpHeaders) - && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) - ) { - $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); - } else { - $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); - } - - $file = fopen($filename, 'w'); - while ($chunk = $data->read(200)) { - fwrite($file, $chunk); - } - fclose($file); - - return new \SplFileObject($filename, 'r'); - } - - /** @psalm-suppress ParadoxicalCondition */ - if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { - settype($data, $class); - return $data; - } - - - if (method_exists($class, 'getAllowableEnumValues')) { - if (!in_array($data, $class::getAllowableEnumValues(), true)) { - $imploded = implode("', '", $class::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); - } - return $data; - } else { - $data = is_string($data) ? json_decode($data) : $data; - - if (is_array($data)) { - $data = (object)$data; - } - - // If a discriminator is defined and points to a valid subclass, use it. - $discriminator = $class::DISCRIMINATOR; - if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { - $subclass = '\OpenAPI\Client\Model\\' . $data->{$discriminator}; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - } - } - - /** @var ModelInterface $instance */ - $instance = new $class(); - foreach ($instance::openAPITypes() as $property => $type) { - $propertySetter = $instance::setters()[$property]; - - if (!isset($propertySetter)) { - continue; - } - - if (!isset($data->{$instance::attributeMap()[$property]})) { - if ($instance::isNullable($property)) { - $instance->$propertySetter(null); - } - - continue; - } - - if (isset($data->{$instance::attributeMap()[$property]})) { - $propertyValue = $data->{$instance::attributeMap()[$property]}; - $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); - } - } - return $instance; - } - } - - /** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of `parse()` to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like `http_build_query()` would). - * - * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 - * with a modification which is described in https://github.com/guzzle/psr7/pull/603 - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - * @param bool $treatBooleansAsInts When `true` values are cast to int (e.g. ['foo' => false] gives `foo=0`). - * When `false` values are cast to strings (e.g. ['foo' => false] gives `foo=false`). - */ - public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986, bool $treatBooleansAsInts = true): string - { - if (!$params) { - return ''; - } - - if ($encoding === false) { - $encoder = function (string $str): string { - return $str; - }; - } elseif ($encoding === PHP_QUERY_RFC3986) { - $encoder = 'rawurlencode'; - } elseif ($encoding === PHP_QUERY_RFC1738) { - $encoder = 'urlencode'; - } else { - throw new \InvalidArgumentException('Invalid type'); - } - - $castBool = $treatBooleansAsInts - ? function ($v) { return (int) $v; } - : function ($v) { return $v ? 'true' : 'false'; }; - - $qs = ''; - foreach ($params as $k => $v) { - $k = $encoder((string) $k); - if (!is_array($v)) { - $qs .= $k; - $v = is_bool($v) ? $castBool($v) : $v; - if ($v !== null) { - $qs .= '='.$encoder((string) $v); - } - $qs .= '&'; - } else { - foreach ($v as $vv) { - $qs .= $k; - $vv = is_bool($vv) ? $castBool($vv) : $vv; - if ($vv !== null) { - $qs .= '='.$encoder((string) $vv); - } - $qs .= '&'; - } - } - } - - return $qs ? (string) substr($qs, 0, -1) : ''; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/phplint.dist.yml b/samples/client/petstore/php-nextgen/OpenAPIClient-php/phplint.dist.yml deleted file mode 100644 index 3a1d5b715e9..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/phplint.dist.yml +++ /dev/null @@ -1,13 +0,0 @@ -path: - - src/ - - tests/ -jobs: 10 -extensions: - - php -exclude: - - vendor -warning: true -memory-limit: -1 -no-cache: false -log-json: false -log-junit: false diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/pom.xml b/samples/client/petstore/php-nextgen/OpenAPIClient-php/pom.xml deleted file mode 100644 index 16ead2bea4d..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - 4.0.0 - org.openapitools - PhpPetstoreOAS3Tests - pom - 1.0-SNAPSHOT - PHP OpenAPI OAS3 Client - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory} - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - bundle-install - pre-integration-test - - exec - - - composer - - install - - - - - check-php-syntax - integration-test - - exec - - - vendor/bin/phplint - - --configuration=phplint.dist.yml - - - - - bundle-test - integration-test - - exec - - - vendor/bin/phpunit - - test - - - - - - - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/CatAllOf.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/CatAllOf.php deleted file mode 100644 index 5703fe3cb0d..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/CatAllOf.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class CatAllOf implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Cat_allOf'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'declawed' => 'bool' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'declawed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'declawed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'declawed' => 'declawed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'declawed' => 'setDeclawed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'declawed' => 'getDeclawed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('declawed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets declawed - * - * @return bool|null - */ - public function getDeclawed() - { - return $this->container['declawed']; - } - - /** - * Sets declawed - * - * @param bool|null $declawed declawed - * - * @return self - */ - public function setDeclawed($declawed) - { - if (is_null($declawed)) { - throw new \InvalidArgumentException('non-nullable declawed cannot be null'); - } - $this->container['declawed'] = $declawed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/DogAllOf.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/DogAllOf.php deleted file mode 100644 index 0063d884f18..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Model/DogAllOf.php +++ /dev/null @@ -1,409 +0,0 @@ - - */ -class DogAllOf implements ModelInterface, ArrayAccess, \JsonSerializable -{ - public const DISCRIMINATOR = null; - - /** - * The original name of the model. - * - * @var string - */ - protected static $openAPIModelName = 'Dog_allOf'; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ - protected static $openAPITypes = [ - 'breed' => 'string' - ]; - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ - protected static $openAPIFormats = [ - 'breed' => null - ]; - - /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ - protected static array $openAPINullables = [ - 'breed' => false - ]; - - /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ - protected array $openAPINullablesSetToNull = []; - - /** - * Array of property to type mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPITypes() - { - return self::$openAPITypes; - } - - /** - * Array of property to format mappings. Used for (de)serialization - * - * @return array - */ - public static function openAPIFormats() - { - return self::$openAPIFormats; - } - - /** - * Array of nullable properties - * - * @return array - */ - protected static function openAPINullables(): array - { - return self::$openAPINullables; - } - - /** - * Array of nullable field names deliberately set to null - * - * @return boolean[] - */ - private function getOpenAPINullablesSetToNull(): array - { - return $this->openAPINullablesSetToNull; - } - - /** - * Setter - Array of nullable field names deliberately set to null - * - * @param boolean[] $openAPINullablesSetToNull - */ - private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void - { - $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; - } - - /** - * Checks if a property is nullable - * - * @param string $property - * @return bool - */ - public static function isNullable(string $property): bool - { - return self::openAPINullables()[$property] ?? false; - } - - /** - * Checks if a nullable property is set to null. - * - * @param string $property - * @return bool - */ - public function isNullableSetToNull(string $property): bool - { - return in_array($property, $this->getOpenAPINullablesSetToNull(), true); - } - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @var string[] - */ - protected static $attributeMap = [ - 'breed' => 'breed' - ]; - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @var string[] - */ - protected static $setters = [ - 'breed' => 'setBreed' - ]; - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @var string[] - */ - protected static $getters = [ - 'breed' => 'getBreed' - ]; - - /** - * Array of attributes where the key is the local name, - * and the value is the original name - * - * @return array - */ - public static function attributeMap() - { - return self::$attributeMap; - } - - /** - * Array of attributes to setter functions (for deserialization of responses) - * - * @return array - */ - public static function setters() - { - return self::$setters; - } - - /** - * Array of attributes to getter functions (for serialization of requests) - * - * @return array - */ - public static function getters() - { - return self::$getters; - } - - /** - * The original name of the model. - * - * @return string - */ - public function getModelName() - { - return self::$openAPIModelName; - } - - - /** - * Associative array for storing property values - * - * @var mixed[] - */ - protected $container = []; - - /** - * Constructor - * - * @param mixed[] $data Associated array of property values - * initializing the model - */ - public function __construct(array $data = null) - { - $this->setIfExists('breed', $data ?? [], null); - } - - /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ - private function setIfExists(string $variableName, array $fields, $defaultValue): void - { - if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { - $this->openAPINullablesSetToNull[] = $variableName; - } - - $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; - } - - /** - * Show all the invalid properties with reasons. - * - * @return array invalid properties with reasons - */ - public function listInvalidProperties() - { - $invalidProperties = []; - - return $invalidProperties; - } - - /** - * Validate all the properties in the model - * return true if all passed - * - * @return bool True if all properties are valid - */ - public function valid() - { - return count($this->listInvalidProperties()) === 0; - } - - - /** - * Gets breed - * - * @return string|null - */ - public function getBreed() - { - return $this->container['breed']; - } - - /** - * Sets breed - * - * @param string|null $breed breed - * - * @return self - */ - public function setBreed($breed) - { - if (is_null($breed)) { - throw new \InvalidArgumentException('non-nullable breed cannot be null'); - } - $this->container['breed'] = $breed; - - return $this; - } - /** - * Returns true if offset exists. False otherwise. - * - * @param integer $offset Offset - * - * @return boolean - */ - public function offsetExists($offset): bool - { - return isset($this->container[$offset]); - } - - /** - * Gets offset. - * - * @param integer $offset Offset - * - * @return mixed|null - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->container[$offset] ?? null; - } - - /** - * Sets value based on offset. - * - * @param int|null $offset Offset - * @param mixed $value Value to be set - * - * @return void - */ - public function offsetSet($offset, $value): void - { - if (is_null($offset)) { - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Unsets offset. - * - * @param integer $offset Offset - * - * @return void - */ - public function offsetUnset($offset): void - { - unset($this->container[$offset]); - } - - /** - * Serializes the object to a value that can be serialized natively by json_encode(). - * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php - * - * @return mixed Returns data which can be serialized by json_encode(), which is a value - * of any type other than a resource. - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return ObjectSerializer::sanitizeForSerialization($this); - } - - /** - * Gets the string presentation of the object - * - * @return string - */ - public function __toString() - { - return json_encode( - ObjectSerializer::sanitizeForSerialization($this), - JSON_PRETTY_PRINT - ); - } - - /** - * Gets a header-safe presentation of the object - * - * @return string - */ - public function toHeaderValue() - { - return json_encode(ObjectSerializer::sanitizeForSerialization($this)); - } -} - - diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AsyncTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AsyncTest.php deleted file mode 100644 index 421eef565ce..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AsyncTest.php +++ /dev/null @@ -1,87 +0,0 @@ -api = new Api\PetApi(); - - $this->petId = 10005; - $pet = new Model\Pet; - $pet->setId($this->petId); - $pet->setName("PHP Unit Test"); - $pet->setPhotoUrls(array("http://test_php_unit_test.com")); - // new tag - $tag= new Model\Tag; - $tag->setId($this->petId); // use the same id as pet - $tag->setName("test php tag"); - // new category - $category = new Model\Category; - $category->setId($this->petId); // use the same id as pet - $category->setName("test php category"); - - $pet->setTags(array($tag)); - $pet->setCategory($category); - - $pet_api = new Api\PetApi(); - // add a new pet (model) - $add_response = $pet_api->addPet($pet); - } - - public function testAsyncRequest() - { - $promise = $this->api->getPetByIdAsync(10005); - - $promise2 = $this->api->getPetByIdAsync(10005); - - $pet = $promise->wait(); - $pet2 = $promise2->wait(); - $this->assertInstanceOf(Pet::class, $pet); - $this->assertInstanceOf(Pet::class, $pet2); - } - - public function testAsyncRequestWithHttpInfo() - { - $promise = $this->api->getPetByIdAsyncWithHttpInfo($this->petId); - - list($pet, $status, $headers) = $promise->wait(); - $this->assertEquals(200, $status); - $this->assertIsArray($headers); - $this->assertInstanceOf(Pet::class, $pet); - } - - public function testAsyncThrowingException() - { - $this->expectException(\OpenAPI\Client\ApiException::class); - $promise = $this->api->getPetByIdAsync(0); - $promise->wait(); - } - - /** - * @doesNotPerformAssertions - */ - public function testAsyncApiExceptionWithoutWaitIsNotThrown() - { - $promise = $this->api->getPetByIdAsync(0); - sleep(1); - } - - public function testAsyncHttpInfoThrowingException() - { - $this->expectException(\OpenAPI\Client\ApiException::class); - $promise = $this->api->getPetByIdAsyncWithHttpInfo(0); - $promise->wait(); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AuthTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AuthTest.php deleted file mode 100644 index 5a4755bcc61..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/AuthTest.php +++ /dev/null @@ -1,63 +0,0 @@ -setApiKey('api_key', '123qwe'); - - $fakeHttpClient = new FakeHttpClient(); - $api = new PetApi($fakeHttpClient, $authConfig); - $api->getPetById(123); - - $headers = $fakeHttpClient->getLastRequest()->getHeaders(); - - $this->assertArrayHasKey('api_key', $headers); - $this->assertEquals(['123qwe'], $headers['api_key']); - } - - public function testApiToken() - { - $authConfig = new Configuration(); - $authConfig->setAccessToken('asd123'); - - $fakeHttpClient = new FakeHttpClient(); - $api = new PetApi($fakeHttpClient, $authConfig); - $api->addPet(new Pet(array('name' => 'testing', 'photo_urls' => array('http://a.com')))); - - $headers = $fakeHttpClient->getLastRequest()->getHeaders(); - - $this->assertArrayHasKey('Authorization', $headers); - $this->assertEquals(['Bearer asd123'], $headers['Authorization']); - } - - public function testBasicAuth() - { - $username = 'user'; - $password = 'password'; - - $authConfig = new Configuration(); - $authConfig->setUsername($username); - $authConfig->setPassword($password); - - $fakeHttpClient = new FakeHttpClient(); - $api = new FakeApi($fakeHttpClient, $authConfig); - $api->testEndpointParameters(123, 100.1, 'ASD_', 'ASD'); - - $headers = $fakeHttpClient->getLastRequest()->getHeaders(); - - $this->assertArrayHasKey('Authorization', $headers); - $encodedCredentials = base64_encode("$username:$password"); - $this->assertEquals(["Basic $encodedCredentials"], $headers['Authorization']); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ConfigurationTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ConfigurationTest.php deleted file mode 100644 index eedbca0a89f..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ConfigurationTest.php +++ /dev/null @@ -1,67 +0,0 @@ -getHostSettings(); - - $this->assertCount(3, $servers); - $this->assertSame("http://{server}.swagger.io:{port}/v2", $servers[0]["url"]); - $this->assertSame("petstore", $servers[0]["variables"]["server"]["default_value"]); - $this->assertSame("80", $servers[0]["variables"]["port"]["default_value"]); - $this->assertSame(array("80", "8080"), $servers[0]["variables"]["port"]["enum_values"]); - } - - /** - * Test server settings - */ - public function testServerUrl() - { - $config = new Configuration(); - // default value - $url = $config->getHostFromSettings(0); - $this->assertSame("http://petstore.swagger.io:80/v2", $url); - - // using a variable - $url = $config->getHostFromSettings(0, array("server" => "dev-petstore")); - $this->assertSame("http://dev-petstore.swagger.io:80/v2", $url); - - // using 2 variables - $url = $config->getHostFromSettings(0, array("server" => "dev-petstore", "port" => "8080")); - $this->assertSame("http://dev-petstore.swagger.io:8080/v2", $url); - } - - /** - * Test invalid index - */ - public function testInvalidIndex() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid index 3 when selecting the host. Must be less than 3'); - $config = new Configuration(); - $url = $config->getHostFromSettings(3); - } - - /** - * Test host settings with invalid values - */ - public function testHostUrlWithInvalidValues() - { - // using 2 variables with invalid values - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('The variable `port` in the host URL has invalid value 8. Must be 80,8080'); - $config = new Configuration(); - $url = $config->getHostFromSettings(0, array("server" => "dev-petstore", "port" => "8")); - $this->assertSame("http://dev-petstore.swagger.io:8080/v2", $url); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DateTimeSerializerTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DateTimeSerializerTest.php deleted file mode 100644 index 5aee91c5a90..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DateTimeSerializerTest.php +++ /dev/null @@ -1,48 +0,0 @@ - $dateTime, - 'date' => $dateTime, - 'number' => 123.45, - 'password' => 'password', - 'byte' => '0101' - ]); - - $data = ObjectSerializer::sanitizeForSerialization($input); - - $this->assertEquals('1973-04-30T17:05:00+02:00', $data->dateTime); - - ObjectSerializer::setDateTimeFormat(\DateTime::RFC3339_EXTENDED); - $dataFraction = ObjectSerializer::sanitizeForSerialization($input); - $this->assertEquals('1973-04-30T17:05:00.000+02:00', $dataFraction->dateTime); - ObjectSerializer::setDateTimeFormat(\DateTime::ATOM); - } - - public function testDateSanitation() - { - $dateTime = new \DateTime('April 30, 1973 17:05 CEST'); - - $input = new FormatTest([ - 'date_time' => $dateTime, - 'date' => $dateTime, - 'number' => 123.45, - 'password' => 'password', - 'byte' => '0101' - ]); - - $data = ObjectSerializer::sanitizeForSerialization($input); - - $this->assertEquals('1973-04-30', $data->date); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DebugTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DebugTest.php deleted file mode 100644 index b14dd018df0..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/DebugTest.php +++ /dev/null @@ -1,38 +0,0 @@ -setId(1); - $newPet->setName("PHP Unit Test"); - (new Api\PetApi())->addPetWithHttpInfo($newPet); - } - - public function testEnableDebugOutput() - { - $this->expectOutputRegex('#GET /v2/pet/1 HTTP/1.1#'); - - $config = new Configuration(); - $config->setDebug(true); - $api = new Api\PetApi(null, $config); - $api->getPetById(1); - } - - public function testEnableDebugOutputAsync() - { - $this->expectOutputRegex('#GET /v2/pet/1 HTTP/1.1#'); - - $config = new Configuration(); - $config->setDebug(true); - $api = new Api\PetApi(null, $config); - $promise = $api->getPetByIdAsync(1); - $promise->wait(); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumClassTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumClassTest.php deleted file mode 100644 index fbc089c7f18..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumClassTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertSame(EnumClass::ABC, '_abc'); - $this->assertSame(EnumClass::EFG, '-efg'); - $this->assertSame(EnumClass::XYZ, '(xyz)'); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumTestTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumTestTest.php deleted file mode 100644 index e1111d1223c..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/EnumTestTest.php +++ /dev/null @@ -1,57 +0,0 @@ -assertSame(EnumTest::ENUM_STRING_UPPER, "UPPER"); - $this->assertSame(EnumTest::ENUM_STRING_LOWER, "lower"); - $this->assertSame(EnumTest::ENUM_INTEGER_1, 1); - $this->assertSame(EnumTest::ENUM_INTEGER_MINUS_1, -1); - $this->assertSame(EnumTest::ENUM_NUMBER_1_DOT_1, 1.1); - $this->assertSame(EnumTest::ENUM_NUMBER_MINUS_1_DOT_2, -1.2); - } - - public function testStrictValidation() - { - $enum = new EnumTest([ - 'enum_string' => 0, - ]); - - $this->assertFalse($enum->valid()); - - $expected = [ - "invalid value '0' for 'enum_string', must be one of 'UPPER', 'lower', ''", - "'enum_string_required' can't be null", - ]; - $this->assertSame($expected, $enum->listInvalidProperties()); - } - - public function testThrowExceptionWhenInvalidAmbiguousValueHasPassed() - { - $this->expectException(\InvalidArgumentException::class); - $enum = new EnumTest(); - $enum->setEnumString(0); - } - - public function testNonRequiredPropertyIsOptional() - { - $enum = new EnumTest([ - 'enum_string_required' => 'UPPER', - ]); - $this->assertSame([], $enum->listInvalidProperties()); - $this->assertTrue($enum->valid()); - } - - public function testRequiredProperty() - { - $enum = new EnumTest(); - $this->assertSame(["'enum_string_required' can't be null"], $enum->listInvalidProperties()); - $this->assertFalse($enum->valid()); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ExceptionTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ExceptionTest.php deleted file mode 100644 index c12388187fd..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ExceptionTest.php +++ /dev/null @@ -1,39 +0,0 @@ -expectException(\OpenAPI\Client\ApiException::class); - $this->expectExceptionCode(404); - $this->expectExceptionMessage('http://petstore.swagger.io/INVALID_URL/store/inventory'); - $config = new Configuration(); - $config->setHost('http://petstore.swagger.io/INVALID_URL'); - - $api = new Api\StoreApi( - new Client(), - $config - ); - $api->getInventory(); - } - - public function testWrongHost() - { - $this->expectException(\OpenAPI\Client\ApiException::class); - $this->expectExceptionMessage('Could not resolve'); - $this->expectExceptionMessage('wrong_host.zxc'); - $config = new Configuration(); - $config->setHost('http://wrong_host.zxc'); - - $api = new Api\StoreApi( - new Client(), - $config - ); - $api->getInventory(); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FakeHttpClient.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FakeHttpClient.php deleted file mode 100644 index f5e32d4c659..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FakeHttpClient.php +++ /dev/null @@ -1,70 +0,0 @@ -request; - } - - /** - * @param null|ResponseInterface $response - */ - public function setResponse(ResponseInterface $response = null) - { - $this->response = $response; - } - - /** - * Send an HTTP request. - * - * @param RequestInterface $request Request to send - * @param array $options Request options to apply to the given - * request and to the transfer. - * - * @return ResponseInterface - * @throws GuzzleException - */ - public function send(RequestInterface $request, array $options = []): ResponseInterface - { - $this->request = $request; - return $this->response ?: new Response(200); - } - - public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface - { - throw new \RuntimeException('not implemented'); - } - - public function request($method, $uri, array $options = []): ResponseInterface - { - throw new \RuntimeException('not implemented'); - } - - public function requestAsync($method, $uri, array $options = []): PromiseInterface - { - throw new \RuntimeException('not implemented'); - } - - public function getConfig($option = null) - { - throw new \RuntimeException('not implemented'); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FormatTestTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FormatTestTest.php deleted file mode 100644 index 0d96987614c..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/FormatTestTest.php +++ /dev/null @@ -1,27 +0,0 @@ - $the64MultiByteStrings, - // mandatory parameters - 'number' => 500, - 'byte' => base64_encode('test'), - 'date' => new DateTime(), - ]); - - $this->assertEmpty($formatTest->listInvalidProperties()); - - // Pass the strings via setter. - // Throws InvalidArgumentException if it doesn't count the length correctly. - $formatTest->setPassword($the64MultiByteStrings); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/HeaderSelectorTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/HeaderSelectorTest.php deleted file mode 100644 index f5c804b8e3b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/HeaderSelectorTest.php +++ /dev/null @@ -1,163 +0,0 @@ -selectHeaders($accept, $contentType, $isMultiple); - $this->assertEquals($expectedHeaders, $headers); - } - - /** - * @return array[][] - */ - public function headersProvider(): array - { - $data = [ - // array $accept, string $contentType, bool $isMultipart, array $expectedHeaders - [ - # No Accept, Content-Type - [], 'application/xml', false, ['Content-Type' => 'application/xml'], - ], - [ - # No Accept, Content-Type, multipart - [], 'application/xml', true, [], - ], - [ - # single Accept, no Content-Type - ['application/xml'], '', false, ['Accept' => 'application/xml', 'Content-Type' => 'application/json'], - ], - [ - # single Accept, no Content-Type, multipart - ['application/xml'], '', true, ['Accept' => 'application/xml'], - ], - [ - # single Accept, Content-Type - ['application/xml'], 'application/xml', false, ['Accept' => 'application/xml', 'Content-Type' => 'application/xml'], - ], - [ - # single Accept, Content-Type, multipart - ['application/xml'], 'application/xml', true, ['Accept' => 'application/xml'], - ], - [ - # single Accept with parameters, Content-Type with parameters - ['application/json;format=flowed'], 'text/plain;format=fixed', false, ['Accept' => 'application/json;format=flowed', 'Content-Type' => 'text/plain;format=fixed'], - ], - - # Tests for Accept headers - no change on Content-Type or multipart setting - [ - # Multiple Accept without Json - ['application/xml', 'text/html'], '', true, ['Accept' => 'application/xml,text/html'], - ], - [ - # Multiple Accept with application/json - ['application/json', 'text/html'], '', true, ['Accept' => 'application/json,text/html;q=0.9'], - ], - [ - # Multiple Accept with json-like - ['text/html', 'application/xml+json'], '', true, ['Accept' => 'application/xml+json,text/html;q=0.9'], - ], - [ - # Multiple Accept with application/json and json-like - ['text/html', 'application/json', 'application/xml+json'], '', true, ['Accept' => 'application/json,application/xml+json;q=0.9,text/html;q=0.8'], - ], - [ - # Multiple Accept, changing priority to application/json - ['application/xml', 'application/json;q=0.9', 'text/plain;format=flowed;q=0.8'], '', true, ['Accept' => 'application/json,application/xml;q=0.9,text/plain;format=flowed;q=0.8'], - ], - [ - # Multiple Accept, same priority for two headers, one being application/json - ['application/xml', 'application/json', 'text/plain;format=flowed;q=0.9'], '', true, ['Accept' => 'application/json,application/xml;q=0.9,text/plain;format=flowed;q=0.8'], - ], - [ - # Multiple Accept, same priority for two headers, both being application/json - ['application/json', 'application/json;IEEE754Compatible=true', 'text/plain;format=flowed;q=0.9'], '', true, ['Accept' => 'application/json,application/json;IEEE754Compatible=true,text/plain;format=flowed;q=0.9'], - ], - [ - # Multiple Accept, same priority for three headers, two being application/json, with changing priority - ['application/json;q=0.9', 'application/json;IEEE754Compatible=true;q=0.9', 'application/xml', 'text/plain;format=flowed;q=0.9'], '', true, ['Accept' => 'application/json,application/json;IEEE754Compatible=true,application/xml;q=0.9,text/plain;format=flowed;q=0.8'], - ], - ]; - - # More than 28 Accept headers - $data[] = $this->createTestDataForLargeNumberOfAcceptHeaders(30); - - # More than 1000 Accept headers - $data[] = $this->createTestDataForLargeNumberOfAcceptHeaders(1000); - - return $data; - } - - /** - * @param int $numberOfHeaders - * @return array - */ - private function createTestDataForLargeNumberOfAcceptHeaders(int $numberOfHeaders): array - { - $acceptHeaders = ['application/json;q=0.9']; - $expected = ['application/json']; - for ($i=1; $i<$numberOfHeaders; $i++) { - $q = rtrim(sprintf('%0.3f', (1000 - $i) / 1000), '0'); - $acceptHeaders[] = "application/xml;option=$i;q=$q"; - $expected[] = "application/xml;option=$i;q=$q"; - } - - return [ - $acceptHeaders, - '', - true, - ['Accept' => implode(',', $expected)] - ]; - } - - /** - * @dataProvider nextWeightProvider - * @param int $currentWeight - * @param bool $bHasMoreThan28Headers - * @param int $expected - */ - public function testGetNextWeight(int $currentWeight, bool $bHasMoreThan28Headers, int $expected): void - { - $selector = new HeaderSelector(); - - self::assertEquals($expected, $selector->getNextWeight($currentWeight, $bHasMoreThan28Headers)); - } - - public function nextWeightProvider(): array - { - return [ - [1000, true, 999], - [999, true, 998], - [2, true, 1], - [1, true, 1], - [1000, false, 900], - [900, false, 800], - [200, false, 100], - [100, false, 90], - [90, false, 80], - [20, false, 10], - [10, false, 9], - [9, false, 8], - [2, false, 1], - [1, false, 1], - [0, false, 1], - ]; - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ModelInheritanceTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ModelInheritanceTest.php deleted file mode 100644 index 333b88bbeda..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ModelInheritanceTest.php +++ /dev/null @@ -1,96 +0,0 @@ -assertSame('red', $dog->getColor()); - $this->assertSame('red', $animal->getColor()); - } - - /** - * test inheritance in the model - */ - public function testInheritance() - { - $newDog = new Dog; - // the object should be an instance of the derived class - $this->assertInstanceOf(Dog::class, $newDog); - // the object should also be an instance of the parent class - $this->assertInstanceOf(Animal::class, $newDog); - } - - /** - * test inheritance constructor is working with data initialization - */ - public function testInheritanceConstructorDataInitialization() - { - // initialize the object with data in the constructor - $data = [ - 'class_name' => 'Dog', - 'breed' => 'Great Dane', - ]; - $newDog = new Dog($data); - - // the property on the derived class should be set - $this->assertSame('Great Dane', $newDog->getBreed()); - // the property on the parent class should be set - $this->assertSame('Dog', $newDog->getClassName()); - } - - /** - * test if discriminator is initialized automatically - */ - public function testDiscriminatorInitialization() - { - $newDog = new Dog(); - $this->assertSame('Dog', $newDog->getClassName()); - } - - /** - * test if ArrayAccess interface works - */ - public function testArrayStuff() - { - // create an array of Animal - $farm = array(); - - // add some animals to the farm to make sure the ArrayAccess interface works - $farm[] = new Dog(); - $farm[] = new Cat(); - $farm[] = new Animal(); - - // assert we can look up the animals in the farm by array indices (let's try a random order) - $this->assertInstanceOf(Cat::class, $farm[1]); - $this->assertInstanceOf(Dog::class, $farm[0]); - $this->assertInstanceOf(Animal::class, $farm[2]); - - // let's try to `foreach` the animals in the farm and let's try to use the objects we loop through - foreach ($farm as $animal) { - $this->assertContains($animal->getClassName(), ['Dog', 'Cat', 'Animal']); - $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $animal); - } - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/NullableTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/NullableTest.php deleted file mode 100644 index c80812db339..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/NullableTest.php +++ /dev/null @@ -1,45 +0,0 @@ -setName(1); - $this->assertEquals(1, $name->getName(), 'Non-nullable property can be set and retains its value'); - - // comment out below as strict type is now enabled - //$this->expectException(InvalidArgumentException::class); - //$this->expectExceptionMessage('non-nullable name cannot be null'); - - $this->expectException(TypeError::class); - $this->expectExceptionMessage('must be of type int, null given'); - - //Failed asserting that exception of type "TypeError" matches expected exception "InvalidArgumentException". Message was: "OpenAPI\Client\Model\Name::setName(): Argument #1 ($name) must be of type int, null given, called in /Users/williamcheng/Code/openapi-generator7/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/NullableTest.php on line 26" at - $name->setName(null); - - } - - public function testNullableobject(): void - { - $nullable = new NullableClass(); - - $nullable->setIntegerProp(null); - $this->assertNull($nullable->getIntegerProp(), 'Nullable property can be set to null retains its value'); - - $nullable->setIntegerProp(1); - $this->assertEquals(1, $nullable->getIntegerProp(), 'Nullable property can be set and retains its value'); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ObjectSerializerTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ObjectSerializerTest.php deleted file mode 100644 index aa1357161ac..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ObjectSerializerTest.php +++ /dev/null @@ -1,634 +0,0 @@ -assertSame("sun.gif", ObjectSerializer::sanitizeFilename("sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("../sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("/var/tmp/sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("./sun.gif")); - - $this->assertSame("sun", ObjectSerializer::sanitizeFilename("sun")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("..\sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("\var\tmp\sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename("c:\var\tmp\sun.gif")); - $this->assertSame("sun.gif", ObjectSerializer::sanitizeFilename(".\sun.gif")); - } - - /** - * Test SplFileObject class deserialization. - * - * @see https://github.com/OpenAPITools/openapi-generator/pull/11184 - * @covers ObjectSerializer::deserialize - * @dataProvider provideFileStreams - */ - public function testDeserializeFile($stream, ?array $httpHeaders = null, ?string $expectedFilename = null): void - { - $s = new ObjectSerializer(); - - /** @var SplFileObject $file */ - $file = ObjectSerializer::deserialize($stream, '\SplFileObject', $httpHeaders); - $this->assertInstanceOf(SplFileObject::class, $file); - - if (is_string($expectedFilename)) { - $this->assertEquals($expectedFilename, $file->getFilename()); - } else { - $this->assertNotEquals($expectedFilename, $file->getFilename()); - } - } - - /** - * File Streams Provider - * @return array[] - */ - public function provideFileStreams(): array - { - return [ - 'File stream without headers' => [ - Utils::streamFor(\fopen(__FILE__, 'r')), - null, - null, - ], - 'File stream with Content-Disposition header' => [ - Utils::streamFor(\fopen(__FILE__, 'r')), - ['Content-Disposition' => 'inline; filename=\'foobar.php\''], - 'foobar.php', - ], - 'File path' => [ - __FILE__, - null, - null, - ], - ]; - } - - /** - * @covers ObjectSerializer::sanitizeTimestamp - * @dataProvider provideTimestamps - */ - public function testSanitizeTimestamp(string $timestamp, string $expected): void - { - $this->assertEquals($expected, ObjectSerializer::sanitizeTimestamp($timestamp)); - } - - /** - * Test datetime deserialization. - * - * @covers ObjectSerializer::deserialize - * @dataProvider provideTimestamps - * - * @see https://github.com/OpenAPITools/openapi-generator/issues/7942 - * @see https://github.com/OpenAPITools/openapi-generator/issues/10548 - */ - public function testDateTimeParseSecondAccuracy(string $timestamp, string $expected): void - { - $dateTime = ObjectSerializer::deserialize($timestamp, '\DateTime'); - $this->assertEquals(new DateTime($expected), $dateTime); - } - - /** - * Timestamps provider - * - * @return string[][] - */ - public function provideTimestamps(): array - { - return [ - 'String from #7942' => [ - '2020-11-11T15:17:58.868722633Z', - '2020-11-11T15:17:58.868722Z', - ], - 'String from #10548' => [ - '2021-10-06T20:17:16.076372256Z', - '2021-10-06T20:17:16.076372Z', - ], - 'Without timezone' => [ - '2021-10-06T20:17:16.076372256', - '2021-10-06T20:17:16.076372', - ], - 'Without microseconds' => [ - '2021-10-06T20:17:16', - '2021-10-06T20:17:16', - ], - 'Without microseconds with timezone' => [ - '2021-10-06T20:17:16Z', - '2021-10-06T20:17:16Z', - ], - 'With numeric timezone' => [ - '2021-10-06T20:17:16.076372256+03:00', - '2021-10-06T20:17:16.076372+03:00', - ], - 'With numeric timezone without delimiter' => [ - '2021-10-06T20:17:16.076372256+0300', - '2021-10-06T20:17:16.076372+0300', - ], - 'With numeric short timezone' => [ - '2021-10-06T20:17:16.076372256+03', - '2021-10-06T20:17:16.076372+03', - ], - ]; - } - - /** - * @covers ObjectSerializer::toQueryValue - * @dataProvider provideQueryParams - */ - public function testToQueryValue( - $data, - string $paramName, - string $openApiType, - string $style, - bool $explode, - bool $required, - $expected - ): void { - $value = ObjectSerializer::toQueryValue($data, $paramName, $openApiType, $style, $explode, $required); - $query = ObjectSerializer::buildQuery($value); - $this->assertEquals($expected, $query); - } - - /** - * Query params provider - * - * @return array[] - */ - public function provideQueryParams(): array - { - $array = ['blue', 'black', 'brown']; - $object = ['R' => 100, 'G' => 200, 'B' => 150]; - - return [ - // style form - // skipValidation - 'form boolean, explode on, required false' => [ - false, 'skipValidation', 'boolean', 'form', true, false, 'skipValidation=0', - ], - 'form empty boolean, explode on, required false' => [ - null, 'skipValidation', 'boolean', 'form', true, false, '', - ], - 'form empty boolean, explode on, required true' => [ - null, 'skipValidation', 'boolean', 'form', true, true, 'skipValidation=', - ], - // color= - 'form empty, explode on, required true' => [ - '', 'color', 'string', 'form', true, true, 'color=', - ], - 'form empty, explode on, required false' => [ - '', 'color', 'string', 'form', true, false, '', - ], - // color= - 'form empty, explode off, required true' => [ - '', 'color', 'string', 'form', false, true, 'color=', - ], - // color=blue - 'form string, explode on, required true' => [ - 'blue', 'color', 'string', 'form', true, true, 'color=blue', - ], - // color=blue - 'form string, explode off, required true' => [ - 'blue', 'color', 'string', 'form', false, true, 'color=blue', - ], - // color=blue&color=black&color=brown - 'form array, explode on, required true' => [ - $array, 'color', 'array', 'form', true, true, 'color=blue&color=black&color=brown', - ], - // color=blue&color=black&color=brown - 'form nested array, explode on, required true' => [ - ['foobar' => $array], 'color', 'array', 'form', true, true, 'color=blue&color=black&color=brown', - ], - // color=blue,black,brown - 'form array, explode off, required true' => [ - $array, 'color', 'array', 'form', false, true, 'color=blue%2Cblack%2Cbrown', - ], - // color=blue,black,brown - 'form nested array, explode off, required true' => [ - ['foobar' => $array], 'color', 'array', 'form', false, true, 'color=blue%2Cblack%2Cbrown', - ], - // R=100&G=200&B=150 - 'form object, explode on, required true' => [ - $object, 'color', 'object', 'form', true, true, 'R=100&G=200&B=150', - ], - // color=R,100,G,200,B,150 - 'form object, explode off, required true' => [ - $object, 'color', 'object', 'form', false, true, 'color=R%2C100%2CG%2C200%2CB%2C150', - ], - - // SPACE DELIMITED - // color=blue - 'spaceDelimited primitive, explode off, required true' => [ - 'blue', 'color', 'string', 'spaceDelimited', false, true, 'color=blue', - ], - // color=blue - 'spaceDelimited primitive, explode on, required true' => [ - 'blue', 'color', 'string', 'spaceDelimited', true, true, 'color=blue', - ], - // color=blue%20black%20brown - 'spaceDelimited array, explode off, required true' => [ - $array, 'color', 'array', 'spaceDelimited', false, true, 'color=blue%20black%20brown', - ], - // color=blue&color=black&color=brown - 'spaceDelimited array, explode on, required true' => [ - $array, 'color', 'array', 'spaceDelimited', true, true, 'color=blue&color=black&color=brown', - ], - // color=R%20100%20G%20200%20B%20150 - // swagger editor gives color=R,100,G,200,B,150 - 'spaceDelimited object, explode off, required true' => [ - $object, 'color', 'object', 'spaceDelimited', false, true, 'color=R%20100%20G%20200%20B%20150', - ], - // R=100&G=200&B=150 - 'spaceDelimited object, explode on, required true' => [ - $object, 'color', 'object', 'spaceDelimited', true, true, 'R=100&G=200&B=150', - ], - - // PIPE DELIMITED - // color=blue - 'pipeDelimited primitive, explode off, required true' => [ - 'blue', 'color', 'string', 'pipeDelimited', false, true, 'color=blue', - ], - // color=blue - 'pipeDelimited primitive, explode on, required true' => [ - 'blue', 'color', 'string', 'pipeDelimited', true, true, 'color=blue', - ], - // color=blue|black|brown - 'pipeDelimited array, explode off, required true' => [ - $array, 'color', 'array', 'pipeDelimited', false, true, 'color=blue%7Cblack%7Cbrown', - ], - // color=blue&color=black&color=brown - 'pipeDelimited array, explode on, required true' => [ - $array, 'color', 'array', 'pipeDelimited', true, true, 'color=blue&color=black&color=brown', - ], - // color=R|100|G|200|B|150 - // swagger editor gives color=R,100,G,200,B,150 - 'pipeDelimited object, explode off, required true' => [ - $object, 'color', 'object', 'pipeDelimited', false, true, 'color=R%7C100%7CG%7C200%7CB%7C150', - ], - // R=100&G=200&B=150 - 'pipeDelimited object, explode on, required true' => [ - $object, 'color', 'object', 'pipeDelimited', true, true, 'R=100&G=200&B=150', - ], - - // DEEP OBJECT - // color=blue - 'deepObject primitive, explode off, required true' => [ - 'blue', 'color', 'string', 'deepObject', false, true, 'color=blue', - ], - 'deepObject primitive, explode on, required true' => [ - 'blue', 'color', 'string', 'deepObject', true, true, 'color=blue', - ], - // color=blue,black,brown - 'deepObject array, explode off, required true' => [ - $array, 'color', 'array', 'deepObject', false, true, 'color=blue%2Cblack%2Cbrown', - ], - // color=blue&color=black&color=brown - 'deepObject array, explode on, required true' => [ - $array, 'color', 'array', 'deepObject', true, true, 'color=blue&color=black&color=brown', - ], - // color[R]=100&color[G]=200&color[B]=150 - 'deepObject object, explode off, required true' => [ - $object, 'color', 'object', 'deepObject', false, true, 'color%5BR%5D=100&color%5BG%5D=200&color%5BB%5D=150', - ], - // color[R]=100&color[G]=200&color[B]=150 - 'deepObject object, explode on, required true' => [ - $object, 'color', 'object', 'deepObject', true, true, 'color%5BR%5D=100&color%5BG%5D=200&color%5BB%5D=150', - ], - // filter[or][0][name]=John&filter[or][1][email]=john@doe.com - 'example from @nadar' => [ - [ - 'or' => - [ - ['name' => 'John'], - ['email' => 'john@doe.com'], - ], - ], - 'filter', - 'object', - 'deepObject', - true, - true, - 'filter%5Bor%5D%5B0%5D%5Bname%5D=John&filter%5Bor%5D%5B1%5D%5Bemail%5D=john%40doe.com' - ], - 'form DateTime object, explode on, required true' => [ - new DateTime('2021-10-06T20:17:16'), 'dateTime', '\DateTime', 'form', true, true, 'dateTime=2021-10-06T20%3A17%3A16%2B00%3A00', - ], - 'form null DateTime object, explode on, required true' => [ - null, 'dateTime', '\DateTime', 'form', true, true, 'dateTime=', - ], - 'form null DateTime object, explode on, required false' => [ - null, 'dateTime', '\DateTime', 'form', true, false, '', - ], - 'form 1 int, explode on, required false' => [ - 1, 'field', 'int', 'form', true, false, 'field=1', - ], - 'form 0 int, explode on, required false' => [ - 0, 'field', 'int', 'form', true, false, 'field=0', - ], - 'form 0 int, explode on, required true' => [ - 0, 'field', 'int', 'form', true, true, 'field=0', - ], - 'form null int, explode on, required false' => [ - null, 'field', 'int', 'form', true, false, '', - ], - 'form null int, explode on, required true' => [ - null, 'field', 'int', 'form', true, true, 'field=', - ], - 'form 1 integer, explode on, required false' => [ - 1, 'field', 'integer', 'form', true, false, 'field=1', - ], - 'form 0 integer, explode on, required false' => [ - 0, 'field', 'integer', 'form', true, false, 'field=0', - ], - 'form 0 integer, explode on, required true' => [ - 0, 'field', 'integer', 'form', true, true, 'field=0', - ], - 'form null integer, explode on, required false' => [ - null, 'field', 'integer', 'form', true, false, '', - ], - 'form null integer, explode on, required true' => [ - null, 'field', 'integer', 'form', true, true, 'field=', - ], - 'form 1.1 float, explode on, required false' => [ - 1.1, 'field', 'float', 'form', true, false, 'field=1.1', - ], - 'form 0 float, explode on, required false' => [ - 0, 'field', 'float', 'form', true, false, 'field=0', - ], - 'form 0.0 float, explode on, required false' => [ - 0.0, 'field', 'float', 'form', true, false, 'field=0', - ], - 'form 0 float, explode on, required true' => [ - 0, 'field', 'float', 'form', true, true, 'field=0', - ], - 'form 0.0 float, explode on, required true' => [ - 0.0, 'field', 'float', 'form', true, true, 'field=0', - ], - 'form null float, explode on, required false' => [ - null, 'field', 'float', 'form', true, false, '', - ], - 'form null float, explode on, required true' => [ - null, 'field', 'float', 'form', true, true, 'field=', - ], - 'form 1.1 number, explode on, required false' => [ - 1.1, 'field', 'number', 'form', true, false, 'field=1.1', - ], - 'form 0 number, explode on, required false' => [ - 0, 'field', 'number', 'form', true, false, 'field=0', - ], - 'form 0.0 number, explode on, required false' => [ - 0.0, 'field', 'number', 'form', true, false, 'field=0', - ], - 'form 0 number, explode on, required true' => [ - 0, 'field', 'number', 'form', true, true, 'field=0', - ], - 'form 0.0 number, explode on, required true' => [ - 0.0, 'field', 'number', 'form', true, true, 'field=0', - ], - 'form null number, explode on, required false' => [ - null, 'field', 'number', 'form', true, false, '', - ], - 'form null number, explode on, required true' => [ - null, 'field', 'number', 'form', true, true, 'field=', - ], - 'form true bool, explode on, required false' => [ - true, 'field', 'bool', 'form', true, false, 'field=1', - ], - 'form false bool, explode on, required false' => [ - false, 'field', 'bool', 'form', true, false, 'field=0', - ], - 'form empty bool, explode on, required false' => [ - null, 'field', 'bool', 'form', true, false, '', - ], - 'form empty bool, explode on, required true' => [ - null, 'field', 'bool', 'form', true, true, 'field=', - ], - # Entries for "boolean" type are already covered in the beginning of this provider - 'form 1 bool, explode on, required false' => [ - 1, 'field', 'bool', 'form', true, false, 'field=1', - ], - 'form 0 bool, explode on, required false' => [ - 0, 'field', 'bool', 'form', true, false, 'field=0', - ], - ]; - } - - /** - * @covers ObjectSerializer::toQueryValue - * @dataProvider provideDeepObjects - */ - public function testDeepObjectStyleQueryParam( - $data, - $paramName, - $expected - ): void { - $value = ObjectSerializer::buildQuery(ObjectSerializer::toQueryValue($data, $paramName, 'object', 'deepObject', true)); - parse_str($value, $result); - $this->assertEquals($expected, $result); - } - - /** - * Deep Objects provider - * - * @return array - */ - public function provideDeepObjects(): array - { - return [ - /** example @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples */ - 'example OpenAPISpec doc' => [ - ['R' => 100, 'G' => 200, 'B' => 150], - 'color', - [ - 'color' => [ - 'R' => 100, - 'G' => 200, - 'B' => 150, - ], - ], - ], - /** example @see https://swagger.io/docs/specification/serialization/ */ - 'example Swagger doc' => [ - ['role' => 'admin', 'firstName' => 'Alex'], - 'id', - [ - 'id' => [ - 'role' => 'admin', - 'firstName' => 'Alex', - ], - ], - ], - ]; - } - - /** - * @dataProvider provideToStringInput - */ - public function testToString($input, string $expected): void - { - $result = ObjectSerializer::toString($input); - - $this->assertSame($expected, $result); - } - - /** - * toString() input provider - * - * @return array - */ - public function provideToStringInput(): array - { - return [ - 'int' => [ - 'input' => 1, - 'expected' => '1', - ], - 'int 0' => [ - 'input' => 0, - 'expected' => '0', - ], - 'false' => [ - 'input' => false, - 'expected' => 'false', - ], - 'true' => [ - 'input' => true, - 'expected' => 'true', - ], - 'some string' => [ - 'input' => 'some string', - 'expected' => 'some string', - ], - 'a date' => [ - 'input' => new DateTime('14-04-2022'), - 'expected' => '2022-04-14T00:00:00+00:00', - ], - ]; - } - - /** - * @covers ObjectSerializer::toQueryValue - * @dataProvider provideQueryParamsWithStringBooleanFormatForQueryString - */ - public function testToQueryValueWithStringBooleanFormatForQueryString( - $data, - string $paramName, - string $openApiType, - string $style, - bool $explode, - bool $required, - $expected - ): void - { - $config = new Configuration(); - $config->setBooleanFormatForQueryString(Configuration::BOOLEAN_FORMAT_STRING); - $config::setDefaultConfiguration($config); - - $value = ObjectSerializer::toQueryValue($data, $paramName, $openApiType, $style, $explode, $required); - $query = ObjectSerializer::buildQuery($value); - $this->assertEquals($expected, $query); - } - - /** - * Query Params with string boolean format provider - * - * @return array[] - */ - public function provideQueryParamsWithStringBooleanFormatForQueryString(): array - { - return [ - // style form - // skipValidation - 'form boolean, required false' => [ - false, 'skipValidation', 'boolean', 'form', true, false, 'skipValidation=false', - ], - 'form empty boolean, required false' => [ - null, 'skipValidation', 'boolean', 'form', true, false, '', - ], - 'form empty boolean, required true' => [ - null, 'skipValidation', 'boolean', 'form', true, true, 'skipValidation=', - ], - 'form true boolean, required true' => [ - true, 'skipValidation', 'boolean', 'form', true, false, 'skipValidation=true', - ], - ]; - } - - /** - * @covers ObjectSerializer::buildQuery - * @dataProvider provideBuildQuery - */ - public function testToBuildQuery( - string $expected, - array $data, - string|null $booleanFormatString = null, - ): void - { - $config = new Configuration(); - if ($booleanFormatString !== null) { - $config->setBooleanFormatForQueryString($booleanFormatString); - } - $config::setDefaultConfiguration($config); - - $query = ObjectSerializer::buildQuery($data); - $this->assertEquals($expected, $query); - } - - /** @return Generator, 2?: Configuration::BOOLEAN_FORMAT_*}> */ - public function provideBuildQuery(): Generator - { - yield 'true as int' => ['foo=1', ['foo' => true]]; - yield 'true as int as default' => ['foo=1', ['foo' => true], Configuration::BOOLEAN_FORMAT_INT]; - yield 'false as int' => ['foo=0', ['foo' => false]]; - yield 'false as int as default' => ['foo=0', ['foo' => false], Configuration::BOOLEAN_FORMAT_INT]; - yield 'true as string' => ['foo=true', ['foo' => true], Configuration::BOOLEAN_FORMAT_STRING]; - yield 'false as string' => ['foo=false', ['foo' => false], Configuration::BOOLEAN_FORMAT_STRING]; - } - - /** - * Test array to class deserialization. - * - * @covers ObjectSerializer::deserialize - * - * @see https://github.com/OpenAPITools/openapi-generator/pull/12849#issuecomment-1186130098 - */ - public function testArrayGivenAsObjectForDeserialize(): void - { - $data = [ - 'name' => 'Pet Name', - 'status' => Pet::STATUS_AVAILABLE, - 'tags' => [ - ['name' => 'Tag Name'], - ] - ]; - - /** @var Pet $pet */ - $pet = ObjectSerializer::deserialize($data, Pet::class); - $this->assertEquals('Pet Name', $pet->getName()); - $this->assertEquals(Pet::STATUS_AVAILABLE, $pet->getStatus()); - - $tags = $pet->getTags(); - $this->assertIsArray($tags); - - $tag = $tags[0]; - $this->assertInstanceOf(Tag::class, $tag); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OrderApiTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OrderApiTest.php deleted file mode 100644 index 78cc9d3edf7..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OrderApiTest.php +++ /dev/null @@ -1,150 +0,0 @@ -assertSame(Model\Order::STATUS_PLACED, "placed"); - $this->assertSame(Model\Order::STATUS_APPROVED, "approved"); - } - - // test get inventory - public function testOrder() - { - // initialize the API client - $order = new Model\Order(); - - $order->setStatus("placed"); - $this->assertSame("placed", $order->getStatus()); - } - - public function testOrderException() - { - // initialize the API client - $this->expectException(\InvalidArgumentException::class); - $order = new Model\Order(); - $order->setStatus("invalid_value"); - } - - // test deserialization of order - public function testDeserializationOfOrder() - { - $order_json = <<assertInstanceOf('OpenAPI\Client\Model\Order', $order); - $this->assertSame(10, $order->getId()); - $this->assertSame(20, $order->getPetId()); - $this->assertSame(30, $order->getQuantity()); - $this->assertTrue(new \DateTime("2015-08-22T07:13:36.613Z") == $order->getShipDate()); - $this->assertSame("placed", $order->getStatus()); - $this->assertSame(false, $order->getComplete()); - } - - // test deserialization of array of array of order - public function testDeserializationOfArrayOfArrayOfOrder() - { - $order_json = <<assertArrayHasKey(0, $order); - $this->assertArrayHasKey(0, $order[0]); - $_order = $order[0][0]; - $this->assertInstanceOf('OpenAPI\Client\Model\Order', $_order); - $this->assertSame(10, $_order->getId()); - $this->assertSame(20, $_order->getPetId()); - $this->assertSame(30, $_order->getQuantity()); - $this->assertTrue(new \DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate()); - $this->assertSame("placed", $_order->getStatus()); - $this->assertSame(false, $_order->getComplete()); - } - - // test deserialization of map of map of order - public function testDeserializationOfMapOfMapOfOrder() - { - $order_json = <<assertArrayHasKey('test', $order); - $this->assertArrayHasKey('test2', $order['test']); - $_order = $order['test']['test2']; - $this->assertInstanceOf('OpenAPI\Client\Model\Order', $_order); - $this->assertSame(10, $_order->getId()); - $this->assertSame(20, $_order->getPetId()); - $this->assertSame(30, $_order->getQuantity()); - $this->assertTrue(new \DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate()); - $this->assertSame("placed", $_order->getStatus()); - $this->assertSame(false, $_order->getComplete()); - - $order = ObjectSerializer::deserialize( - json_decode($order_json), - 'array>' - ); - - $this->assertArrayHasKey('test', $order); - $this->assertArrayHasKey('test2', $order['test']); - $_order = $order['test']['test2']; - $this->assertInstanceOf('OpenAPI\Client\Model\Order', $_order); - $this->assertSame(10, $_order->getId()); - $this->assertSame(20, $_order->getPetId()); - $this->assertSame(30, $_order->getQuantity()); - $this->assertTrue(new \DateTime("2015-08-22T07:13:36.613Z") == $_order->getShipDate()); - $this->assertSame("placed", $_order->getStatus()); - $this->assertSame(false, $_order->getComplete()); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OuterEnumTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OuterEnumTest.php deleted file mode 100644 index 00777968f9b..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/OuterEnumTest.php +++ /dev/null @@ -1,95 +0,0 @@ -assertIsString($result); - $this->assertEquals('placed', $result); - } - - public function testDeserializeInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid value for enum'); - ObjectSerializer::deserialize( - "lkjfalgkdfjg", - OuterEnum::class - ); - } - - public function testDeserializeNested() - { - $json = '{ - "enum_string": "UPPER", - "enum_integer": -1, - "enum_number": -1.2, - "outerEnum": "approved" - }'; - - /** * @var EnumTest $result */ - $result = ObjectSerializer::deserialize( - json_decode($json), - EnumTest::class - ); - - $this->assertInstanceOf(EnumTest::class, $result); - $this->assertEquals('approved', $result->getOuterEnum()); - } - - public function testSanitize() - { - $json = "placed"; - - $result = ObjectSerializer::sanitizeForSerialization( - $json - ); - - $this->assertIsString($result); - } - - public function testSanitizeNested() - { - $input = new EnumTest([ - 'enum_string' => 'UPPER', - 'enum_integer' => -1, - 'enum_number' => -1.2, - 'outer_enum' => 'approved' - ]); - - $result = ObjectSerializer::sanitizeForSerialization( - $input - ); - - $this->assertIsObject($result); - $this->assertInstanceOf(\stdClass::class, $result); - - $this->assertIsString($result->outerEnum); - $this->assertEquals('approved', $result->outerEnum); - } - - public function testSanitizeNestedInvalidValue() - { - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid value for enum'); - $input = new EnumTest([ - 'enum_string' => 'UPPER', - 'enum_integer' => -1, - 'enum_number' => -1.2, - 'outer_enum' => 'invalid_value' - ]); - - ObjectSerializer::sanitizeForSerialization($input); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ParametersTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ParametersTest.php deleted file mode 100644 index 9bda987f53d..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ParametersTest.php +++ /dev/null @@ -1,87 +0,0 @@ -fakeHttpClient = new FakeHttpClient(); - $this->fakeApi = new Api\FakeApi($this->fakeHttpClient); - $this->userApi = new Api\UserApi($this->fakeHttpClient); - } - - public function testHeaderParam() - { - $this->fakeApi->testEnumParameters([], 'something'); - - $request = $this->fakeHttpClient->getLastRequest(); - $headers = $request->getHeaders(); - - $this->assertArrayHasKey('enum_header_string', $headers); - $this->assertEquals(['something'], $headers['enum_header_string']); - } - - public function testHeaderParamCollection() - { - $this->fakeApi->testEnumParameters(['string1', 'string2']); - - $request = $this->fakeHttpClient->getLastRequest(); - $headers = $request->getHeaders(); - - $this->assertArrayHasKey('enum_header_string_array', $headers); - $this->assertEquals(['string1,string2'], $headers['enum_header_string_array']); - } - - public function testInlineAdditionalProperties() - { - $param = new \stdClass(); - $param->foo = 'bar'; - $this->fakeApi->testInlineAdditionalProperties(array($param)); - - $request = $this->fakeHttpClient->getLastRequest(); - $this->assertSame('[{"foo":"bar"}]', $request->getBody()->getContents()); - } - - /** - * @see https://github.com/OpenAPITools/openapi-generator/pull/11225 - * @dataProvider provideQueryParameters - */ - public function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language, $expected) - { - $request = $this->fakeApi->testQueryParameterCollectionFormatRequest($pipe, $ioutil, $http, $url, $context, $allow_empty, $language); - $this->assertEquals($expected, urldecode($request->getUri()->getQuery())); - } - - public function provideQueryParameters() - { - $array = ['blue', 'black', 'brown']; - $object = ['R' => 100, 'G' => 200, 'B' => 150]; - return [ - [ - $array, $array, $array, $array, $array, 'blue', $object, 'pipe=blue|black|brown&ioutil=blue,black,brown&http=blue black brown&url=blue,black,brown&context=blue&context=black&context=brown&R=100&G=200&B=150&allowEmpty=blue', - ], - ]; - } - -// missing example for collection path param in config -// public function testPathParamCollection() -// { -// $this->userApi->getUserByNameWithHttpInfo(['aa', 'bb']); -// $request = $this->fakeHttpClient->getLastRequest(); -// $this->assertEquals('user/aa,bb', urldecode($request->getUri()->getPath())); -// } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/PetApiTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/PetApiTest.php deleted file mode 100644 index 758dfda0d11..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/PetApiTest.php +++ /dev/null @@ -1,387 +0,0 @@ -setId($newPetId); - $newPet->setName("PHP Unit Test"); - $newPet->setPhotoUrls(["http://test_php_unit_test.com"]); - // new tag - $tag = new Model\Tag; - $tag->setId($newPetId); // use the same id as pet - $tag->setName("test php tag"); - // new category - $category = new Model\Category; - $category->setId($newPetId); // use the same id as pet - $category->setName("test php category"); - - $newPet->setTags(array($tag)); - $newPet->setCategory($category); - - $config = new Configuration(); - $petApi = new Api\PetApi(null, $config); - - // add a new pet (model) - list(, $status) = $petApi->addPetWithHttpInfo($newPet); - Assert::assertEquals(200, $status); - } - - public function setUp(): void - { - $this->api = new Api\PetApi(); - } - - public function testGetPetById() - { - $petId = 10005; - - $pet = $this->api->getPetById($petId); - $this->assertSame($petId, $pet->getId()); - $this->assertSame('PHP Unit Test', $pet->getName()); - $this->assertSame('http://test_php_unit_test.com', $pet->getPhotoUrls()[0]); - $this->assertSame($petId, $pet->getCategory()->getId()); - $this->assertSame('test php category', $pet->getCategory()->getName()); - $this->assertSame($petId, $pet->getTags()[0]->getId()); - $this->assertSame('test php tag', $pet->getTags()[0]->getName()); - } - - /** - * comment out as we've removed invalid endpoints from the spec, we'll introduce something - * similar in the future when we've time to update the petstore server - * - * // test getPetById with a Pet object (id 10005) - * public function testGetPetByIdInObject() - * { - * // initialize the API client without host - * $pet_id = 10005; // ID of pet that needs to be fetched - * $pet_api = new Api\PetApi(); - * $pet_api->getApiClient()->getConfig()->setApiKey('api_key', '111222333444555'); - * // return Pet (inline model) - * $response = $pet_api->getPetByIdInObject($pet_id); - * $this->assertInstanceOf('OpenAPI\Client\Model\InlineResponse200', $response); - * $this->assertSame($response->getId(), $pet_id); - * $this->assertSame($response->getName(), 'PHP Unit Test'); - * $this->assertSame($response->getPhotoUrls()[0], 'http://test_php_unit_test.com'); - * - * // category is type "object" - * $this->assertInternalType('array', $response->getCategory()); - * $this->assertSame($response->getCategory()['id'], $pet_id); - * $this->assertSame($response->getCategory()['name'], 'test php category'); - * - * $this->assertSame($response->getTags()[0]->getId(), $pet_id); - * $this->assertSame($response->getTags()[0]->getName(), 'test php tag'); - * } - */ - - // test getPetByIdWithHttpInfo with a Pet object (id 10005) - public function testGetPetByIdWithHttpInfo() - { - // initialize the API client without host - $petId = 10005; // ID of pet that needs to be fetched - - /** @var $pet Pet */ - list($pet, $status_code, $response_headers) = $this->api->getPetByIdWithHttpInfo($petId); - $this->assertSame($petId, $pet->getId()); - $this->assertSame('PHP Unit Test', $pet->getName()); - $this->assertSame($petId, $pet->getCategory()->getId()); - $this->assertSame('test php category', $pet->getCategory()->getName()); - $this->assertSame($petId, $pet->getTags()[0]->getId()); - $this->assertSame('test php tag', $pet->getTags()[0]->getName()); - $this->assertSame(200, $status_code); - $this->assertSame(['application/json'], $response_headers['Content-Type']); - } - - public function testFindPetByStatus() - { - $response = $this->api->findPetsByStatus(array('available')); - $this->assertGreaterThan(0, count($response)); // at least one object returned - - $this->assertInstanceOf(Pet::class, $response[0]); // verify the object is Pet - foreach ($response as $pet) { - $this->assertSame('available', $pet->getStatus()); - } - - $response = $this->api->findPetsByStatus(array('unknown_and_incorrect_status')); - $this->assertCount(0, $response); - } - - public function testUpdatePet() - { - $petId = 10001; - $updatedPet = new Model\Pet; - $updatedPet->setId($petId); - $updatedPet->setName('updatePet'); - $updatedPet->setStatus('pending'); - $updatedPet->setPhotoUrls(array('http://a.com')); - $result = $this->api->updatePet($updatedPet); - $this->assertNull($result); - - // verify updated Pet - $result = $this->api->getPetById($petId); - $this->assertSame($petId, $result->getId()); - $this->assertSame('pending', $result->getStatus()); - $this->assertSame('updatePet', $result->getName()); - } - - // test updatePetWithFormWithHttpInfo and verify by the "name" of the response - public function testUpdatePetWithFormWithHttpInfo() - { - $petId = 10001; // ID of pet that needs to be fetched - - // update Pet (form) - list($update_response, $status_code, $http_headers) = $this->api->updatePetWithFormWithHttpInfo( - $petId, - 'update pet with form with http info' - ); - // return nothing (void) - $this->assertNull($update_response); - $this->assertSame(200, $status_code); - $this->assertSame(['application/json'], $http_headers['Content-Type']); - $response = $this->api->getPetById($petId); - $this->assertSame($petId, $response->getId()); - $this->assertSame('update pet with form with http info', $response->getName()); - } - - // test updatePetWithForm and verify by the "name" and "status" of the response - public function testUpdatePetWithForm() - { - $pet_id = 10001; // ID of pet that needs to be fetched - $result = $this->api->updatePetWithForm($pet_id, 'update pet with form', 'sold'); - // return nothing (void) - $this->assertNull($result); - - $response = $this->api->getPetById($pet_id); - $this->assertSame($pet_id, $response->getId()); - $this->assertSame('update pet with form', $response->getName()); - $this->assertSame('sold', $response->getStatus()); - } - - // test addPet and verify by the "id" and "name" of the response - public function testAddPet() - { - $new_pet_id = 10005; - $newPet = new Model\Pet; - $newPet->setId($new_pet_id); - $newPet->setName("PHP Unit Test 2"); - $newPet->setPhotoUrls(array("http://a.com")); - - // add a new pet (model) - $add_response = $this->api->addPet($newPet); - // return nothing (void) - $this->assertNull($add_response); - - // verify added Pet - $response = $this->api->getPetById($new_pet_id); - $this->assertSame($new_pet_id, $response->getId()); - $this->assertSame('PHP Unit Test 2', $response->getName()); - $this->assertSame(array("http://a.com"), $response->getPhotoUrls()); - } - - /* - * comment out as we've removed invalid endpoints from the spec, we'll introduce something - * similar in the future when we've time to update the petstore server - * - // test addPetUsingByteArray and verify by the "id" and "name" of the response - public function testAddPetUsingByteArray() - { - // initialize the API client - $config = (new Configuration())->setHost('http://petstore.swagger.io/v2'); - $api_client = new ApiClient($config); - - $new_pet_id = 10005; - $new_pet = new Model\Pet; - $new_pet->setId($new_pet_id); - $new_pet->setName("PHP Unit Test 3"); - // new tag - $tag= new Model\Tag; - $tag->setId($new_pet_id); // use the same id as pet - $tag->setName("test php tag"); - // new category - $category = new Model\Category; - $category->setId($new_pet_id); // use the same id as pet - $category->setName("test php category"); - - $new_pet->setTags(array($tag)); - $new_pet->setCategory($category); - - $pet_api = new Api\PetApi($api_client); - // add a new pet (model) - $object_serializer = new ObjectSerializer(); - $pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet)); - $add_response = $pet_api->addPetUsingByteArray($pet_json_string); - // return nothing (void) - $this->assertSame($add_response, NULL); - // verify added Pet - $response = $pet_api->getPetById($new_pet_id); - $this->assertSame($response->getId(), $new_pet_id); - $this->assertSame($response->getName(), 'PHP Unit Test 3'); - } - */ - - // test upload file - public function testUploadFile() - { - // upload file - $pet_id = 10001; - $response = $this->api->uploadFile($pet_id, 'test meta', __DIR__ . '/../composer.json'); - // return ApiResponse - $this->assertInstanceOf(ApiResponse::class, $response); - } - - /* - * comment out as we've removed invalid endpoints from the spec, we'll introduce something - * similar in the future when we've time to update the petstore server - * - // test byte array response - public function testGetPetByIdWithByteArray() - { - // initialize the API client - $config = new Configuration(); - $config->setHost('http://petstore.swagger.io/v2'); - $api_client = new APIClient($config); - $pet_api = new Api\PetApi($api_client); - // test getPetByIdWithByteArray - $pet_id = 10005; - $bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id); - $json = json_decode($bytes, true); - - $this->assertInternalType("string", $bytes); - - $this->assertSame($json['id'], $pet_id); - // not testing name as it's tested by addPetUsingByteArray - //$this->assertSame($json['name'], 'PHP Unit Test'); - $this->assertSame($json['category']['id'], $pet_id); - $this->assertSame($json['category']['name'], 'test php category'); - $this->assertSame($json['tags'][0]['id'], $pet_id); - $this->assertSame($json['tags'][0]['name'], 'test php tag'); - } - */ - - // test inheritance in the model - public function testInheritance() - { - $new_dog = new Model\Dog; - // the object should be an instance of the derived class - $this->assertInstanceOf('OpenAPI\Client\Model\Dog', $new_dog); - // the object should also be an instance of the parent class - $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $new_dog); - } - - // test inheritance constructor is working with data - // initialization - public function testInheritanceConstructorDataInitialization() - { - // initialize the object with data in the constructor - $data = array( - 'class_name' => 'Dog', - 'breed' => 'Great Dane' - ); - $new_dog = new Model\Dog($data); - - // the property on the derived class should be set - $this->assertSame('Great Dane', $new_dog->getBreed()); - // the property on the parent class should be set - $this->assertSame('Dog', $new_dog->getClassName()); - } - - // test if discriminator is initialized automatically - public function testDiscriminatorInitialization() - { - $new_dog = new Model\Dog(); - $this->assertSame('Dog', $new_dog->getClassName()); - } - - // test if ArrayAccess interface works - public function testArrayStuff() - { - // create an array of Animal - $farm = array(); - - // add some animals to the farm to make sure the ArrayAccess - // interface works - $farm[] = new Model\Dog(); - $farm[] = new Model\Cat(); - $farm[] = new Model\Animal(); - - // assert we can look up the animals in the farm by array - // indices (let's try a random order) - $this->assertInstanceOf('OpenAPI\Client\Model\Cat', $farm[1]); - $this->assertInstanceOf('OpenAPI\Client\Model\Dog', $farm[0]); - $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $farm[2]); - - // let's try to `foreach` the animals in the farm and let's - // try to use the objects we loop through - foreach ($farm as $animal) { - $this->assertContains($animal->getClassName(), array('Dog', 'Cat', 'Animal')); - $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $animal); - } - } - - // test if default values works - public function testDefaultValues() - { - // add some animals to the farm to make sure the ArrayAccess - // interface works - $dog = new Model\Dog(); - $animal = new Model\Animal(); - - // assert we can look up the animals in the farm by array - // indices (let's try a random order) - $this->assertSame('red', $dog->getColor()); - $this->assertSame('red', $animal->getColor()); - } - - /** - * test invalid argument - */ - public function testInvalidArgument() - { - // the argument is required, and we must specify one or some from 'available', 'pending', 'sold' - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Missing the required parameter $status when calling findPetsByStatus'); - $this->api->findPetsByStatus([]); - } - -// Disabled as currently we don't have any endpoint that would return file -// For testing I just replaced url and return type in Api method. -// public function testDownloadingLargeFile() -// { -// $petId = 10005; -// $config = new Configuration(); -// $config->setHost('https://getcomposer.org'); -// $api = new PetApi(new Client(), $config); -// $result = $api->getPetById($petId); -// $this->assertInstanceOf(\SplFileObject::class, $result); -// var_dump([ -// 'peak mem (MiB)' => memory_get_peak_usage(true)/1024/1024, -// 'file size (MiB)' => $result->getSize()/1024/1024, -// 'path' => sys_get_temp_dir() . '/' . $result->getFilename() -// ]); -// } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/RequestTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/RequestTest.php deleted file mode 100644 index 834e27588a7..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/RequestTest.php +++ /dev/null @@ -1,36 +0,0 @@ -fakeClient = new FakeHttpClient(); - $this->api = new Api\FakeApi($this->fakeClient); - } - - public function testFormDataEncodingToJson() - { - $this->api->testJsonFormData('value', 'value2'); - - $request = $this->fakeClient->getLastRequest(); - $contentType = $request->getHeader('Content-Type'); - $this->assertEquals(['application/x-www-form-urlencoded'], $contentType); - - $requestContent = $request->getBody()->getContents(); - - // JSON serialization of form data is not supported - $this->assertEquals('param=value¶m2=value2', $requestContent); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ResponseTypesTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ResponseTypesTest.php deleted file mode 100644 index 8d65396ccbc..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ResponseTypesTest.php +++ /dev/null @@ -1,92 +0,0 @@ -fakeHttpClient = new FakeHttpClient(); - $this->api = new PetApi($this->fakeHttpClient); - } - - public function testDefined200ReturnType() - { - $this->fakeHttpClient->setResponse(new Response(200, [], json_encode([]))); - $result = $this->api->getPetById(123); - - $this->assertInstanceOf(Pet::class, $result); - } - - public function testDefault2xxReturnType() - { - $this->fakeHttpClient->setResponse(new Response(255, [], json_encode([]))); - $result = $this->api->getPetById(123); - - $this->assertInstanceOf(Pet::class, $result); - } - - public function testDefinedErrorException() - { - $this->expectExceptionCode(400); - $this->expectException(\OpenAPI\Client\ApiException::class); - $statusCode = 400; - - $this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}')); - $this->api->getPetById(123); - } - -// missing case in spec: -// responses: -// '400': -// description: failure -// schema: -// $ref: '#/definitions/Error' -// public function testDefinedErrorResponseObject() -// { -// $result = null; -// try { -// $this->fakeHttpClient->setResponse(new Response(400, [], '{}')); -// $this->api->getPetById(123); -// } catch (ApiException $e) { -// $result = $e->getResponseObject(); -// } -// -// $this->assertInstanceOf(Error::class, $result); -// } - - public function testDefaultErrorException() - { - $this->expectExceptionCode(404); - $this->expectException(\OpenAPI\Client\ApiException::class); - $statusCode = 404; - - $this->fakeHttpClient->setResponse(new Response($statusCode, [], '{}')); - $this->api->getPetById(123); - } - - public function testDefaultErrorResponseObject() - { - $result = null; - try { - $this->fakeHttpClient->setResponse(new Response(404, [], '{}')); - $this->api->getPetById(123); - } catch (ApiException $e) { - $result = $e->getResponseObject(); - } - - $this->assertNull($result); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ServerVariablesInOperationTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ServerVariablesInOperationTest.php deleted file mode 100644 index 385b895f0dc..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/ServerVariablesInOperationTest.php +++ /dev/null @@ -1,60 +0,0 @@ -fakeHttpClient = new FakeHttpClient(); - $this->api = new Api\PetApi($this->fakeHttpClient); - $this->pet = new Model\Pet(); - $this->pet->setName("something"); - $this->pet->setPhotoUrls(array("https://a.com")); - } - - public function testServerVariablesInOperation(): void - { - # Test default values (if no variables are set) - $this->api->addPet($this->pet, 2); - $request = $this->fakeHttpClient->getLastRequest(); - - $this->assertEquals('petstore.swagger.io', $request->getUri()->getHost(), 'Server variable set to default value.'); - - # Test variables substitution - $this->api->addPet($this->pet, 2, [ 'server' => 'qa-petstore', 'port' => '8080']); - $request = $this->fakeHttpClient->getLastRequest(); - - $this->assertEquals('qa-petstore.swagger.io', $request->getUri()->getHost(), 'Server set to "qa-petstore"'); - $this->assertEquals(8080, $request->getUri()->getPort(), 'Port set to 8080'); - } - - public function testLegacyServerChoiceInOperation(): void - { - # Test legacy behavior (set server using api->setHostIndex() - $this->api->setHostIndex(1); - $this->api->addPet($this->pet); - $request = $this->fakeHttpClient->getLastRequest(); - - $this->assertEquals('path-server-test.petstore.local', $request->getUri()->getHost(), 'Server set using legacy behavior'); - } - - public function testInvalidVariableValueInOperation(): void - { - $this->expectException(InvalidArgumentException::class); - $this->api->addPet($this->pet, 2,['server' => 'invalid-value']); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/StoreApiTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/StoreApiTest.php deleted file mode 100644 index 51d64b8a93a..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/StoreApiTest.php +++ /dev/null @@ -1,58 +0,0 @@ -api = new StoreApi(); - } - - /** - * Setup before running each test case - */ - public static function setUpBeforeClass(): void - { - // add a new pet (id 10005) to ensure the pet object is available for all the tests - // new pet - $id = 10005; - $pet = new Pet(); - $pet->setId($id); - $pet->setName('PHP Unit Test'); - $pet->setPhotoUrls(array('http://a.com')); - $pet->setStatus('available'); - // new tag - $tag = new Tag(); - $tag->setId($id); // use the same id as pet - $tag->setName('test php tag'); - // new category - $category = new Category(); - $category->setId($id); // use the same id as pet - $category->setName('test php category'); - - $pet->setTags([$tag]); - $pet->setCategory($category); - - $api = new PetApi(); - $api->addPet($pet); - } - - public function testGetInventory() - { - $result = $this->api->getInventory(); - - $this->assertIsArray($result); - $this->assertIsInt($result['available']); - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/UserApiTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/UserApiTest.php deleted file mode 100644 index 929789670f9..00000000000 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/test/UserApiTest.php +++ /dev/null @@ -1,37 +0,0 @@ -api = new Api\UserApi(); - } - - // test login use - public function testLoginUser() - { - // initialize the API client - // login - $response = $this->api->loginUser('xxxxx', 'yyyyyyyy'); - - $this->assertIsString($response); - - $pattern = '/logged in user session/'; - $assertMessage = "response string starts with 'logged in user session'"; - $this->assertIsString($response); - if (method_exists($this, 'assertMatchesRegularExpression')) { - $this->assertMatchesRegularExpression($pattern, $response, $assertMessage); - } else { - $this->assertRegExp($pattern, $response, $assertMessage); - } - } -} diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Api/AnotherFakeApiTest.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Api/AnotherFakeApiTest.php index 28b50fbc881..d41d0bfbea8 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Api/AnotherFakeApiTest.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/tests/Api/AnotherFakeApiTest.php @@ -1,9 +1,8 @@