diff --git a/bin/openapi3/php-petstore.sh b/bin/openapi3/php-petstore.sh index 38287bddb8d..2f92da7f9f8 100755 --- a/bin/openapi3/php-petstore.sh +++ b/bin/openapi3/php-petstore.sh @@ -26,7 +26,7 @@ then fi # cleanup tests -TEST_DIR="./samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test" +TEST_DIR="./samples/openapi3/client/petstore/php/OpenAPIClient-php/test" if [ -d $TEST_DIR ]; then rm -rf $TEST_DIR fi diff --git a/bin/php-petstore.sh b/bin/php-petstore.sh index 7621019dbff..462be327c32 100755 --- a/bin/php-petstore.sh +++ b/bin/php-petstore.sh @@ -26,7 +26,7 @@ then fi # cleanup tests -TEST_DIR="./samples/client/petstore/php/OpenAPIToolsClient-php/test" +TEST_DIR="./samples/client/petstore/php/OpenAPIClient-php/test" if [ -d $TEST_DIR ]; then rm -rf $TEST_DIR fi diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpClientCodegen.java index 5d7c07e19f4..889808eda46 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpClientCodegen.java @@ -56,10 +56,10 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { public static final String SRC_BASE_PATH = "srcBasePath"; public static final String COMPOSER_VENDOR_NAME = "composerVendorName"; public static final String COMPOSER_PROJECT_NAME = "composerProjectName"; - protected String invokerPackage = "OpenAPITools\\Client"; + protected String invokerPackage = "OpenAPI\\Client"; protected String composerVendorName = null; protected String composerProjectName = null; - protected String packagePath = "OpenAPIToolsClient-php"; + protected String packagePath = "OpenAPIClient-php"; protected String artifactVersion = null; protected String srcBasePath = "lib"; protected String testBasePath = "test"; diff --git a/modules/openapi-generator/src/main/resources/php/ModelInterface.mustache b/modules/openapi-generator/src/main/resources/php/ModelInterface.mustache index 64b7614ded1..662c618ddbe 100644 --- a/modules/openapi-generator/src/main/resources/php/ModelInterface.mustache +++ b/modules/openapi-generator/src/main/resources/php/ModelInterface.mustache @@ -39,14 +39,14 @@ interface ModelInterface * * @return array */ - public static function openAPIToolsTypes(); + public static function openAPITypes(); /** * Array of property to format mappings. Used for (de)serialization * * @return array */ - public static function openAPIToolsFormats(); + public static function openAPIFormats(); /** * Array of attributes where the key is the local name, and the value is the original name diff --git a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache index c9c9baa34d6..6f22dd8ab40 100644 --- a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache @@ -51,19 +51,19 @@ class ObjectSerializer return $data; } elseif (is_object($data)) { $values = []; - $formats = $data::openAPIToolsFormats(); - foreach ($data::openAPIToolsTypes() as $property => $openAPIToolsType) { + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { $getter = $data::getters()[$property]; $value = $data->$getter(); if ($value !== null - && !in_array($openAPIToolsType, [{{&primitives}}], true) - && method_exists($openAPIToolsType, 'getAllowableEnumValues') - && !in_array($value, $openAPIToolsType::getAllowableEnumValues())) { - $imploded = implode("', '", $openAPIToolsType::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$openAPIToolsType', must be one of: '$imploded'"); + && !in_array($openAPIType, [{{&primitives}}], true) + && method_exists($openAPIType, 'getAllowableEnumValues') + && !in_array($value, $openAPIType::getAllowableEnumValues())) { + $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); } if ($value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIToolsType, $formats[$property]); + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); } } return (object)$values; @@ -289,7 +289,7 @@ class ObjectSerializer } } $instance = new $class(); - foreach ($instance::openAPIToolsTypes() as $property => $type) { + foreach ($instance::openAPITypes() as $property => $type) { $propertySetter = $instance::setters()[$property]; if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { diff --git a/modules/openapi-generator/src/main/resources/php/composer.mustache b/modules/openapi-generator/src/main/resources/php/composer.mustache index 7da4820b942..8d9b8f4674d 100644 --- a/modules/openapi-generator/src/main/resources/php/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php/composer.mustache @@ -6,8 +6,10 @@ "description": "{{description}}", "keywords": [ "openapitools", + "openapi-generator", "php", "sdk", + "rest", "api" ], "homepage": "http://openapi-generator.tech", diff --git a/modules/openapi-generator/src/main/resources/php/model_generic.mustache b/modules/openapi-generator/src/main/resources/php/model_generic.mustache index 899f419686d..c2d5e0e2f04 100644 --- a/modules/openapi-generator/src/main/resources/php/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/php/model_generic.mustache @@ -7,14 +7,14 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @var string */ - protected static $openAPIToolsModelName = '{{name}}'; + protected static $openAPIModelName = '{{name}}'; /** * Array of property to type mappings. Used for (de)serialization * * @var string[] */ - protected static $openAPIToolsTypes = [ + protected static $openAPITypes = [ {{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}}, {{/hasMore}}{{/vars}} ]; @@ -24,7 +24,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @var string[] */ - protected static $openAPIToolsFormats = [ + protected static $openAPIFormats = [ {{#vars}}'{{name}}' => {{#dataFormat}}'{{{dataFormat}}}'{{/dataFormat}}{{^dataFormat}}null{{/dataFormat}}{{#hasMore}}, {{/hasMore}}{{/vars}} ]; @@ -34,9 +34,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @return array */ - public static function openAPIToolsTypes() + public static function openAPITypes() { - return self::$openAPIToolsTypes{{#parentSchema}} + parent::openAPIToolsTypes(){{/parentSchema}}; + return self::$openAPITypes{{#parentSchema}} + parent::openAPITypes(){{/parentSchema}}; } /** @@ -44,9 +44,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa * * @return array */ - public static function openAPIToolsFormats() + public static function openAPIFormats() { - return self::$openAPIToolsFormats{{#parentSchema}} + parent::openAPIToolsFormats(){{/parentSchema}}; + return self::$openAPIFormats{{#parentSchema}} + parent::openAPIFormats(){{/parentSchema}}; } /** @@ -118,7 +118,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa */ public function getModelName() { - return self::$openAPIToolsModelName; + return self::$openAPIModelName; } {{#vars}}{{#isEnum}}{{#allowableValues}}{{#enumVars}}const {{enumName}}_{{{name}}} = {{{value}}}; @@ -167,7 +167,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}{{^pa // Initialize discriminator property with the model name. $discriminator = array_search('{{discriminatorName}}', self::$attributeMap); - $this->container[$discriminator] = static::$openAPIToolsModelName; + $this->container[$discriminator] = static::$openAPIModelName; {{/discriminator}} } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java index 2a444f6cec5..dd1bf2cc9c4 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java @@ -32,11 +32,11 @@ public class PhpClientCodegenTest { Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE); Assert.assertEquals(codegen.isHideGenerationTimestamp(), true); - Assert.assertEquals(codegen.modelPackage(), "OpenAPITools\\Client\\Model"); - Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "OpenAPITools\\Client\\Model"); - Assert.assertEquals(codegen.apiPackage(), "OpenAPITools\\Client\\Api"); - Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "OpenAPITools\\Client\\Api"); - Assert.assertEquals(codegen.getInvokerPackage(), "OpenAPITools\\Client"); + Assert.assertEquals(codegen.modelPackage(), "OpenAPI\\Client\\Model"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.MODEL_PACKAGE), "OpenAPI\\Client\\Model"); + Assert.assertEquals(codegen.apiPackage(), "OpenAPI\\Client\\Api"); + Assert.assertEquals(codegen.additionalProperties().get(CodegenConstants.API_PACKAGE), "OpenAPI\\Client\\Api"); + Assert.assertEquals(codegen.getInvokerPackage(), "OpenAPI\\Client"); } @Test diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpModelTest.java index cd85b62e2dd..0014415fe5e 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpModelTest.java @@ -177,7 +177,7 @@ public class PhpModelTest { final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); - Assert.assertEquals(property1.datatype, "\\OpenAPITools\\Client\\Model\\Children"); + Assert.assertEquals(property1.datatype, "\\OpenAPI\\Client\\Model\\Children"); Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.baseType, "Children"); Assert.assertFalse(property1.required); @@ -200,7 +200,7 @@ public class PhpModelTest { final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); - Assert.assertEquals(property1.datatype, "\\OpenAPITools\\Client\\Model\\Children[]"); + Assert.assertEquals(property1.datatype, "\\OpenAPI\\Client\\Model\\Children[]"); Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.baseType, "array"); Assert.assertEquals(property1.containerType, "array"); @@ -227,7 +227,7 @@ public class PhpModelTest { final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.complexType, "Children"); - Assert.assertEquals(property1.datatype, "map[string,\\OpenAPITools\\Client\\Model\\Children]"); + Assert.assertEquals(property1.datatype, "map[string,\\OpenAPI\\Client\\Model\\Children]"); Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.baseType, "map"); Assert.assertEquals(property1.containerType, "map"); diff --git a/samples/client/petstore/php/OpenAPIClient-php/.php_cs b/samples/client/petstore/php/OpenAPIClient-php/.php_cs new file mode 100644 index 00000000000..6b8e23c818a --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/.php_cs @@ -0,0 +1,18 @@ +level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->setUsingCache(true) + ->fixers( + [ + 'ordered_use', + 'phpdoc_order', + 'short_array_syntax', + 'strict', + 'strict_param' + ] + ) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ); diff --git a/samples/client/petstore/php/OpenAPIClient-php/.travis.yml b/samples/client/petstore/php/OpenAPIClient-php/.travis.yml new file mode 100644 index 00000000000..d77f3825f6f --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/.travis.yml @@ -0,0 +1,10 @@ +language: php +sudo: false +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm +before_install: "composer install" +script: "vendor/bin/phpunit" diff --git a/samples/client/petstore/php/OpenAPIClient-php/README.md b/samples/client/petstore/php/OpenAPIClient-php/README.md new file mode 100644 index 00000000000..82d72fc9c38 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/README.md @@ -0,0 +1,186 @@ +# OpenAPIClient-php +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PhpClientCodegen + +## Requirements + +PHP 5.5 and later + +## Installation & Usage +### Composer + +To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: + +``` +{ + "repositories": [ + { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + } + ], + "require": { + "GIT_USER_ID/GIT_REPO_ID": "*@dev" + } +} +``` + +Then run `composer install` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php + require_once('/path/to/OpenAPIClient-php/vendor/autoload.php'); +``` + +## Tests + +To run the unit tests: + +``` +composer install +./vendor/bin/phpunit +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```php +testSpecialTags($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; +} + +?> +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags +*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +*FakeApi* | [**testBodyWithQueryParams**](docs/Api/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | +*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case +*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/Api/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/Api/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/Api/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/Api/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/Api/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/Api/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/Api/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/Api/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md) + - [Animal](docs/Model/Animal.md) + - [AnimalFarm](docs/Model/AnimalFarm.md) + - [ApiResponse](docs/Model/ApiResponse.md) + - [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md) + - [ArrayTest](docs/Model/ArrayTest.md) + - [Capitalization](docs/Model/Capitalization.md) + - [Cat](docs/Model/Cat.md) + - [Category](docs/Model/Category.md) + - [ClassModel](docs/Model/ClassModel.md) + - [Client](docs/Model/Client.md) + - [Dog](docs/Model/Dog.md) + - [EnumArrays](docs/Model/EnumArrays.md) + - [EnumClass](docs/Model/EnumClass.md) + - [EnumTest](docs/Model/EnumTest.md) + - [FormatTest](docs/Model/FormatTest.md) + - [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md) + - [MapTest](docs/Model/MapTest.md) + - [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model200Response](docs/Model/Model200Response.md) + - [ModelList](docs/Model/ModelList.md) + - [ModelReturn](docs/Model/ModelReturn.md) + - [Name](docs/Model/Name.md) + - [NumberOnly](docs/Model/NumberOnly.md) + - [Order](docs/Model/Order.md) + - [OuterComposite](docs/Model/OuterComposite.md) + - [OuterEnum](docs/Model/OuterEnum.md) + - [Pet](docs/Model/Pet.md) + - [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md) + - [SpecialModelName](docs/Model/SpecialModelName.md) + - [Tag](docs/Model/Tag.md) + - [User](docs/Model/User.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + +## http_basic_test + +- **Type**: HTTP basic authentication + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + + + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/composer.json b/samples/client/petstore/php/OpenAPIClient-php/composer.json new file mode 100644 index 00000000000..65d3c935fb8 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/composer.json @@ -0,0 +1,38 @@ +{ + "name": "GIT_USER_ID/GIT_REPO_ID", + "description": "", + "keywords": [ + "openapitools", + "openapi-generator", + "php", + "sdk", + "rest", + "api" + ], + "homepage": "http://openapi-generator.tech", + "license": "proprietary", + "authors": [ + { + "name": "OpenAPI-Generator contributors", + "homepage": "https://openapi-generator.tech" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~1.12" + }, + "autoload": { + "psr-4": { "OpenAPI\\Client\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "OpenAPI\\Client\\" : "test/" } + } +} diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md new file mode 100644 index 00000000000..9e4f59fce29 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md @@ -0,0 +1,58 @@ +# OpenAPI\Client\AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags + + +# **testSpecialTags** +> \OpenAPI\Client\Model\Client testSpecialTags($client) + +To test special tags + +To test special tags + +### Example +```php +testSpecialTags($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md new file mode 100644 index 00000000000..e281e30e189 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -0,0 +1,548 @@ +# OpenAPI\Client\FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | +[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params | +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + + +# **fakeOuterBooleanSerialize** +> bool fakeOuterBooleanSerialize($body) + + + +Test serialization of outer boolean types + +### Example +```php +fakeOuterBooleanSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **bool**| Input boolean as post body | [optional] + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterCompositeSerialize** +> \OpenAPI\Client\Model\OuterComposite fakeOuterCompositeSerialize($outer_composite) + + + +Test serialization of object with outer number type + +### Example +```php +fakeOuterCompositeSerialize($outer_composite); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterCompositeSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outer_composite** | [**\OpenAPI\Client\Model\OuterComposite**](../Model/OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**\OpenAPI\Client\Model\OuterComposite**](../Model/OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterNumberSerialize** +> float fakeOuterNumberSerialize($body) + + + +Test serialization of outer number types + +### Example +```php +fakeOuterNumberSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterNumberSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **float**| Input number as post body | [optional] + +### Return type + +**float** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterStringSerialize** +> string fakeOuterStringSerialize($body) + + + +Test serialization of outer string types + +### Example +```php +fakeOuterStringSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterStringSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| Input string as post body | [optional] + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testBodyWithQueryParams** +> testBodyWithQueryParams($query, $user) + + + +### Example +```php +testBodyWithQueryParams($query, $user); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testBodyWithQueryParams: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **string**| | + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testClientModel** +> \OpenAPI\Client\Model\Client testClientModel($client) + +To test \"client\" model + +To test \"client\" model + +### Example +```php +testClientModel($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testClientModel: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testEndpointParameters** +> testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new OpenAPI\Client\Api\FakeApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$number = 3.4; // float | None +$double = 3.4; // double | None +$pattern_without_delimiter = 'pattern_without_delimiter_example'; // string | None +$byte = 'byte_example'; // string | None +$integer = 56; // int | None +$int32 = 56; // int | None +$int64 = 56; // int | None +$float = 3.4; // float | None +$string = 'string_example'; // string | None +$binary = "/path/to/file.txt"; // \SplFileObject | None +$date = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | None +$date_time = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | None +$password = 'password_example'; // string | None +$callback = 'callback_example'; // string | None + +try { + $apiInstance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **float**| None | + **double** | **double**| None | + **pattern_without_delimiter** | **string**| None | + **byte** | **string**| None | + **integer** | **int**| None | [optional] + **int32** | **int**| None | [optional] + **int64** | **int**| None | [optional] + **float** | **float**| None | [optional] + **string** | **string**| None | [optional] + **binary** | **\SplFileObject****\SplFileObject**| None | [optional] + **date** | **\DateTime**| None | [optional] + **date_time** | **\DateTime**| None | [optional] + **password** | **string**| None | [optional] + **callback** | **string**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testEnumParameters** +> testEnumParameters($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string) + +To test enum parameters + +To test enum parameters + +### Example +```php +testEnumParameters($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testEnumParameters: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_header_string_array** | [**string[]**](../Model/string.md)| Header parameter enum test (string array) | [optional] + **enum_header_string** | **string**| Header parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_string_array** | [**string[]**](../Model/string.md)| Query parameter enum test (string array) | [optional] + **enum_query_string** | **string**| Query parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] + **enum_query_double** | **double**| Query parameter enum test (double) | [optional] + **enum_form_string_array** | **string[]**| Form parameter enum test (string array) | [optional] [default to '$'] + **enum_form_string** | **string**| Form parameter enum test (string) | [optional] [default to '-efg'] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties($request_body) + +test inline additionalProperties + +### Example +```php + 'request_body_example'); // map[string,string] | request body + +try { + $apiInstance->testInlineAdditionalProperties($request_body); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testInlineAdditionalProperties: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **request_body** | [**map[string,string]**](../Model/string.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testJsonFormData** +> testJsonFormData($param, $param2) + +test json serialization of form data + +### Example +```php +testJsonFormData($param, $param2); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testJsonFormData: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **string**| field1 | + **param2** | **string**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md new file mode 100644 index 00000000000..b4c7dcfff38 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md @@ -0,0 +1,64 @@ +# OpenAPI\Client\FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **testClassname** +> \OpenAPI\Client\Model\Client testClassname($client) + +To test class name in snake case + +To test class name in snake case + +### Example +```php +setApiKey('api_key_query', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\FakeClassnameTags123Api( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model + +try { + $result = $apiInstance->testClassname($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +[api_key_query](../../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md new file mode 100644 index 00000000000..8af99174535 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md @@ -0,0 +1,438 @@ +# OpenAPI\Client\PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +> addPet($pet) + +Add a new pet to the store + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store + +try { + $apiInstance->addPet($pet); +} catch (Exception $e) { + echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deletePet** +> deletePet($pet_id, $api_key) + +Deletes a pet + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | Pet id to delete +$api_key = 'api_key_example'; // string | + +try { + $apiInstance->deletePet($pet_id, $api_key); +} catch (Exception $e) { + echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **string**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **findPetsByStatus** +> \OpenAPI\Client\Model\Pet[] findPetsByStatus($status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$status = array('status_example'); // string[] | Status values that need to be considered for filter + +try { + $result = $apiInstance->findPetsByStatus($status); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**string[]**](../Model/string.md)| Status values that need to be considered for filter | + +### Return type + +[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **findPetsByTags** +> \OpenAPI\Client\Model\Pet[] findPetsByTags($tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$tags = array('tags_example'); // string[] | Tags to filter by + +try { + $result = $apiInstance->findPetsByTags($tags); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**string[]**](../Model/string.md)| Tags to filter by | + +### Return type + +[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getPetById** +> \OpenAPI\Client\Model\Pet getPetById($pet_id) + +Find pet by ID + +Returns a single pet + +### Example +```php +setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to return + +try { + $result = $apiInstance->getPetById($pet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to return | + +### Return type + +[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md) + +### Authorization + +[api_key](../../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updatePet** +> updatePet($pet) + +Update an existing pet + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store + +try { + $apiInstance->updatePet($pet); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updatePetWithForm** +> updatePetWithForm($pet_id, $name, $status) + +Updates a pet in the store with form data + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet that needs to be updated +$name = 'name_example'; // string | Updated name of the pet +$status = 'status_example'; // string | Updated status of the pet + +try { + $apiInstance->updatePetWithForm($pet_id, $name, $status); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be updated | + **name** | **string**| Updated name of the pet | [optional] + **status** | **string**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **uploadFile** +> \OpenAPI\Client\Model\ApiResponse uploadFile($pet_id, $additional_metadata, $file) + +uploads an image + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to update +$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server +$file = "/path/to/file.txt"; // \SplFileObject | file to upload + +try { + $result = $apiInstance->uploadFile($pet_id, $additional_metadata, $file); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **string**| Additional data to pass to server | [optional] + **file** | **\SplFileObject****\SplFileObject**| file to upload | [optional] + +### Return type + +[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md new file mode 100644 index 00000000000..9c6cb4a782e --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md @@ -0,0 +1,207 @@ +# OpenAPI\Client\StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +> deleteOrder($order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```php +deleteOrder($order_id); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getInventory** +> map[string,int] getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```php +setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\StoreApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->getInventory(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**map[string,int]** + +### Authorization + +[api_key](../../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getOrderById** +> \OpenAPI\Client\Model\Order getOrderById($order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```php +getOrderById($order_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**\OpenAPI\Client\Model\Order**](../Model/Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **placeOrder** +> \OpenAPI\Client\Model\Order placeOrder($order) + +Place an order for a pet + +### Example +```php +placeOrder($order); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**\OpenAPI\Client\Model\Order**](../Model/Order.md)| order placed for purchasing the pet | + +### Return type + +[**\OpenAPI\Client\Model\Order**](../Model/Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md new file mode 100644 index 00000000000..c43b9262500 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md @@ -0,0 +1,392 @@ +# OpenAPI\Client\UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# **createUser** +> createUser($user) + +Create user + +This can only be done by the logged in user. + +### Example +```php +createUser($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createUsersWithArrayInput** +> createUsersWithArrayInput($user) + +Creates list of users with given input array + +### Example +```php +createUsersWithArrayInput($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User[]**](../Model/array.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createUsersWithListInput** +> createUsersWithListInput($user) + +Creates list of users with given input array + +### Example +```php +createUsersWithListInput($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User[]**](../Model/array.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deleteUser** +> deleteUser($username) + +Delete user + +This can only be done by the logged in user. + +### Example +```php +deleteUser($username); +} catch (Exception $e) { + echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getUserByName** +> \OpenAPI\Client\Model\User getUserByName($username) + +Get user by user name + +### Example +```php +getUserByName($username); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**\OpenAPI\Client\Model\User**](../Model/User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **loginUser** +> string loginUser($username, $password) + +Logs user into the system + +### Example +```php +loginUser($username, $password); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The user name for login | + **password** | **string**| The password for login in clear text | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + +### Example +```php +logoutUser(); +} catch (Exception $e) { + echo 'Exception when calling UserApi->logoutUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updateUser** +> updateUser($username, $user) + +Updated user + +This can only be done by the logged in user. + +### Example +```php +updateUser($username, $user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..b162fe9595f --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md @@ -0,0 +1,11 @@ +# AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_property** | **map[string,string]** | | [optional] +**map_of_map_property** | [**map[string,map[string,string]]**](map.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md new file mode 100644 index 00000000000..c57fbe8ea4a --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md @@ -0,0 +1,11 @@ +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | +**color** | **string** | | [optional] [default to 'red'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md new file mode 100644 index 00000000000..df6bab21dae --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md @@ -0,0 +1,9 @@ +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md new file mode 100644 index 00000000000..9d351183422 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md @@ -0,0 +1,12 @@ +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] +**type** | **string** | | [optional] +**message** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 00000000000..7831e189888 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# ArrayOfArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_array_number** | [**float[][]**](array.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md new file mode 100644 index 00000000000..a32607e4201 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# ArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_number** | **float[]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md new file mode 100644 index 00000000000..2ef4e3785e4 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md @@ -0,0 +1,12 @@ +# ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_string** | **string[]** | | [optional] +**array_array_of_integer** | [**int[][]**](array.md) | | [optional] +**array_array_of_model** | [**\OpenAPI\Client\Model\ReadOnlyFirst[][]**](array.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md new file mode 100644 index 00000000000..0fcc9e873d7 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md @@ -0,0 +1,15 @@ +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **string** | | [optional] +**capital_camel** | **string** | | [optional] +**small_snake** | **string** | | [optional] +**capital_snake** | **string** | | [optional] +**sca_eth_flow_points** | **string** | | [optional] +**att_name** | **string** | Name of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md new file mode 100644 index 00000000000..8d30565d014 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md @@ -0,0 +1,10 @@ +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md new file mode 100644 index 00000000000..80aef312e5e --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md @@ -0,0 +1,11 @@ +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md new file mode 100644 index 00000000000..3ad025b6ed3 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md @@ -0,0 +1,10 @@ +# ClassModel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md new file mode 100644 index 00000000000..f6047a62471 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md @@ -0,0 +1,10 @@ +# Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md new file mode 100644 index 00000000000..3c04bdf4cf7 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md @@ -0,0 +1,10 @@ +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md new file mode 100644 index 00000000000..ebaedecdae0 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md @@ -0,0 +1,11 @@ +# EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **string** | | [optional] +**array_enum** | **string[]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md new file mode 100644 index 00000000000..67f017becd0 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md @@ -0,0 +1,9 @@ +# EnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md new file mode 100644 index 00000000000..9aca24e644e --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md @@ -0,0 +1,14 @@ +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string** | **string** | | [optional] +**enum_string_required** | **string** | | +**enum_integer** | **int** | | [optional] +**enum_number** | **double** | | [optional] +**outer_enum** | [**\OpenAPI\Client\Model\OuterEnum**](OuterEnum.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md new file mode 100644 index 00000000000..e106ff1eba2 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md @@ -0,0 +1,22 @@ +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **int** | | [optional] +**int32** | **int** | | [optional] +**int64** | **int** | | [optional] +**number** | **float** | | +**float** | **float** | | [optional] +**double** | **double** | | [optional] +**string** | **string** | | [optional] +**byte** | **string** | | +**binary** | [**\SplFileObject**](\SplFileObject.md) | | [optional] +**date** | [**\DateTime**](\DateTime.md) | | +**date_time** | [**\DateTime**](\DateTime.md) | | [optional] +**uuid** | **string** | | [optional] +**password** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md new file mode 100644 index 00000000000..5e64572b781 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ +# HasOnlyReadOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **string** | | [optional] +**foo** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md new file mode 100644 index 00000000000..e2781ccc398 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md @@ -0,0 +1,11 @@ +# MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_map_of_string** | [**map[string,map[string,string]]**](map.md) | | [optional] +**map_of_enum_string** | **map[string,string]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..a34e2f6d129 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,12 @@ +# MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **string** | | [optional] +**date_time** | [**\DateTime**](\DateTime.md) | | [optional] +**map** | [**map[string,\OpenAPI\Client\Model\Animal]**](Animal.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md new file mode 100644 index 00000000000..ebbea5c68af --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md @@ -0,0 +1,11 @@ +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md new file mode 100644 index 00000000000..e18ba4e123d --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md @@ -0,0 +1,10 @@ +# ModelList + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123_list** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md new file mode 100644 index 00000000000..9adb62e1e12 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md @@ -0,0 +1,10 @@ +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**return** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md new file mode 100644 index 00000000000..4565647e1ef --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md @@ -0,0 +1,13 @@ +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | +**snake_case** | **int** | | [optional] +**property** | **string** | | [optional] +**_123_number** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md new file mode 100644 index 00000000000..93a0fde7b93 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md @@ -0,0 +1,10 @@ +# NumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_number** | **float** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md new file mode 100644 index 00000000000..ddae5cc2b57 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md @@ -0,0 +1,15 @@ +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | [**\DateTime**](\DateTime.md) | | [optional] +**status** | **string** | Order Status | [optional] +**complete** | **bool** | | [optional] [default to false] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md new file mode 100644 index 00000000000..e7967521395 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md @@ -0,0 +1,12 @@ +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**my_number** | **float** | | [optional] +**my_string** | **string** | | [optional] +**my_boolean** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md new file mode 100644 index 00000000000..06d413b0168 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md @@ -0,0 +1,9 @@ +# OuterEnum + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md new file mode 100644 index 00000000000..2d281a3c499 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md @@ -0,0 +1,15 @@ +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**\OpenAPI\Client\Model\Category**](Category.md) | | [optional] +**name** | **string** | | +**photo_urls** | **string[]** | | +**tags** | [**\OpenAPI\Client\Model\Tag[]**](Tag.md) | | [optional] +**status** | **string** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md new file mode 100644 index 00000000000..90662a00cf3 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md @@ -0,0 +1,11 @@ +# ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **string** | | [optional] +**baz** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md new file mode 100644 index 00000000000..022ee19169c --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md @@ -0,0 +1,10 @@ +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md new file mode 100644 index 00000000000..15ec3e0a91d --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md @@ -0,0 +1,11 @@ +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md new file mode 100644 index 00000000000..ff278fd4889 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/User.md @@ -0,0 +1,17 @@ +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **string** | | [optional] +**first_name** | **string** | | [optional] +**last_name** | **string** | | [optional] +**email** | **string** | | [optional] +**password** | **string** | | [optional] +**phone** | **string** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/git_push.sh b/samples/client/petstore/php/OpenAPIClient-php/git_push.sh new file mode 100644 index 00000000000..20057f67ade --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php new file mode 100644 index 00000000000..0d34e97176f --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -0,0 +1,365 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation testSpecialTags + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testSpecialTags($client) + { + list($response) = $this->testSpecialTagsWithHttpInfo($client); + return $response; + } + + /** + * Operation testSpecialTagsWithHttpInfo + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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 testSpecialTagsWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testSpecialTagsRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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 testSpecialTagsAsync + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testSpecialTagsAsync($client) + { + return $this->testSpecialTagsAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testSpecialTagsAsyncWithHttpInfo + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testSpecialTagsAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testSpecialTagsRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testSpecialTags' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testSpecialTagsRequest($client) + { + // 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 testSpecialTags' + ); + } + + $resourcePath = '/another-fake/dummy'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $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/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php new file mode 100644 index 00000000000..6593089617a --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -0,0 +1,2732 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation fakeOuterBooleanSerialize + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return bool + */ + public function fakeOuterBooleanSerialize($body = null) + { + list($response) = $this->fakeOuterBooleanSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterBooleanSerializeWithHttpInfo + * + * @param bool $body Input boolean as post body (optional) + * + * @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) + { + $returnType = 'bool'; + $request = $this->fakeOuterBooleanSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterBooleanSerializeAsync($body = null) + { + return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterBooleanSerializeAsyncWithHttpInfo + * + * + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'bool'; + $request = $this->fakeOuterBooleanSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterBooleanSerialize' + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterBooleanSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/boolean'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterCompositeSerialize + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\OuterComposite + */ + public function fakeOuterCompositeSerialize($outer_composite = null) + { + list($response) = $this->fakeOuterCompositeSerializeWithHttpInfo($outer_composite); + return $response; + } + + /** + * Operation fakeOuterCompositeSerializeWithHttpInfo + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\OuterComposite'; + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterCompositeSerializeAsync($outer_composite = null) + { + return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterCompositeSerializeAsyncWithHttpInfo + * + * + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite = null) + { + $returnType = '\OpenAPI\Client\Model\OuterComposite'; + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterCompositeSerialize' + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterCompositeSerializeRequest($outer_composite = null) + { + + $resourcePath = '/fake/outer/composite'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($outer_composite)) { + $_tempBody = $outer_composite; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterNumberSerialize + * + * @param float $body Input number as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return float + */ + public function fakeOuterNumberSerialize($body = null) + { + list($response) = $this->fakeOuterNumberSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterNumberSerializeWithHttpInfo + * + * @param float $body Input number as post body (optional) + * + * @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) + { + $returnType = 'float'; + $request = $this->fakeOuterNumberSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterNumberSerializeAsync($body = null) + { + return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterNumberSerializeAsyncWithHttpInfo + * + * + * + * @param float $body Input number as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'float'; + $request = $this->fakeOuterNumberSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterNumberSerialize' + * + * @param float $body Input number as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterNumberSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/number'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterStringSerialize + * + * @param string $body Input string as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return string + */ + public function fakeOuterStringSerialize($body = null) + { + list($response) = $this->fakeOuterStringSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterStringSerializeWithHttpInfo + * + * @param string $body Input string as post body (optional) + * + * @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) + { + $returnType = 'string'; + $request = $this->fakeOuterStringSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterStringSerializeAsync($body = null) + { + return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterStringSerializeAsyncWithHttpInfo + * + * + * + * @param string $body Input string as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'string'; + $request = $this->fakeOuterStringSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterStringSerialize' + * + * @param string $body Input string as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterStringSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/string'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testBodyWithQueryParams + * + * @param string $query query (required) + * @param \OpenAPI\Client\Model\User $user user (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testBodyWithQueryParams($query, $user) + { + $this->testBodyWithQueryParamsWithHttpInfo($query, $user); + } + + /** + * Operation testBodyWithQueryParamsWithHttpInfo + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @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) + { + $returnType = ''; + $request = $this->testBodyWithQueryParamsRequest($query, $user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithQueryParamsAsync($query, $user) + { + return $this->testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testBodyWithQueryParamsAsyncWithHttpInfo + * + * + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testBodyWithQueryParamsAsyncWithHttpInfo($query, $user) + { + $returnType = ''; + $request = $this->testBodyWithQueryParamsRequest($query, $user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testBodyWithQueryParams' + * + * @param string $query (required) + * @param \OpenAPI\Client\Model\User $user (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testBodyWithQueryParamsRequest($query, $user) + { + // 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 + if ($query !== null) { + $queryParams['query'] = ObjectSerializer::toQueryValue($query); + } + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testClientModel + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testClientModel($client) + { + list($response) = $this->testClientModelWithHttpInfo($client); + return $response; + } + + /** + * Operation testClientModelWithHttpInfo + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClientModelRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClientModelAsync($client) + { + return $this->testClientModelAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testClientModelAsyncWithHttpInfo + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClientModelAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClientModelRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testClientModel' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testClientModelRequest($client) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testEndpointParameters + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $this->testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + } + + /** + * Operation testEndpointParametersWithHttpInfo + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $returnType = ''; + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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 double $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) + * + * @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) + { + return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testEndpointParametersAsyncWithHttpInfo + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $returnType = ''; + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testEndpointParameters' + * + * @param float $number None (required) + * @param double $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected 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) + { + // 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'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($binary), '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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $this->testEnumParametersWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string); + } + + /** + * 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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $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_form_string_array, $enum_form_string); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + return $this->testEnumParametersAsyncWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string) + ->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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $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_form_string_array, $enum_form_string); + + 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(), + $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected 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_form_string_array = '$', $enum_form_string = '-efg') + { + + $resourcePath = '/fake'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if (is_array($enum_query_string_array)) { + $enum_query_string_array = ObjectSerializer::serializeCollection($enum_query_string_array, 'csv', true); + } + if ($enum_query_string_array !== null) { + $queryParams['enum_query_string_array'] = ObjectSerializer::toQueryValue($enum_query_string_array); + } + // query params + if ($enum_query_string !== null) { + $queryParams['enum_query_string'] = ObjectSerializer::toQueryValue($enum_query_string); + } + // query params + if ($enum_query_integer !== null) { + $queryParams['enum_query_integer'] = ObjectSerializer::toQueryValue($enum_query_integer); + } + // query params + if ($enum_query_double !== null) { + $queryParams['enum_query_double'] = ObjectSerializer::toQueryValue($enum_query_double); + } + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testInlineAdditionalProperties + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testInlineAdditionalProperties($request_body) + { + $this->testInlineAdditionalPropertiesWithHttpInfo($request_body); + } + + /** + * Operation testInlineAdditionalPropertiesWithHttpInfo + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @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) + { + $returnType = ''; + $request = $this->testInlineAdditionalPropertiesRequest($request_body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testInlineAdditionalPropertiesAsync + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testInlineAdditionalPropertiesAsync($request_body) + { + return $this->testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testInlineAdditionalPropertiesAsyncWithHttpInfo + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + { + $returnType = ''; + $request = $this->testInlineAdditionalPropertiesRequest($request_body); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testInlineAdditionalProperties' + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testInlineAdditionalPropertiesRequest($request_body) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($request_body)) { + $_tempBody = $request_body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testJsonFormData + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testJsonFormData($param, $param2) + { + $this->testJsonFormDataWithHttpInfo($param, $param2); + } + + /** + * Operation testJsonFormDataWithHttpInfo + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @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) + { + $returnType = ''; + $request = $this->testJsonFormDataRequest($param, $param2); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testJsonFormDataAsync($param, $param2) + { + return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testJsonFormDataAsyncWithHttpInfo + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testJsonFormDataAsyncWithHttpInfo($param, $param2) + { + $returnType = ''; + $request = $this->testJsonFormDataRequest($param, $param2); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testJsonFormData' + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testJsonFormDataRequest($param, $param2) + { + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php new file mode 100644 index 00000000000..5b833a82e89 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -0,0 +1,370 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testClassname($client) + { + list($response) = $this->testClassnameWithHttpInfo($client); + return $response; + } + + /** + * Operation testClassnameWithHttpInfo + * + * To test class name in snake case + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClassnameRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsync($client) + { + return $this->testClassnameAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testClassnameAsyncWithHttpInfo + * + * To test class name in snake case + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClassnameRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testClassname' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testClassnameRequest($client) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $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/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php new file mode 100644 index 00000000000..65b004b8b11 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -0,0 +1,2123 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addPet + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function addPet($pet) + { + $this->addPetWithHttpInfo($pet); + } + + /** + * Operation addPetWithHttpInfo + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @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) + { + $returnType = ''; + $request = $this->addPetRequest($pet); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation addPetAsync + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPetAsync($pet) + { + return $this->addPetAsyncWithHttpInfo($pet) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addPetAsyncWithHttpInfo + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPetAsyncWithHttpInfo($pet) + { + $returnType = ''; + $request = $this->addPetRequest($pet); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addPet' + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function addPetRequest($pet) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($pet)) { + $_tempBody = $pet; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json', 'application/xml'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePet + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key api_key (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deletePet($pet_id, $api_key = null) + { + $this->deletePetWithHttpInfo($pet_id, $api_key); + } + + /** + * Operation deletePetWithHttpInfo + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * + * @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) + { + $returnType = ''; + $request = $this->deletePetRequest($pet_id, $api_key); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePetAsync($pet_id, $api_key = null) + { + return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null) + { + $returnType = ''; + $request = $this->deletePetRequest($pet_id, $api_key); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePet' + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deletePetRequest($pet_id, $api_key = null) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation findPetsByStatus + * + * Finds Pets by status + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet[] + */ + public function findPetsByStatus($status) + { + list($response) = $this->findPetsByStatusWithHttpInfo($status); + return $response; + } + + /** + * Operation findPetsByStatusWithHttpInfo + * + * Finds Pets by status + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByStatusRequest($status); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByStatusAsync($status) + { + return $this->findPetsByStatusAsyncWithHttpInfo($status) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByStatusAsyncWithHttpInfo($status) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByStatusRequest($status); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'findPetsByStatus' + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function findPetsByStatusRequest($status) + { + // 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 + if (is_array($status)) { + $status = ObjectSerializer::serializeCollection($status, 'csv', true); + } + if ($status !== null) { + $queryParams['status'] = ObjectSerializer::toQueryValue($status); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation findPetsByTags + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet[] + */ + public function findPetsByTags($tags) + { + list($response) = $this->findPetsByTagsWithHttpInfo($tags); + return $response; + } + + /** + * Operation findPetsByTagsWithHttpInfo + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @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 findPetsByTagsWithHttpInfo($tags) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByTagsRequest($tags); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByTagsAsync($tags) + { + return $this->findPetsByTagsAsyncWithHttpInfo($tags) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation findPetsByTagsAsyncWithHttpInfo + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByTagsAsyncWithHttpInfo($tags) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByTagsRequest($tags); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'findPetsByTags' + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function findPetsByTagsRequest($tags) + { + // 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 + if (is_array($tags)) { + $tags = ObjectSerializer::serializeCollection($tags, 'csv', true); + } + if ($tags !== null) { + $queryParams['tags'] = ObjectSerializer::toQueryValue($tags); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPetById + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet + */ + public function getPetById($pet_id) + { + list($response) = $this->getPetByIdWithHttpInfo($pet_id); + return $response; + } + + /** + * Operation getPetByIdWithHttpInfo + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Pet'; + $request = $this->getPetByIdRequest($pet_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPetByIdAsync($pet_id) + { + return $this->getPetByIdAsyncWithHttpInfo($pet_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPetByIdAsyncWithHttpInfo + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPetByIdAsyncWithHttpInfo($pet_id) + { + $returnType = '\OpenAPI\Client\Model\Pet'; + $request = $this->getPetByIdRequest($pet_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPetById' + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getPetByIdRequest($pet_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePet + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updatePet($pet) + { + $this->updatePetWithHttpInfo($pet); + } + + /** + * Operation updatePetWithHttpInfo + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @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) + { + $returnType = ''; + $request = $this->updatePetRequest($pet); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation updatePetAsync + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetAsync($pet) + { + return $this->updatePetAsyncWithHttpInfo($pet) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePetAsyncWithHttpInfo + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetAsyncWithHttpInfo($pet) + { + $returnType = ''; + $request = $this->updatePetRequest($pet); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePet' + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updatePetRequest($pet) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($pet)) { + $_tempBody = $pet; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json', 'application/xml'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * 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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updatePetWithForm($pet_id, $name = null, $status = null) + { + $this->updatePetWithFormWithHttpInfo($pet_id, $name, $status); + } + + /** + * 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) + * + * @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) + { + $returnType = ''; + $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetWithFormAsync($pet_id, $name = null, $status = null) + { + return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null) + { + $returnType = ''; + $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updatePetWithFormRequest($pet_id, $name = null, $status = null) + { + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @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) + { + list($response) = $this->uploadFileWithHttpInfo($pet_id, $additional_metadata, $file); + 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) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null) + { + return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function uploadFileRequest($pet_id, $additional_metadata = null, $file = null) + { + // 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'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['multipart/form-data'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php new file mode 100644 index 00000000000..9243c750982 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -0,0 +1,1107 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteOrder($order_id) + { + $this->deleteOrderWithHttpInfo($order_id); + } + + /** + * Operation deleteOrderWithHttpInfo + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * + * @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) + { + $returnType = ''; + $request = $this->deleteOrderRequest($order_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOrderAsync($order_id) + { + return $this->deleteOrderAsyncWithHttpInfo($order_id) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOrderAsyncWithHttpInfo($order_id) + { + $returnType = ''; + $request = $this->deleteOrderRequest($order_id); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOrder' + * + * @param string $order_id ID of the order that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteOrderRequest($order_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getInventory + * + * Returns pet inventories by status + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return map[string,int] + */ + public function getInventory() + { + list($response) = $this->getInventoryWithHttpInfo(); + return $response; + } + + /** + * Operation getInventoryWithHttpInfo + * + * Returns pet inventories by status + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of map[string,int], HTTP status code, HTTP response headers (array of strings) + */ + public function getInventoryWithHttpInfo() + { + $returnType = 'map[string,int]'; + $request = $this->getInventoryRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + 'map[string,int]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getInventoryAsync + * + * Returns pet inventories by status + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getInventoryAsync() + { + return $this->getInventoryAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getInventoryAsyncWithHttpInfo + * + * Returns pet inventories by status + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getInventoryAsyncWithHttpInfo() + { + $returnType = 'map[string,int]'; + $request = $this->getInventoryRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getInventory' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getInventoryRequest() + { + + $resourcePath = '/store/inventory'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Order + */ + public function getOrderById($order_id) + { + list($response) = $this->getOrderByIdWithHttpInfo($order_id); + return $response; + } + + /** + * Operation getOrderByIdWithHttpInfo + * + * Find purchase order by ID + * + * @param int $order_id ID of pet that needs to be fetched (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->getOrderByIdRequest($order_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderByIdAsync($order_id) + { + return $this->getOrderByIdAsyncWithHttpInfo($order_id) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderByIdAsyncWithHttpInfo($order_id) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->getOrderByIdRequest($order_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderById' + * + * @param int $order_id ID of pet that needs to be fetched (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getOrderByIdRequest($order_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Order + */ + public function placeOrder($order) + { + list($response) = $this->placeOrderWithHttpInfo($order); + return $response; + } + + /** + * Operation placeOrderWithHttpInfo + * + * Place an order for a pet + * + * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->placeOrderRequest($order); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsync($order) + { + return $this->placeOrderAsyncWithHttpInfo($order) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsyncWithHttpInfo($order) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->placeOrderRequest($order); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeOrder' + * + * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function placeOrderRequest($order) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($order)) { + $_tempBody = $order; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php new file mode 100644 index 00000000000..430a4199b34 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -0,0 +1,1973 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createUser + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUser($user) + { + $this->createUserWithHttpInfo($user); + } + + /** + * Operation createUserWithHttpInfo + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUserRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUserAsync($user) + { + return $this->createUserAsyncWithHttpInfo($user) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createUserAsyncWithHttpInfo + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUserAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUserRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUser' + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUserRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUsersWithArrayInput($user) + { + $this->createUsersWithArrayInputWithHttpInfo($user); + } + + /** + * Operation createUsersWithArrayInputWithHttpInfo + * + * Creates list of users with given input array + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUsersWithArrayInputRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithArrayInputAsync($user) + { + return $this->createUsersWithArrayInputAsyncWithHttpInfo($user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithArrayInputAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUsersWithArrayInputRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUsersWithArrayInput' + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUsersWithArrayInputRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUsersWithListInput($user) + { + $this->createUsersWithListInputWithHttpInfo($user); + } + + /** + * Operation createUsersWithListInputWithHttpInfo + * + * Creates list of users with given input array + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUsersWithListInputRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithListInputAsync($user) + { + return $this->createUsersWithListInputAsyncWithHttpInfo($user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithListInputAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUsersWithListInputRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUsersWithListInput' + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUsersWithListInputRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteUser($username) + { + $this->deleteUserWithHttpInfo($username); + } + + /** + * Operation deleteUserWithHttpInfo + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @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) + { + $returnType = ''; + $request = $this->deleteUserRequest($username); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteUserAsync($username) + { + return $this->deleteUserAsyncWithHttpInfo($username) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteUserAsyncWithHttpInfo + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteUserAsyncWithHttpInfo($username) + { + $returnType = ''; + $request = $this->deleteUserRequest($username); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteUser' + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteUserRequest($username) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\User + */ + public function getUserByName($username) + { + list($response) = $this->getUserByNameWithHttpInfo($username); + return $response; + } + + /** + * Operation getUserByNameWithHttpInfo + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\User'; + $request = $this->getUserByNameRequest($username); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserByNameAsync($username) + { + return $this->getUserByNameAsyncWithHttpInfo($username) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserByNameAsyncWithHttpInfo($username) + { + $returnType = '\OpenAPI\Client\Model\User'; + $request = $this->getUserByNameRequest($username); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserByName' + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getUserByNameRequest($username) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return string + */ + public function loginUser($username, $password) + { + list($response) = $this->loginUserWithHttpInfo($username, $password); + 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) + * + * @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) + { + $returnType = 'string'; + $request = $this->loginUserRequest($username, $password); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function loginUserAsync($username, $password) + { + return $this->loginUserAsyncWithHttpInfo($username, $password) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function loginUserAsyncWithHttpInfo($username, $password) + { + $returnType = 'string'; + $request = $this->loginUserRequest($username, $password); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function loginUserRequest($username, $password) + { + // 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 + if ($username !== null) { + $queryParams['username'] = ObjectSerializer::toQueryValue($username); + } + // query params + if ($password !== null) { + $queryParams['password'] = ObjectSerializer::toQueryValue($password); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation logoutUser + * + * Logs out current logged in user session + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function logoutUser() + { + $this->logoutUserWithHttpInfo(); + } + + /** + * Operation logoutUserWithHttpInfo + * + * Logs out current logged in user session + * + * + * @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() + { + $returnType = ''; + $request = $this->logoutUserRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation logoutUserAsync + * + * Logs out current logged in user session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function logoutUserAsync() + { + return $this->logoutUserAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation logoutUserAsyncWithHttpInfo + * + * Logs out current logged in user session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function logoutUserAsyncWithHttpInfo() + { + $returnType = ''; + $request = $this->logoutUserRequest(); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'logoutUser' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function logoutUserRequest() + { + + $resourcePath = '/user/logout'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updateUser($username, $user) + { + $this->updateUserWithHttpInfo($username, $user); + } + + /** + * Operation updateUserWithHttpInfo + * + * Updated user + * + * @param string $username name that need to be deleted (required) + * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->updateUserRequest($username, $user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateUserAsync($username, $user) + { + return $this->updateUserAsyncWithHttpInfo($username, $user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateUserAsyncWithHttpInfo($username, $user) + { + $returnType = ''; + $request = $this->updateUserRequest($username, $user); + + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updateUserRequest($username, $user) + { + // 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 + ); + } + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $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/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php new file mode 100644 index 00000000000..2f59401f7a8 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/ApiException.php @@ -0,0 +1,121 @@ +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 mixed HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php new file mode 100644 index 00000000000..7b51d67087d --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Configuration.php @@ -0,0 +1,429 @@ +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 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 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 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 detault 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 .= ' OpenAPI Spec Version: 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 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; + } +} diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php new file mode 100644 index 00000000000..80475db54be --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -0,0 +1,110 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + return $headers; + } + + /** + * @param string[] $accept + * @return array + */ + public function selectHeadersForMultipart($accept) + { + $headers = $this->selectHeaders($accept, []); + + unset($headers['Content-Type']); + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif (preg_grep("/application\/json/i", $accept)) { + return 'application/json'; + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php new file mode 100644 index 00000000000..c35728944e7 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php @@ -0,0 +1,331 @@ + 'map[string,string]', + 'map_of_map_property' => 'map[string,map[string,string]]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'map_property' => null, + 'map_of_map_property' => null + ]; + + /** + * 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 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->container['map_property'] = isset($data['map_property']) ? $data['map_property'] : null; + $this->container['map_of_map_property'] = isset($data['map_of_map_property']) ? $data['map_of_map_property'] : null; + } + + /** + * 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 map[string,string] + */ + public function getMapProperty() + { + return $this->container['map_property']; + } + + /** + * Sets map_property + * + * @param map[string,string] $map_property map_property + * + * @return $this + */ + public function setMapProperty($map_property) + { + $this->container['map_property'] = $map_property; + + return $this; + } + + /** + * Gets map_of_map_property + * + * @return map[string,map[string,string]] + */ + public function getMapOfMapProperty() + { + return $this->container['map_of_map_property']; + } + + /** + * Sets map_of_map_property + * + * @param map[string,map[string,string]] $map_of_map_property map_of_map_property + * + * @return $this + */ + public function setMapOfMapProperty($map_of_map_property) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php new file mode 100644 index 00000000000..6574a08fd6f --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php @@ -0,0 +1,338 @@ + 'string', + 'color' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'class_name' => null, + 'color' => null + ]; + + /** + * 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 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->container['class_name'] = isset($data['class_name']) ? $data['class_name'] : null; + $this->container['color'] = isset($data['color']) ? $data['color'] : 'red'; + + // Initialize discriminator property with the model name. + $discriminator = array_search('className', self::$attributeMap); + $this->container[$discriminator] = static::$openAPIModelName; + } + + /** + * 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 $this + */ + public function setClassName($class_name) + { + $this->container['class_name'] = $class_name; + + return $this; + } + + /** + * Gets color + * + * @return string + */ + public function getColor() + { + return $this->container['color']; + } + + /** + * Sets color + * + * @param string $color color + * + * @return $this + */ + public function setColor($color) + { + $this->container['color'] = $color; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php new file mode 100644 index 00000000000..ba563750be0 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php @@ -0,0 +1,276 @@ +listInvalidProperties()) === 0; + } + + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php new file mode 100644 index 00000000000..571d4983244 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php @@ -0,0 +1,361 @@ + 'int', + 'type' => 'string', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'code' => 'int32', + 'type' => null, + 'message' => null + ]; + + /** + * 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 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->container['code'] = isset($data['code']) ? $data['code'] : null; + $this->container['type'] = isset($data['type']) ? $data['type'] : null; + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + } + + /** + * 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 + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param int $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type type + * + * @return $this + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message message + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php new file mode 100644 index 00000000000..20f5c0be4f1 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php @@ -0,0 +1,301 @@ + 'float[][]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'array_array_number' => null + ]; + + /** + * 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 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->container['array_array_number'] = isset($data['array_array_number']) ? $data['array_array_number'] : null; + } + + /** + * 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[][] + */ + public function getArrayArrayNumber() + { + return $this->container['array_array_number']; + } + + /** + * Sets array_array_number + * + * @param float[][] $array_array_number array_array_number + * + * @return $this + */ + public function setArrayArrayNumber($array_array_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php new file mode 100644 index 00000000000..ba5dd085926 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php @@ -0,0 +1,301 @@ + 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'array_number' => null + ]; + + /** + * 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 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->container['array_number'] = isset($data['array_number']) ? $data['array_number'] : null; + } + + /** + * 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[] + */ + public function getArrayNumber() + { + return $this->container['array_number']; + } + + /** + * Sets array_number + * + * @param float[] $array_number array_number + * + * @return $this + */ + public function setArrayNumber($array_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php new file mode 100644 index 00000000000..4d88a5f484e --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php @@ -0,0 +1,361 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'array_of_string' => null, + 'array_array_of_integer' => 'int64', + 'array_array_of_model' => null + ]; + + /** + * 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 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->container['array_of_string'] = isset($data['array_of_string']) ? $data['array_of_string'] : null; + $this->container['array_array_of_integer'] = isset($data['array_array_of_integer']) ? $data['array_array_of_integer'] : null; + $this->container['array_array_of_model'] = isset($data['array_array_of_model']) ? $data['array_array_of_model'] : null; + } + + /** + * 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_of_string + * + * @return string[] + */ + public function getArrayOfString() + { + return $this->container['array_of_string']; + } + + /** + * Sets array_of_string + * + * @param string[] $array_of_string array_of_string + * + * @return $this + */ + public function setArrayOfString($array_of_string) + { + $this->container['array_of_string'] = $array_of_string; + + return $this; + } + + /** + * Gets array_array_of_integer + * + * @return int[][] + */ + public function getArrayArrayOfInteger() + { + return $this->container['array_array_of_integer']; + } + + /** + * Sets array_array_of_integer + * + * @param int[][] $array_array_of_integer array_array_of_integer + * + * @return $this + */ + public function setArrayArrayOfInteger($array_array_of_integer) + { + $this->container['array_array_of_integer'] = $array_array_of_integer; + + return $this; + } + + /** + * Gets array_array_of_model + * + * @return \OpenAPI\Client\Model\ReadOnlyFirst[][] + */ + public function getArrayArrayOfModel() + { + return $this->container['array_array_of_model']; + } + + /** + * Sets array_array_of_model + * + * @param \OpenAPI\Client\Model\ReadOnlyFirst[][] $array_array_of_model array_array_of_model + * + * @return $this + */ + public function setArrayArrayOfModel($array_array_of_model) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php new file mode 100644 index 00000000000..165c41fcc8b --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php @@ -0,0 +1,451 @@ + '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[] + */ + 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 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 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->container['small_camel'] = isset($data['small_camel']) ? $data['small_camel'] : null; + $this->container['capital_camel'] = isset($data['capital_camel']) ? $data['capital_camel'] : null; + $this->container['small_snake'] = isset($data['small_snake']) ? $data['small_snake'] : null; + $this->container['capital_snake'] = isset($data['capital_snake']) ? $data['capital_snake'] : null; + $this->container['sca_eth_flow_points'] = isset($data['sca_eth_flow_points']) ? $data['sca_eth_flow_points'] : null; + $this->container['att_name'] = isset($data['att_name']) ? $data['att_name'] : null; + } + + /** + * 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 + */ + public function getSmallCamel() + { + return $this->container['small_camel']; + } + + /** + * Sets small_camel + * + * @param string $small_camel small_camel + * + * @return $this + */ + public function setSmallCamel($small_camel) + { + $this->container['small_camel'] = $small_camel; + + return $this; + } + + /** + * Gets capital_camel + * + * @return string + */ + public function getCapitalCamel() + { + return $this->container['capital_camel']; + } + + /** + * Sets capital_camel + * + * @param string $capital_camel capital_camel + * + * @return $this + */ + public function setCapitalCamel($capital_camel) + { + $this->container['capital_camel'] = $capital_camel; + + return $this; + } + + /** + * Gets small_snake + * + * @return string + */ + public function getSmallSnake() + { + return $this->container['small_snake']; + } + + /** + * Sets small_snake + * + * @param string $small_snake small_snake + * + * @return $this + */ + public function setSmallSnake($small_snake) + { + $this->container['small_snake'] = $small_snake; + + return $this; + } + + /** + * Gets capital_snake + * + * @return string + */ + public function getCapitalSnake() + { + return $this->container['capital_snake']; + } + + /** + * Sets capital_snake + * + * @param string $capital_snake capital_snake + * + * @return $this + */ + public function setCapitalSnake($capital_snake) + { + $this->container['capital_snake'] = $capital_snake; + + return $this; + } + + /** + * Gets sca_eth_flow_points + * + * @return string + */ + public function getScaEthFlowPoints() + { + return $this->container['sca_eth_flow_points']; + } + + /** + * Sets sca_eth_flow_points + * + * @param string $sca_eth_flow_points sca_eth_flow_points + * + * @return $this + */ + public function setScaEthFlowPoints($sca_eth_flow_points) + { + $this->container['sca_eth_flow_points'] = $sca_eth_flow_points; + + return $this; + } + + /** + * Gets att_name + * + * @return string + */ + public function getAttName() + { + return $this->container['att_name']; + } + + /** + * Sets att_name + * + * @param string $att_name Name of the pet + * + * @return $this + */ + public function setAttName($att_name) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php new file mode 100644 index 00000000000..24d015d48e0 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php @@ -0,0 +1,295 @@ + 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'declawed' => null + ]; + + /** + * 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 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->container['declawed'] = isset($data['declawed']) ? $data['declawed'] : null; + } + + /** + * 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 + */ + public function getDeclawed() + { + return $this->container['declawed']; + } + + /** + * Sets declawed + * + * @param bool $declawed declawed + * + * @return $this + */ + public function setDeclawed($declawed) + { + $this->container['declawed'] = $declawed; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php new file mode 100644 index 00000000000..976e578c1e5 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php @@ -0,0 +1,331 @@ + 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php new file mode 100644 index 00000000000..b6525b02054 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php @@ -0,0 +1,302 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + '_class' => null + ]; + + /** + * 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 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->container['_class'] = isset($data['_class']) ? $data['_class'] : null; + } + + /** + * 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 + */ + public function getClass() + { + return $this->container['_class']; + } + + /** + * Sets _class + * + * @param string $_class _class + * + * @return $this + */ + public function setClass($_class) + { + $this->container['_class'] = $_class; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php new file mode 100644 index 00000000000..43be0f8a5ec --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php @@ -0,0 +1,301 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'client' => null + ]; + + /** + * 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 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->container['client'] = isset($data['client']) ? $data['client'] : null; + } + + /** + * 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 + */ + public function getClient() + { + return $this->container['client']; + } + + /** + * Sets client + * + * @param string $client client + * + * @return $this + */ + public function setClient($client) + { + $this->container['client'] = $client; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php new file mode 100644 index 00000000000..c849f2e75b8 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php @@ -0,0 +1,295 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'breed' => null + ]; + + /** + * 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 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->container['breed'] = isset($data['breed']) ? $data['breed'] : null; + } + + /** + * 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 + */ + public function getBreed() + { + return $this->container['breed']; + } + + /** + * Sets breed + * + * @param string $breed breed + * + * @return $this + */ + public function setBreed($breed) + { + $this->container['breed'] = $breed; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php new file mode 100644 index 00000000000..98985fbc9e8 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php @@ -0,0 +1,387 @@ + 'string', + 'array_enum' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'just_symbol' => null, + 'array_enum' => null + ]; + + /** + * 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 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; + } + + const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>='; + const JUST_SYMBOL_DOLLAR = '$'; + const ARRAY_ENUM_FISH = 'fish'; + 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->container['just_symbol'] = isset($data['just_symbol']) ? $data['just_symbol'] : null; + $this->container['array_enum'] = isset($data['array_enum']) ? $data['array_enum'] : null; + } + + /** + * 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 for 'just_symbol', must be one of '%s'", + 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 + */ + public function getJustSymbol() + { + return $this->container['just_symbol']; + } + + /** + * Sets just_symbol + * + * @param string $just_symbol just_symbol + * + * @return $this + */ + public function setJustSymbol($just_symbol) + { + $allowedValues = $this->getJustSymbolAllowableValues(); + if (!is_null($just_symbol) && !in_array($just_symbol, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'just_symbol', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['just_symbol'] = $just_symbol; + + return $this; + } + + /** + * Gets array_enum + * + * @return string[] + */ + public function getArrayEnum() + { + return $this->container['array_enum']; + } + + /** + * Sets array_enum + * + * @param string[] $array_enum array_enum + * + * @return $this + */ + public function setArrayEnum($array_enum) + { + $allowedValues = $this->getArrayEnumAllowableValues(); + if (!is_null($array_enum) && 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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php new file mode 100644 index 00000000000..d8e282ed4cb --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php @@ -0,0 +1,64 @@ + 'string', + 'enum_string_required' => 'string', + 'enum_integer' => 'int', + 'enum_number' => 'double', + 'outer_enum' => '\OpenAPI\Client\Model\OuterEnum' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'enum_string' => null, + 'enum_string_required' => null, + 'enum_integer' => 'int32', + 'enum_number' => 'double', + 'outer_enum' => null + ]; + + /** + * 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 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' + ]; + + /** + * 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' + ]; + + /** + * 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' + ]; + + /** + * 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; + } + + const ENUM_STRING_UPPER = 'UPPER'; + const ENUM_STRING_LOWER = 'lower'; + const ENUM_STRING_EMPTY = ''; + const ENUM_STRING_REQUIRED_UPPER = 'UPPER'; + const ENUM_STRING_REQUIRED_LOWER = 'lower'; + const ENUM_STRING_REQUIRED_EMPTY = ''; + const ENUM_INTEGER_1 = 1; + const ENUM_INTEGER_MINUS_1 = -1; + const ENUM_NUMBER_1_DOT_1 = 1.1; + 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->container['enum_string'] = isset($data['enum_string']) ? $data['enum_string'] : null; + $this->container['enum_string_required'] = isset($data['enum_string_required']) ? $data['enum_string_required'] : null; + $this->container['enum_integer'] = isset($data['enum_integer']) ? $data['enum_integer'] : null; + $this->container['enum_number'] = isset($data['enum_number']) ? $data['enum_number'] : null; + $this->container['outer_enum'] = isset($data['outer_enum']) ? $data['outer_enum'] : null; + } + + /** + * 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 for 'enum_string', must be one of '%s'", + 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 for 'enum_string_required', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getEnumIntegerAllowableValues(); + if (!is_null($this->container['enum_integer']) && !in_array($this->container['enum_integer'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getEnumNumberAllowableValues(); + if (!is_null($this->container['enum_number']) && !in_array($this->container['enum_number'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_number', must be one of '%s'", + 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 + */ + public function getEnumString() + { + return $this->container['enum_string']; + } + + /** + * Sets enum_string + * + * @param string $enum_string enum_string + * + * @return $this + */ + public function setEnumString($enum_string) + { + $allowedValues = $this->getEnumStringAllowableValues(); + if (!is_null($enum_string) && !in_array($enum_string, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_string', must be one of '%s'", + 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 $this + */ + public function setEnumStringRequired($enum_string_required) + { + $allowedValues = $this->getEnumStringRequiredAllowableValues(); + if (!in_array($enum_string_required, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_string_required', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_string_required'] = $enum_string_required; + + return $this; + } + + /** + * Gets enum_integer + * + * @return int + */ + public function getEnumInteger() + { + return $this->container['enum_integer']; + } + + /** + * Sets enum_integer + * + * @param int $enum_integer enum_integer + * + * @return $this + */ + public function setEnumInteger($enum_integer) + { + $allowedValues = $this->getEnumIntegerAllowableValues(); + if (!is_null($enum_integer) && !in_array($enum_integer, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_integer'] = $enum_integer; + + return $this; + } + + /** + * Gets enum_number + * + * @return double + */ + public function getEnumNumber() + { + return $this->container['enum_number']; + } + + /** + * Sets enum_number + * + * @param double $enum_number enum_number + * + * @return $this + */ + public function setEnumNumber($enum_number) + { + $allowedValues = $this->getEnumNumberAllowableValues(); + if (!is_null($enum_number) && !in_array($enum_number, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_number', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_number'] = $enum_number; + + return $this; + } + + /** + * Gets outer_enum + * + * @return \OpenAPI\Client\Model\OuterEnum + */ + public function getOuterEnum() + { + return $this->container['outer_enum']; + } + + /** + * Sets outer_enum + * + * @param \OpenAPI\Client\Model\OuterEnum $outer_enum outer_enum + * + * @return $this + */ + public function setOuterEnum($outer_enum) + { + $this->container['outer_enum'] = $outer_enum; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php new file mode 100644 index 00000000000..9aa38eca136 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php @@ -0,0 +1,786 @@ + 'int', + 'int32' => 'int', + 'int64' => 'int', + 'number' => 'float', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'byte' => 'string', + 'binary' => '\SplFileObject', + 'date' => '\DateTime', + 'date_time' => '\DateTime', + 'uuid' => 'string', + 'password' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'integer' => null, + 'int32' => 'int32', + 'int64' => 'int64', + 'number' => null, + 'float' => 'float', + 'double' => 'double', + 'string' => null, + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'date-time', + 'uuid' => 'uuid', + 'password' => 'password' + ]; + + /** + * 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 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', + 'string' => 'string', + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'dateTime', + 'uuid' => 'uuid', + 'password' => 'password' + ]; + + /** + * 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', + 'string' => 'setString', + 'byte' => 'setByte', + 'binary' => 'setBinary', + 'date' => 'setDate', + 'date_time' => 'setDateTime', + 'uuid' => 'setUuid', + 'password' => 'setPassword' + ]; + + /** + * 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', + 'string' => 'getString', + 'byte' => 'getByte', + 'binary' => 'getBinary', + 'date' => 'getDate', + 'date_time' => 'getDateTime', + 'uuid' => 'getUuid', + 'password' => 'getPassword' + ]; + + /** + * 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->container['integer'] = isset($data['integer']) ? $data['integer'] : null; + $this->container['int32'] = isset($data['int32']) ? $data['int32'] : null; + $this->container['int64'] = isset($data['int64']) ? $data['int64'] : null; + $this->container['number'] = isset($data['number']) ? $data['number'] : null; + $this->container['float'] = isset($data['float']) ? $data['float'] : null; + $this->container['double'] = isset($data['double']) ? $data['double'] : null; + $this->container['string'] = isset($data['string']) ? $data['string'] : null; + $this->container['byte'] = isset($data['byte']) ? $data['byte'] : null; + $this->container['binary'] = isset($data['binary']) ? $data['binary'] : null; + $this->container['date'] = isset($data['date']) ? $data['date'] : null; + $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; + $this->container['password'] = isset($data['password']) ? $data['password'] : null; + } + + /** + * 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 (!preg_match("/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/", $this->container['byte'])) { + $invalidProperties[] = "invalid value for 'byte', must be conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."; + } + + 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."; + } + + 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 + */ + public function getInteger() + { + return $this->container['integer']; + } + + /** + * Sets integer + * + * @param int $integer integer + * + * @return $this + */ + public function setInteger($integer) + { + + if (!is_null($integer) && ($integer > 100)) { + throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be smaller than or equal to 100.'); + } + if (!is_null($integer) && ($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 + */ + public function getInt32() + { + return $this->container['int32']; + } + + /** + * Sets int32 + * + * @param int $int32 int32 + * + * @return $this + */ + public function setInt32($int32) + { + + if (!is_null($int32) && ($int32 > 200)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be smaller than or equal to 200.'); + } + if (!is_null($int32) && ($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 + */ + public function getInt64() + { + return $this->container['int64']; + } + + /** + * Sets int64 + * + * @param int $int64 int64 + * + * @return $this + */ + public function setInt64($int64) + { + $this->container['int64'] = $int64; + + return $this; + } + + /** + * Gets number + * + * @return float + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param float $number number + * + * @return $this + */ + public function setNumber($number) + { + + 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 + */ + public function getFloat() + { + return $this->container['float']; + } + + /** + * Sets float + * + * @param float $float float + * + * @return $this + */ + public function setFloat($float) + { + + if (!is_null($float) && ($float > 987.6)) { + throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be smaller than or equal to 987.6.'); + } + if (!is_null($float) && ($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 double + */ + public function getDouble() + { + return $this->container['double']; + } + + /** + * Sets double + * + * @param double $double double + * + * @return $this + */ + public function setDouble($double) + { + + if (!is_null($double) && ($double > 123.4)) { + throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be smaller than or equal to 123.4.'); + } + if (!is_null($double) && ($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 string + * + * @return string + */ + public function getString() + { + return $this->container['string']; + } + + /** + * Sets string + * + * @param string $string string + * + * @return $this + */ + public function setString($string) + { + + if (!is_null($string) && (!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 $this + */ + public function setByte($byte) + { + + if ((!preg_match("/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/", $byte))) { + throw new \InvalidArgumentException("invalid value for $byte when calling FormatTest., must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/."); + } + + $this->container['byte'] = $byte; + + return $this; + } + + /** + * Gets binary + * + * @return \SplFileObject + */ + public function getBinary() + { + return $this->container['binary']; + } + + /** + * Sets binary + * + * @param \SplFileObject $binary binary + * + * @return $this + */ + public function setBinary($binary) + { + $this->container['binary'] = $binary; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime $date date + * + * @return $this + */ + public function setDate($date) + { + $this->container['date'] = $date; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime $date_time date_time + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets uuid + * + * @return string + */ + public function getUuid() + { + return $this->container['uuid']; + } + + /** + * Sets uuid + * + * @param string $uuid uuid + * + * @return $this + */ + public function setUuid($uuid) + { + $this->container['uuid'] = $uuid; + + return $this; + } + + /** + * Gets password + * + * @return string + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string $password password + * + * @return $this + */ + public function setPassword($password) + { + 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; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php new file mode 100644 index 00000000000..ba447b30c42 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php @@ -0,0 +1,331 @@ + 'string', + 'foo' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'bar' => null, + 'foo' => null + ]; + + /** + * 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 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->container['bar'] = isset($data['bar']) ? $data['bar'] : null; + $this->container['foo'] = isset($data['foo']) ? $data['foo'] : null; + } + + /** + * 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 + */ + public function getBar() + { + return $this->container['bar']; + } + + /** + * Sets bar + * + * @param string $bar bar + * + * @return $this + */ + public function setBar($bar) + { + $this->container['bar'] = $bar; + + return $this; + } + + /** + * Gets foo + * + * @return string + */ + public function getFoo() + { + return $this->container['foo']; + } + + /** + * Sets foo + * + * @param string $foo foo + * + * @return $this + */ + public function setFoo($foo) + { + $this->container['foo'] = $foo; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php new file mode 100644 index 00000000000..868afa3d3f8 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php @@ -0,0 +1,355 @@ + 'map[string,map[string,string]]', + 'map_of_enum_string' => 'map[string,string]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'map_map_of_string' => null, + 'map_of_enum_string' => null + ]; + + /** + * 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 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' + ]; + + /** + * 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' + ]; + + /** + * 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' + ]; + + /** + * 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; + } + + const MAP_OF_ENUM_STRING_UPPER = 'UPPER'; + 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->container['map_map_of_string'] = isset($data['map_map_of_string']) ? $data['map_map_of_string'] : null; + $this->container['map_of_enum_string'] = isset($data['map_of_enum_string']) ? $data['map_of_enum_string'] : null; + } + + /** + * 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 map[string,map[string,string]] + */ + public function getMapMapOfString() + { + return $this->container['map_map_of_string']; + } + + /** + * Sets map_map_of_string + * + * @param map[string,map[string,string]] $map_map_of_string map_map_of_string + * + * @return $this + */ + public function setMapMapOfString($map_map_of_string) + { + $this->container['map_map_of_string'] = $map_map_of_string; + + return $this; + } + + /** + * Gets map_of_enum_string + * + * @return map[string,string] + */ + public function getMapOfEnumString() + { + return $this->container['map_of_enum_string']; + } + + /** + * Sets map_of_enum_string + * + * @param map[string,string] $map_of_enum_string map_of_enum_string + * + * @return $this + */ + public function setMapOfEnumString($map_of_enum_string) + { + $allowedValues = $this->getMapOfEnumStringAllowableValues(); + if (!is_null($map_of_enum_string) && 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; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php new file mode 100644 index 00000000000..0e23c1cf7d7 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php @@ -0,0 +1,361 @@ + 'string', + 'date_time' => '\DateTime', + 'map' => 'map[string,\OpenAPI\Client\Model\Animal]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'uuid' => 'uuid', + 'date_time' => 'date-time', + 'map' => null + ]; + + /** + * 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 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->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; + $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['map'] = isset($data['map']) ? $data['map'] : null; + } + + /** + * 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 + */ + public function getUuid() + { + return $this->container['uuid']; + } + + /** + * Sets uuid + * + * @param string $uuid uuid + * + * @return $this + */ + public function setUuid($uuid) + { + $this->container['uuid'] = $uuid; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime $date_time date_time + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets map + * + * @return map[string,\OpenAPI\Client\Model\Animal] + */ + public function getMap() + { + return $this->container['map']; + } + + /** + * Sets map + * + * @param map[string,\OpenAPI\Client\Model\Animal] $map map + * + * @return $this + */ + public function setMap($map) + { + $this->container['map'] = $map; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php new file mode 100644 index 00000000000..f781ba56e36 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php @@ -0,0 +1,332 @@ + 'int', + 'class' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => 'int32', + 'class' => null + ]; + + /** + * 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 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->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['class'] = isset($data['class']) ? $data['class'] : null; + } + + /** + * 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 + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param int $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets class + * + * @return string + */ + public function getClass() + { + return $this->container['class']; + } + + /** + * Sets class + * + * @param string $class class + * + * @return $this + */ + public function setClass($class) + { + $this->container['class'] = $class; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php new file mode 100644 index 00000000000..7df58906de6 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php @@ -0,0 +1,96 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + '_123_list' => null + ]; + + /** + * 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 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->container['_123_list'] = isset($data['_123_list']) ? $data['_123_list'] : null; + } + + /** + * 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 + */ + public function get123List() + { + return $this->container['_123_list']; + } + + /** + * Sets _123_list + * + * @param string $_123_list _123_list + * + * @return $this + */ + public function set123List($_123_list) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php new file mode 100644 index 00000000000..4d0663e296d --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -0,0 +1,302 @@ + 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'return' => 'int32' + ]; + + /** + * 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 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->container['return'] = isset($data['return']) ? $data['return'] : null; + } + + /** + * 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 + */ + public function getReturn() + { + return $this->container['return']; + } + + /** + * Sets return + * + * @param int $return return + * + * @return $this + */ + public function setReturn($return) + { + $this->container['return'] = $return; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php new file mode 100644 index 00000000000..8f6f7299ae0 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php @@ -0,0 +1,395 @@ + 'int', + 'snake_case' => 'int', + 'property' => 'string', + '_123_number' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => 'int32', + 'snake_case' => 'int32', + 'property' => null, + '_123_number' => null + ]; + + /** + * 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 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->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['snake_case'] = isset($data['snake_case']) ? $data['snake_case'] : null; + $this->container['property'] = isset($data['property']) ? $data['property'] : null; + $this->container['_123_number'] = isset($data['_123_number']) ? $data['_123_number'] : null; + } + + /** + * 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 $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets snake_case + * + * @return int + */ + public function getSnakeCase() + { + return $this->container['snake_case']; + } + + /** + * Sets snake_case + * + * @param int $snake_case snake_case + * + * @return $this + */ + public function setSnakeCase($snake_case) + { + $this->container['snake_case'] = $snake_case; + + return $this; + } + + /** + * Gets property + * + * @return string + */ + public function getProperty() + { + return $this->container['property']; + } + + /** + * Sets property + * + * @param string $property property + * + * @return $this + */ + public function setProperty($property) + { + $this->container['property'] = $property; + + return $this; + } + + /** + * Gets _123_number + * + * @return int + */ + public function get123Number() + { + return $this->container['_123_number']; + } + + /** + * Sets _123_number + * + * @param int $_123_number _123_number + * + * @return $this + */ + public function set123Number($_123_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php new file mode 100644 index 00000000000..c88ef7f338c --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php @@ -0,0 +1,301 @@ + 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'just_number' => null + ]; + + /** + * 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 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->container['just_number'] = isset($data['just_number']) ? $data['just_number'] : null; + } + + /** + * 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 + */ + public function getJustNumber() + { + return $this->container['just_number']; + } + + /** + * Sets just_number + * + * @param float $just_number just_number + * + * @return $this + */ + public function setJustNumber($just_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php new file mode 100644 index 00000000000..2551c35f8b4 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php @@ -0,0 +1,485 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'pet_id' => 'int64', + 'quantity' => 'int32', + 'ship_date' => 'date-time', + 'status' => null, + 'complete' => null + ]; + + /** + * 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 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; + } + + const STATUS_PLACED = 'placed'; + const STATUS_APPROVED = 'approved'; + 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['pet_id'] = isset($data['pet_id']) ? $data['pet_id'] : null; + $this->container['quantity'] = isset($data['quantity']) ? $data['quantity'] : null; + $this->container['ship_date'] = isset($data['ship_date']) ? $data['ship_date'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['complete'] = isset($data['complete']) ? $data['complete'] : false; + } + + /** + * 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 for 'status', must be one of '%s'", + 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets pet_id + * + * @return int + */ + public function getPetId() + { + return $this->container['pet_id']; + } + + /** + * Sets pet_id + * + * @param int $pet_id pet_id + * + * @return $this + */ + public function setPetId($pet_id) + { + $this->container['pet_id'] = $pet_id; + + return $this; + } + + /** + * Gets quantity + * + * @return int + */ + public function getQuantity() + { + return $this->container['quantity']; + } + + /** + * Sets quantity + * + * @param int $quantity quantity + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->container['quantity'] = $quantity; + + return $this; + } + + /** + * Gets ship_date + * + * @return \DateTime + */ + public function getShipDate() + { + return $this->container['ship_date']; + } + + /** + * Sets ship_date + * + * @param \DateTime $ship_date ship_date + * + * @return $this + */ + public function setShipDate($ship_date) + { + $this->container['ship_date'] = $ship_date; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status Order Status + * + * @return $this + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets complete + * + * @return bool + */ + public function getComplete() + { + return $this->container['complete']; + } + + /** + * Sets complete + * + * @param bool $complete complete + * + * @return $this + */ + public function setComplete($complete) + { + $this->container['complete'] = $complete; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php new file mode 100644 index 00000000000..17093d35f68 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php @@ -0,0 +1,361 @@ + 'float', + 'my_string' => 'string', + 'my_boolean' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'my_number' => null, + 'my_string' => null, + 'my_boolean' => null + ]; + + /** + * 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 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->container['my_number'] = isset($data['my_number']) ? $data['my_number'] : null; + $this->container['my_string'] = isset($data['my_string']) ? $data['my_string'] : null; + $this->container['my_boolean'] = isset($data['my_boolean']) ? $data['my_boolean'] : null; + } + + /** + * 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 + */ + public function getMyNumber() + { + return $this->container['my_number']; + } + + /** + * Sets my_number + * + * @param float $my_number my_number + * + * @return $this + */ + public function setMyNumber($my_number) + { + $this->container['my_number'] = $my_number; + + return $this; + } + + /** + * Gets my_string + * + * @return string + */ + public function getMyString() + { + return $this->container['my_string']; + } + + /** + * Sets my_string + * + * @param string $my_string my_string + * + * @return $this + */ + public function setMyString($my_string) + { + $this->container['my_string'] = $my_string; + + return $this; + } + + /** + * Gets my_boolean + * + * @return bool + */ + public function getMyBoolean() + { + return $this->container['my_boolean']; + } + + /** + * Sets my_boolean + * + * @param bool $my_boolean my_boolean + * + * @return $this + */ + public function setMyBoolean($my_boolean) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php new file mode 100644 index 00000000000..afcef74733e --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php @@ -0,0 +1,64 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'category' => null, + 'name' => null, + 'photo_urls' => null, + 'tags' => null, + 'status' => null + ]; + + /** + * 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 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; + } + + const STATUS_AVAILABLE = 'available'; + const STATUS_PENDING = 'pending'; + 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['category'] = isset($data['category']) ? $data['category'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['photo_urls'] = isset($data['photo_urls']) ? $data['photo_urls'] : null; + $this->container['tags'] = isset($data['tags']) ? $data['tags'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + } + + /** + * 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 for 'status', must be one of '%s'", + 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets category + * + * @return \OpenAPI\Client\Model\Category + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param \OpenAPI\Client\Model\Category $category category + * + * @return $this + */ + public function setCategory($category) + { + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $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 $this + */ + public function setPhotoUrls($photo_urls) + { + $this->container['photo_urls'] = $photo_urls; + + return $this; + } + + /** + * Gets tags + * + * @return \OpenAPI\Client\Model\Tag[] + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param \OpenAPI\Client\Model\Tag[] $tags tags + * + * @return $this + */ + public function setTags($tags) + { + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status pet status in the store + * + * @return $this + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + 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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php new file mode 100644 index 00000000000..792262e0a07 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php @@ -0,0 +1,331 @@ + 'string', + 'baz' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'bar' => null, + 'baz' => null + ]; + + /** + * 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 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->container['bar'] = isset($data['bar']) ? $data['bar'] : null; + $this->container['baz'] = isset($data['baz']) ? $data['baz'] : null; + } + + /** + * 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 + */ + public function getBar() + { + return $this->container['bar']; + } + + /** + * Sets bar + * + * @param string $bar bar + * + * @return $this + */ + public function setBar($bar) + { + $this->container['bar'] = $bar; + + return $this; + } + + /** + * Gets baz + * + * @return string + */ + public function getBaz() + { + return $this->container['baz']; + } + + /** + * Sets baz + * + * @param string $baz baz + * + * @return $this + */ + public function setBaz($baz) + { + $this->container['baz'] = $baz; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php new file mode 100644 index 00000000000..1e35ffd6a32 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php @@ -0,0 +1,301 @@ + 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'special_property_name' => 'int64' + ]; + + /** + * 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 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->container['special_property_name'] = isset($data['special_property_name']) ? $data['special_property_name'] : null; + } + + /** + * 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 + */ + public function getSpecialPropertyName() + { + return $this->container['special_property_name']; + } + + /** + * Sets special_property_name + * + * @param int $special_property_name special_property_name + * + * @return $this + */ + public function setSpecialPropertyName($special_property_name) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php new file mode 100644 index 00000000000..d2527268cdb --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php @@ -0,0 +1,331 @@ + 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php new file mode 100644 index 00000000000..a63067f4d02 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/User.php @@ -0,0 +1,511 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'username' => null, + 'first_name' => null, + 'last_name' => null, + 'email' => null, + 'password' => null, + 'phone' => null, + 'user_status' => 'int32' + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['username'] = isset($data['username']) ? $data['username'] : null; + $this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null; + $this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null; + $this->container['email'] = isset($data['email']) ? $data['email'] : null; + $this->container['password'] = isset($data['password']) ? $data['password'] : null; + $this->container['phone'] = isset($data['phone']) ? $data['phone'] : null; + $this->container['user_status'] = isset($data['user_status']) ? $data['user_status'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets username + * + * @return string + */ + public function getUsername() + { + return $this->container['username']; + } + + /** + * Sets username + * + * @param string $username username + * + * @return $this + */ + public function setUsername($username) + { + $this->container['username'] = $username; + + return $this; + } + + /** + * Gets first_name + * + * @return string + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string $first_name first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string $last_name last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email + * + * @return string + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string $email email + * + * @return $this + */ + public function setEmail($email) + { + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets password + * + * @return string + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string $password password + * + * @return $this + */ + public function setPassword($password) + { + $this->container['password'] = $password; + + return $this; + } + + /** + * Gets phone + * + * @return string + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string $phone phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->container['phone'] = $phone; + + return $this; + } + + /** + * Gets user_status + * + * @return int + */ + public function getUserStatus() + { + return $this->container['user_status']; + } + + /** + * Sets user_status + * + * @param int $user_status User Status + * + * @return $this + */ + public function setUserStatus($user_status) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php new file mode 100644 index 00000000000..25262d1d07f --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -0,0 +1,317 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($openAPIType, 'getAllowableEnumValues') + && !in_array($value, $openAPIType::getAllowableEnumValues())) { + $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } + } + 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; + } + } + + /** + * 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)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * + * @return string the serialized object + */ + public static function toQueryValue($object) + { + if (is_array($object)) { + return implode(',', $object); + } else { + return self::toString($object); + } + } + + /** + * 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) + { + 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 + * + * @param string|\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(\DateTime::ATOM); + } else { + return $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $collectionFormat 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, $collectionFormat, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { + // 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 ($collectionFormat) { + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'ssv': + return implode(' ', $collection); + + 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 + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null an single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $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; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's 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)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (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'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues())) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + // 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; + } + } + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +} diff --git a/samples/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist b/samples/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist new file mode 100644 index 00000000000..c12ee148477 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./test/Api + ./test/Model + + + + + + ./lib/Api + ./lib/Model + + + diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php similarity index 87% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php index 2fb493e741f..751ae065157 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * AnotherFakeApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php index 57bdc901258..d19dfa25e43 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * FakeApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php similarity index 87% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php index 3d39e6d42f9..3b055d126dc 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * FakeClassnameTags123ApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php similarity index 91% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php index f4ce9e18e45..e3ff5eb1047 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * PetApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php similarity index 89% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php index 20e6e2bbb55..b01601ddaf7 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * StoreApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php similarity index 92% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php index 7d1f2031be2..abcb622dabe 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * UserApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php index 954b1ef159f..84c4cd39362 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AdditionalPropertiesClassTest Class Doc Comment * * @category Class * @description AdditionalPropertiesClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php index 9df0d2347c4..adc12bb876f 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AnimalFarmTest Class Doc Comment * * @category Class * @description AnimalFarm - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php index 166bf161ce3..7056d16b0cf 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AnimalTest Class Doc Comment * * @category Class * @description Animal - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php index d0f02fcea88..0c00ef8cb47 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ApiResponseTest Class Doc Comment * * @category Class * @description ApiResponse - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php index 86001b65197..5a5147cffa1 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayOfArrayOfNumberOnlyTest Class Doc Comment * * @category Class * @description ArrayOfArrayOfNumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php index 4e02d0525fc..a53cb832bca 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayOfNumberOnlyTest Class Doc Comment * * @category Class * @description ArrayOfNumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php index 737e4c9874f..fa2f37a58fa 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayTestTest Class Doc Comment * * @category Class * @description ArrayTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php index 96698110920..f7acf13d262 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CapitalizationTest Class Doc Comment * * @category Class * @description Capitalization - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php index 5db87d38e66..5cc579ed177 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CatTest Class Doc Comment * * @category Class * @description Cat - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php index bd41a94f3b9..8dd7c9200c7 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CategoryTest Class Doc Comment * * @category Class * @description Category - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php index e0560988f7b..5d9a0f9014e 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ClassModelTest Class Doc Comment * * @category Class * @description Model for testing model with \"_class\" property - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php index 3567c068a45..b9d9b8c5260 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ClientTest Class Doc Comment * * @category Class * @description Client - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php index 4075a3b85bd..99256d561ff 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * DogTest Class Doc Comment * * @category Class * @description Dog - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php index d3b933748cd..a01055a8cec 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumArraysTest Class Doc Comment * * @category Class * @description EnumArrays - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php index 36175d90760..7f7cd925493 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumClassTest Class Doc Comment * * @category Class * @description EnumClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php index 28dfd5af5be..1e5770584cf 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumTestTest Class Doc Comment * * @category Class * @description EnumTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php similarity index 96% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php index 40581f4dc58..269bbfa9983 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * FormatTestTest Class Doc Comment * * @category Class * @description FormatTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php index 712ac2f1fb0..ee9f4c59594 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * HasOnlyReadOnlyTest Class Doc Comment * * @category Class * @description HasOnlyReadOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php index 5d7e83b8617..fb850048e9c 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * MapTestTest Class Doc Comment * * @category Class * @description MapTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php index 2f9b49dd212..2d1e95c5032 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * MixedPropertiesAndAdditionalPropertiesClassTest Class Doc Comment * * @category Class * @description MixedPropertiesAndAdditionalPropertiesClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php index df20e34bb3f..a963bcae3be 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * Model200ResponseTest Class Doc Comment * * @category Class * @description Model for testing model name starting with number - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php index 492bec1a03b..d24dc028525 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ModelListTest Class Doc Comment * * @category Class * @description ModelList - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php index 3a743e83cbe..ad55c38b56d 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ModelReturnTest Class Doc Comment * * @category Class * @description Model for testing reserved words - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php index 040dddabd1a..fef59be669a 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * NameTest Class Doc Comment * * @category Class * @description Model for testing model name same as property name - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php index a06ccb1e84c..3ec1911c053 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * NumberOnlyTest Class Doc Comment * * @category Class * @description NumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php index 3d5cafb7d15..56e3f10930e 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OrderTest Class Doc Comment * * @category Class * @description Order - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php index 771a03c8c85..f8cc46983b3 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OuterCompositeTest Class Doc Comment * * @category Class * @description OuterComposite - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php index 83b56d68154..db909de55fe 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OuterEnumTest Class Doc Comment * * @category Class * @description OuterEnum - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php index 4eb71836195..7d33e91cdf9 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * PetTest Class Doc Comment * * @category Class * @description Pet - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php index 022a7d746e0..afad4d62ad0 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ReadOnlyFirstTest Class Doc Comment * * @category Class * @description ReadOnlyFirst - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php index ef19680ba36..713d2acd05f 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * SpecialModelNameTest Class Doc Comment * * @category Class * @description SpecialModelName - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php index f8c2bc2ce30..e37e3aabec4 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * TagTest Class Doc Comment * * @category Class * @description Tag - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php b/samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php rename to samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php index d22b6f3e957..20adea143e1 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * UserTest Class Doc Comment * * @category Class * @description User - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/AsyncTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/AsyncTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php index 9f71e55c024..0ac3ad36ada 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/AsyncTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php @@ -1,9 +1,9 @@ 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/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumClassTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/EnumClassTest.php similarity index 79% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumClassTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/EnumClassTest.php index fe1b514e7f6..751b214c4ed 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumClassTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/EnumClassTest.php @@ -1,8 +1,8 @@ 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 for 'enum_string', must be one of 'UPPER', 'lower', ''", + "'enum_string_required' can't be null", + ]; + $this->assertSame($expected, $enum->listInvalidProperties()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testThrowExceptionWhenInvalidAmbiguousValueHasPassed() + { + $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/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ExceptionTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/ExceptionTest.php similarity index 84% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ExceptionTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/ExceptionTest.php index 86b09de4240..317b3793600 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ExceptionTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/ExceptionTest.php @@ -1,13 +1,13 @@ $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/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/HeaderSelectorTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php similarity index 98% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/HeaderSelectorTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php index afe9fbf2129..89ee7a8df15 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/HeaderSelectorTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php @@ -1,6 +1,6 @@ assertContains($animal->getClassName(), ['Dog', 'Cat', 'Animal']); - $this->assertInstanceOf('OpenAPITools\Client\Model\Animal', $animal); + $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $animal); } } } diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ObjectSerializerTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php similarity index 96% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ObjectSerializerTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php index b405233a83e..c65dbdc3e38 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/ObjectSerializerTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php @@ -1,6 +1,6 @@ assertInstanceOf('OpenAPITools\Client\Model\Order', $order); + $this->assertInstanceOf('OpenAPI\Client\Model\Order', $order); $this->assertSame(10, $order->getId()); $this->assertSame(20, $order->getPetId()); $this->assertSame(30, $order->getQuantity()); @@ -82,13 +82,13 @@ ORDER; ORDER; $order = ObjectSerializer::deserialize( json_decode($order_json), - 'OpenAPITools\Client\Model\Order[][]' + 'OpenAPI\Client\Model\Order[][]' ); $this->assertArrayHasKey(0, $order); $this->assertArrayHasKey(0, $order[0]); $_order = $order[0][0]; - $this->assertInstanceOf('OpenAPITools\Client\Model\Order', $_order); + $this->assertInstanceOf('OpenAPI\Client\Model\Order', $_order); $this->assertSame(10, $_order->getId()); $this->assertSame(20, $_order->getPetId()); $this->assertSame(30, $_order->getQuantity()); @@ -116,13 +116,13 @@ ORDER; ORDER; $order = ObjectSerializer::deserialize( json_decode($order_json), - 'map[string,map[string,\OpenAPITools\Client\Model\Order]]' + 'map[string,map[string,\OpenAPI\Client\Model\Order]]' ); $this->assertArrayHasKey('test', $order); $this->assertArrayHasKey('test2', $order['test']); $_order = $order['test']['test2']; - $this->assertInstanceOf('OpenAPITools\Client\Model\Order', $_order); + $this->assertInstanceOf('OpenAPI\Client\Model\Order', $_order); $this->assertSame(10, $_order->getId()); $this->assertSame(20, $_order->getPetId()); $this->assertSame(30, $_order->getQuantity()); diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/OuterEnumTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/OuterEnumTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php index 2bfd5ea4ad3..862832ca0a8 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/OuterEnumTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php @@ -1,9 +1,9 @@ getApiClient()->getConfig()->setApiKey('api_key', '111222333444555'); * // return Pet (inline model) * $response = $pet_api->getPetByIdInObject($pet_id); - * $this->assertInstanceOf('OpenAPITools\Client\Model\InlineResponse200', $response); + * $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'); @@ -289,9 +289,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase { $new_dog = new Model\Dog; // the object should be an instance of the derived class - $this->assertInstanceOf('OpenAPITools\Client\Model\Dog', $new_dog); + $this->assertInstanceOf('OpenAPI\Client\Model\Dog', $new_dog); // the object should also be an instance of the parent class - $this->assertInstanceOf('OpenAPITools\Client\Model\Animal', $new_dog); + $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $new_dog); } // test inheritance constructor is working with data @@ -333,15 +333,15 @@ class PetApiTest extends \PHPUnit_Framework_TestCase // assert we can look up the animals in the farm by array // indices (let's try a random order) - $this->assertInstanceOf('OpenAPITools\Client\Model\Cat', $farm[1]); - $this->assertInstanceOf('OpenAPITools\Client\Model\Dog', $farm[0]); - $this->assertInstanceOf('OpenAPITools\Client\Model\Animal', $farm[2]); + $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('OpenAPITools\Client\Model\Animal', $animal); + $this->assertInstanceOf('OpenAPI\Client\Model\Animal', $animal); } } diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/PetTest.php b/samples/client/petstore/php/OpenAPIClient-php/tests/PetTest.php similarity index 82% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/PetTest.php rename to samples/client/petstore/php/OpenAPIClient-php/tests/PetTest.php index 04dff16bf37..5e4a3f2a195 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/PetTest.php +++ b/samples/client/petstore/php/OpenAPIClient-php/tests/PetTest.php @@ -1,8 +1,8 @@ level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->setUsingCache(true) + ->fixers( + [ + 'ordered_use', + 'phpdoc_order', + 'short_array_syntax', + 'strict', + 'strict_param' + ] + ) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->in(__DIR__) + ); diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/.travis.yml b/samples/openapi3/client/petstore/php/OpenAPIClient-php/.travis.yml new file mode 100644 index 00000000000..d77f3825f6f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/.travis.yml @@ -0,0 +1,10 @@ +language: php +sudo: false +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm +before_install: "composer install" +script: "vendor/bin/phpunit" diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md new file mode 100644 index 00000000000..04e36d807a2 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md @@ -0,0 +1,185 @@ +# OpenAPIClient-php +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PhpClientCodegen + +## Requirements + +PHP 5.5 and later + +## Installation & Usage +### Composer + +To install the bindings via [Composer](http://getcomposer.org/), add the following to `composer.json`: + +``` +{ + "repositories": [ + { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + } + ], + "require": { + "GIT_USER_ID/GIT_REPO_ID": "*@dev" + } +} +``` + +Then run `composer install` + +### Manual Installation + +Download the files and include `autoload.php`: + +```php + require_once('/path/to/OpenAPIClient-php/vendor/autoload.php'); +``` + +## Tests + +To run the unit tests: + +``` +composer install +./vendor/bin/phpunit +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```php +testSpecialTags($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; +} + +?> +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags +*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | +*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model +*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case +*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/Api/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/Api/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/Api/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/Api/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/Api/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/Api/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/Api/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/Api/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md) + - [Animal](docs/Model/Animal.md) + - [AnimalFarm](docs/Model/AnimalFarm.md) + - [ApiResponse](docs/Model/ApiResponse.md) + - [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md) + - [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md) + - [ArrayTest](docs/Model/ArrayTest.md) + - [Capitalization](docs/Model/Capitalization.md) + - [Cat](docs/Model/Cat.md) + - [Category](docs/Model/Category.md) + - [ClassModel](docs/Model/ClassModel.md) + - [Client](docs/Model/Client.md) + - [Dog](docs/Model/Dog.md) + - [EnumArrays](docs/Model/EnumArrays.md) + - [EnumClass](docs/Model/EnumClass.md) + - [EnumTest](docs/Model/EnumTest.md) + - [FormatTest](docs/Model/FormatTest.md) + - [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md) + - [MapTest](docs/Model/MapTest.md) + - [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model200Response](docs/Model/Model200Response.md) + - [ModelList](docs/Model/ModelList.md) + - [ModelReturn](docs/Model/ModelReturn.md) + - [Name](docs/Model/Name.md) + - [NumberOnly](docs/Model/NumberOnly.md) + - [Order](docs/Model/Order.md) + - [OuterComposite](docs/Model/OuterComposite.md) + - [OuterEnum](docs/Model/OuterEnum.md) + - [Pet](docs/Model/Pet.md) + - [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md) + - [SpecialModelName](docs/Model/SpecialModelName.md) + - [Tag](docs/Model/Tag.md) + - [User](docs/Model/User.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + +## http_basic_test + +- **Type**: HTTP basic authentication + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + + + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json b/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json new file mode 100644 index 00000000000..65d3c935fb8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json @@ -0,0 +1,38 @@ +{ + "name": "GIT_USER_ID/GIT_REPO_ID", + "description": "", + "keywords": [ + "openapitools", + "openapi-generator", + "php", + "sdk", + "rest", + "api" + ], + "homepage": "http://openapi-generator.tech", + "license": "proprietary", + "authors": [ + { + "name": "OpenAPI-Generator contributors", + "homepage": "https://openapi-generator.tech" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "guzzlehttp/guzzle": "^6.2" + }, + "require-dev": { + "phpunit/phpunit": "^4.8", + "squizlabs/php_codesniffer": "~2.6", + "friendsofphp/php-cs-fixer": "~1.12" + }, + "autoload": { + "psr-4": { "OpenAPI\\Client\\" : "lib/" } + }, + "autoload-dev": { + "psr-4": { "OpenAPI\\Client\\" : "test/" } + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md new file mode 100644 index 00000000000..9e4f59fce29 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md @@ -0,0 +1,58 @@ +# OpenAPI\Client\AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testSpecialTags**](AnotherFakeApi.md#testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags + + +# **testSpecialTags** +> \OpenAPI\Client\Model\Client testSpecialTags($client) + +To test special tags + +To test special tags + +### Example +```php +testSpecialTags($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md new file mode 100644 index 00000000000..ee9253a4eef --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -0,0 +1,499 @@ +# OpenAPI\Client\FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | +[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model +[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data + + +# **fakeOuterBooleanSerialize** +> bool fakeOuterBooleanSerialize($body) + + + +Test serialization of outer boolean types + +### Example +```php +fakeOuterBooleanSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **bool**| Input boolean as post body | [optional] + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterCompositeSerialize** +> \OpenAPI\Client\Model\OuterComposite fakeOuterCompositeSerialize($outer_composite) + + + +Test serialization of object with outer number type + +### Example +```php +fakeOuterCompositeSerialize($outer_composite); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterCompositeSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outer_composite** | [**\OpenAPI\Client\Model\OuterComposite**](../Model/OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**\OpenAPI\Client\Model\OuterComposite**](../Model/OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterNumberSerialize** +> float fakeOuterNumberSerialize($body) + + + +Test serialization of outer number types + +### Example +```php +fakeOuterNumberSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterNumberSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **float**| Input number as post body | [optional] + +### Return type + +**float** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **fakeOuterStringSerialize** +> string fakeOuterStringSerialize($body) + + + +Test serialization of outer string types + +### Example +```php +fakeOuterStringSerialize($body); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->fakeOuterStringSerialize: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **string**| Input string as post body | [optional] + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testClientModel** +> \OpenAPI\Client\Model\Client testClientModel($client) + +To test \"client\" model + +To test \"client\" model + +### Example +```php +testClientModel($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testClientModel: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testEndpointParameters** +> testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```php +setUsername('YOUR_USERNAME') + ->setPassword('YOUR_PASSWORD'); + + +$apiInstance = new OpenAPI\Client\Api\FakeApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$number = 3.4; // float | None +$double = 3.4; // double | None +$pattern_without_delimiter = 'pattern_without_delimiter_example'; // string | None +$byte = 'byte_example'; // string | None +$integer = 56; // int | None +$int32 = 56; // int | None +$int64 = 56; // int | None +$float = 3.4; // float | None +$string = 'string_example'; // string | None +$binary = "/path/to/file.txt"; // \SplFileObject | None +$date = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | None +$date_time = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | None +$password = 'password_example'; // string | None +$callback = 'callback_example'; // string | None + +try { + $apiInstance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **float**| None | + **double** | **double**| None | + **pattern_without_delimiter** | **string**| None | + **byte** | **string**| None | + **integer** | **int**| None | [optional] + **int32** | **int**| None | [optional] + **int64** | **int**| None | [optional] + **float** | **float**| None | [optional] + **string** | **string**| None | [optional] + **binary** | **\SplFileObject****\SplFileObject**| None | [optional] + **date** | **\DateTime**| None | [optional] + **date_time** | **\DateTime**| None | [optional] + **password** | **string**| None | [optional] + **callback** | **string**| None | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[http_basic_test](../../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testEnumParameters** +> testEnumParameters($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string) + +To test enum parameters + +To test enum parameters + +### Example +```php +testEnumParameters($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testEnumParameters: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_header_string_array** | [**string[]**](../Model/string.md)| Header parameter enum test (string array) | [optional] + **enum_header_string** | **string**| Header parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_string_array** | [**string[]**](../Model/string.md)| Query parameter enum test (string array) | [optional] + **enum_query_string** | **string**| Query parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] + **enum_query_double** | **double**| Query parameter enum test (double) | [optional] + **enum_form_string_array** | **string[]**| Form parameter enum test (string array) | [optional] [default to '$'] + **enum_form_string** | **string**| Form parameter enum test (string) | [optional] [default to '-efg'] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testInlineAdditionalProperties** +> testInlineAdditionalProperties($request_body) + +test inline additionalProperties + +### Example +```php + 'request_body_example'); // map[string,string] | request body + +try { + $apiInstance->testInlineAdditionalProperties($request_body); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testInlineAdditionalProperties: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **request_body** | [**map[string,string]**](../Model/string.md)| request body | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **testJsonFormData** +> testJsonFormData($param, $param2) + +test json serialization of form data + +### Example +```php +testJsonFormData($param, $param2); +} catch (Exception $e) { + echo 'Exception when calling FakeApi->testJsonFormData: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **string**| field1 | + **param2** | **string**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md new file mode 100644 index 00000000000..b4c7dcfff38 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/FakeClassnameTags123Api.md @@ -0,0 +1,64 @@ +# OpenAPI\Client\FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **testClassname** +> \OpenAPI\Client\Model\Client testClassname($client) + +To test class name in snake case + +To test class name in snake case + +### Example +```php +setApiKey('api_key_query', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\FakeClassnameTags123Api( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model + +try { + $result = $apiInstance->testClassname($client); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model | + +### Return type + +[**\OpenAPI\Client\Model\Client**](../Model/Client.md) + +### Authorization + +[api_key_query](../../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md new file mode 100644 index 00000000000..8af99174535 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/PetApi.md @@ -0,0 +1,438 @@ +# OpenAPI\Client\PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +> addPet($pet) + +Add a new pet to the store + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store + +try { + $apiInstance->addPet($pet); +} catch (Exception $e) { + echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deletePet** +> deletePet($pet_id, $api_key) + +Deletes a pet + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | Pet id to delete +$api_key = 'api_key_example'; // string | + +try { + $apiInstance->deletePet($pet_id, $api_key); +} catch (Exception $e) { + echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **string**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **findPetsByStatus** +> \OpenAPI\Client\Model\Pet[] findPetsByStatus($status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$status = array('status_example'); // string[] | Status values that need to be considered for filter + +try { + $result = $apiInstance->findPetsByStatus($status); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**string[]**](../Model/string.md)| Status values that need to be considered for filter | + +### Return type + +[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **findPetsByTags** +> \OpenAPI\Client\Model\Pet[] findPetsByTags($tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$tags = array('tags_example'); // string[] | Tags to filter by + +try { + $result = $apiInstance->findPetsByTags($tags); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**string[]**](../Model/string.md)| Tags to filter by | + +### Return type + +[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getPetById** +> \OpenAPI\Client\Model\Pet getPetById($pet_id) + +Find pet by ID + +Returns a single pet + +### Example +```php +setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to return + +try { + $result = $apiInstance->getPetById($pet_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to return | + +### Return type + +[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md) + +### Authorization + +[api_key](../../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updatePet** +> updatePet($pet) + +Update an existing pet + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store + +try { + $apiInstance->updatePet($pet); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updatePetWithForm** +> updatePetWithForm($pet_id, $name, $status) + +Updates a pet in the store with form data + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet that needs to be updated +$name = 'name_example'; // string | Updated name of the pet +$status = 'status_example'; // string | Updated status of the pet + +try { + $apiInstance->updatePetWithForm($pet_id, $name, $status); +} catch (Exception $e) { + echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be updated | + **name** | **string**| Updated name of the pet | [optional] + **status** | **string**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **uploadFile** +> \OpenAPI\Client\Model\ApiResponse uploadFile($pet_id, $additional_metadata, $file) + +uploads an image + +### Example +```php +setAccessToken('YOUR_ACCESS_TOKEN'); + +$apiInstance = new OpenAPI\Client\Api\PetApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$pet_id = 56; // int | ID of pet to update +$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server +$file = "/path/to/file.txt"; // \SplFileObject | file to upload + +try { + $result = $apiInstance->uploadFile($pet_id, $additional_metadata, $file); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **string**| Additional data to pass to server | [optional] + **file** | **\SplFileObject****\SplFileObject**| file to upload | [optional] + +### Return type + +[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md) + +### Authorization + +[petstore_auth](../../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md new file mode 100644 index 00000000000..c607217ea44 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/StoreApi.md @@ -0,0 +1,207 @@ +# OpenAPI\Client\StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +> deleteOrder($order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```php +deleteOrder($order_id); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **string**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getInventory** +> map[string,int] getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```php +setApiKey('api_key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer'); + +$apiInstance = new OpenAPI\Client\Api\StoreApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); + +try { + $result = $apiInstance->getInventory(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**map[string,int]** + +### Authorization + +[api_key](../../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getOrderById** +> \OpenAPI\Client\Model\Order getOrderById($order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```php +getOrderById($order_id); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**\OpenAPI\Client\Model\Order**](../Model/Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **placeOrder** +> \OpenAPI\Client\Model\Order placeOrder($order) + +Place an order for a pet + +### Example +```php +placeOrder($order); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**\OpenAPI\Client\Model\Order**](../Model/Order.md)| order placed for purchasing the pet | + +### Return type + +[**\OpenAPI\Client\Model\Order**](../Model/Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md new file mode 100644 index 00000000000..f57c5028497 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/UserApi.md @@ -0,0 +1,392 @@ +# OpenAPI\Client\UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# **createUser** +> createUser($user) + +Create user + +This can only be done by the logged in user. + +### Example +```php +createUser($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createUsersWithArrayInput** +> createUsersWithArrayInput($user) + +Creates list of users with given input array + +### Example +```php +createUsersWithArrayInput($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User[]**](../Model/array.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **createUsersWithListInput** +> createUsersWithListInput($user) + +Creates list of users with given input array + +### Example +```php +createUsersWithListInput($user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**\OpenAPI\Client\Model\User[]**](../Model/array.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **deleteUser** +> deleteUser($username) + +Delete user + +This can only be done by the logged in user. + +### Example +```php +deleteUser($username); +} catch (Exception $e) { + echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **getUserByName** +> \OpenAPI\Client\Model\User getUserByName($username) + +Get user by user name + +### Example +```php +getUserByName($username); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**\OpenAPI\Client\Model\User**](../Model/User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **loginUser** +> string loginUser($username, $password) + +Logs user into the system + +### Example +```php +loginUser($username, $password); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| The user name for login | + **password** | **string**| The password for login in clear text | + +### Return type + +**string** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + +### Example +```php +logoutUser(); +} catch (Exception $e) { + echo 'Exception when calling UserApi->logoutUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **updateUser** +> updateUser($username, $user) + +Updated user + +This can only be done by the logged in user. + +### Example +```php +updateUser($username, $user); +} catch (Exception $e) { + echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **string**| name that need to be deleted | + **user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md new file mode 100644 index 00000000000..b162fe9595f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md @@ -0,0 +1,11 @@ +# AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_property** | **map[string,string]** | | [optional] +**map_of_map_property** | [**map[string,map[string,string]]**](map.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md new file mode 100644 index 00000000000..c57fbe8ea4a --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Animal.md @@ -0,0 +1,11 @@ +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **string** | | +**color** | **string** | | [optional] [default to 'red'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md new file mode 100644 index 00000000000..df6bab21dae --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/AnimalFarm.md @@ -0,0 +1,9 @@ +# AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md new file mode 100644 index 00000000000..9d351183422 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ApiResponse.md @@ -0,0 +1,12 @@ +# ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] +**type** | **string** | | [optional] +**message** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 00000000000..7831e189888 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# ArrayOfArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_array_number** | [**float[][]**](array.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md new file mode 100644 index 00000000000..a32607e4201 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfNumberOnly.md @@ -0,0 +1,10 @@ +# ArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_number** | **float[]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md new file mode 100644 index 00000000000..2ef4e3785e4 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md @@ -0,0 +1,12 @@ +# ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_string** | **string[]** | | [optional] +**array_array_of_integer** | [**int[][]**](array.md) | | [optional] +**array_array_of_model** | [**\OpenAPI\Client\Model\ReadOnlyFirst[][]**](array.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md new file mode 100644 index 00000000000..0fcc9e873d7 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Capitalization.md @@ -0,0 +1,15 @@ +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **string** | | [optional] +**capital_camel** | **string** | | [optional] +**small_snake** | **string** | | [optional] +**capital_snake** | **string** | | [optional] +**sca_eth_flow_points** | **string** | | [optional] +**att_name** | **string** | Name of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md new file mode 100644 index 00000000000..8d30565d014 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Cat.md @@ -0,0 +1,10 @@ +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md new file mode 100644 index 00000000000..80aef312e5e --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Category.md @@ -0,0 +1,11 @@ +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md new file mode 100644 index 00000000000..3ad025b6ed3 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ClassModel.md @@ -0,0 +1,10 @@ +# ClassModel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md new file mode 100644 index 00000000000..f6047a62471 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Client.md @@ -0,0 +1,10 @@ +# Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md new file mode 100644 index 00000000000..3c04bdf4cf7 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Dog.md @@ -0,0 +1,10 @@ +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**breed** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md new file mode 100644 index 00000000000..ebaedecdae0 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumArrays.md @@ -0,0 +1,11 @@ +# EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **string** | | [optional] +**array_enum** | **string[]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md new file mode 100644 index 00000000000..67f017becd0 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumClass.md @@ -0,0 +1,9 @@ +# EnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md new file mode 100644 index 00000000000..9aca24e644e --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/EnumTest.md @@ -0,0 +1,14 @@ +# EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string** | **string** | | [optional] +**enum_string_required** | **string** | | +**enum_integer** | **int** | | [optional] +**enum_number** | **double** | | [optional] +**outer_enum** | [**\OpenAPI\Client\Model\OuterEnum**](OuterEnum.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md new file mode 100644 index 00000000000..e106ff1eba2 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/FormatTest.md @@ -0,0 +1,22 @@ +# FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **int** | | [optional] +**int32** | **int** | | [optional] +**int64** | **int** | | [optional] +**number** | **float** | | +**float** | **float** | | [optional] +**double** | **double** | | [optional] +**string** | **string** | | [optional] +**byte** | **string** | | +**binary** | [**\SplFileObject**](\SplFileObject.md) | | [optional] +**date** | [**\DateTime**](\DateTime.md) | | +**date_time** | [**\DateTime**](\DateTime.md) | | [optional] +**uuid** | **string** | | [optional] +**password** | **string** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md new file mode 100644 index 00000000000..5e64572b781 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/HasOnlyReadOnly.md @@ -0,0 +1,11 @@ +# HasOnlyReadOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **string** | | [optional] +**foo** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md new file mode 100644 index 00000000000..e2781ccc398 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md @@ -0,0 +1,11 @@ +# MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_map_of_string** | [**map[string,map[string,string]]**](map.md) | | [optional] +**map_of_enum_string** | **map[string,string]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 00000000000..a34e2f6d129 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,12 @@ +# MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **string** | | [optional] +**date_time** | [**\DateTime**](\DateTime.md) | | [optional] +**map** | [**map[string,\OpenAPI\Client\Model\Animal]**](Animal.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md new file mode 100644 index 00000000000..ebbea5c68af --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Model200Response.md @@ -0,0 +1,11 @@ +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md new file mode 100644 index 00000000000..e18ba4e123d --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelList.md @@ -0,0 +1,10 @@ +# ModelList + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123_list** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md new file mode 100644 index 00000000000..9adb62e1e12 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ModelReturn.md @@ -0,0 +1,10 @@ +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**return** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md new file mode 100644 index 00000000000..4565647e1ef --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Name.md @@ -0,0 +1,13 @@ +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | +**snake_case** | **int** | | [optional] +**property** | **string** | | [optional] +**_123_number** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md new file mode 100644 index 00000000000..93a0fde7b93 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/NumberOnly.md @@ -0,0 +1,10 @@ +# NumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_number** | **float** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md new file mode 100644 index 00000000000..ddae5cc2b57 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Order.md @@ -0,0 +1,15 @@ +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | [**\DateTime**](\DateTime.md) | | [optional] +**status** | **string** | Order Status | [optional] +**complete** | **bool** | | [optional] [default to false] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md new file mode 100644 index 00000000000..e7967521395 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterComposite.md @@ -0,0 +1,12 @@ +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**my_number** | **float** | | [optional] +**my_string** | **string** | | [optional] +**my_boolean** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md new file mode 100644 index 00000000000..06d413b0168 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/OuterEnum.md @@ -0,0 +1,9 @@ +# OuterEnum + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md new file mode 100644 index 00000000000..2d281a3c499 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Pet.md @@ -0,0 +1,15 @@ +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**\OpenAPI\Client\Model\Category**](Category.md) | | [optional] +**name** | **string** | | +**photo_urls** | **string[]** | | +**tags** | [**\OpenAPI\Client\Model\Tag[]**](Tag.md) | | [optional] +**status** | **string** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md new file mode 100644 index 00000000000..90662a00cf3 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/ReadOnlyFirst.md @@ -0,0 +1,11 @@ +# ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **string** | | [optional] +**baz** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md new file mode 100644 index 00000000000..022ee19169c --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/SpecialModelName.md @@ -0,0 +1,10 @@ +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md new file mode 100644 index 00000000000..15ec3e0a91d --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Tag.md @@ -0,0 +1,11 @@ +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/User.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/User.md new file mode 100644 index 00000000000..ff278fd4889 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/User.md @@ -0,0 +1,17 @@ +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **string** | | [optional] +**first_name** | **string** | | [optional] +**last_name** | **string** | | [optional] +**email** | **string** | | [optional] +**password** | **string** | | [optional] +**phone** | **string** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/git_push.sh b/samples/openapi3/client/petstore/php/OpenAPIClient-php/git_push.sh new file mode 100644 index 00000000000..20057f67ade --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php new file mode 100644 index 00000000000..0d34e97176f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php @@ -0,0 +1,365 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation testSpecialTags + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testSpecialTags($client) + { + list($response) = $this->testSpecialTagsWithHttpInfo($client); + return $response; + } + + /** + * Operation testSpecialTagsWithHttpInfo + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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 testSpecialTagsWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testSpecialTagsRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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 testSpecialTagsAsync + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testSpecialTagsAsync($client) + { + return $this->testSpecialTagsAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testSpecialTagsAsyncWithHttpInfo + * + * To test special tags + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testSpecialTagsAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testSpecialTagsRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testSpecialTags' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testSpecialTagsRequest($client) + { + // 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 testSpecialTags' + ); + } + + $resourcePath = '/another-fake/dummy'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php new file mode 100644 index 00000000000..389356e2505 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -0,0 +1,2493 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation fakeOuterBooleanSerialize + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return bool + */ + public function fakeOuterBooleanSerialize($body = null) + { + list($response) = $this->fakeOuterBooleanSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterBooleanSerializeWithHttpInfo + * + * @param bool $body Input boolean as post body (optional) + * + * @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) + { + $returnType = 'bool'; + $request = $this->fakeOuterBooleanSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterBooleanSerializeAsync($body = null) + { + return $this->fakeOuterBooleanSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterBooleanSerializeAsyncWithHttpInfo + * + * + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterBooleanSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'bool'; + $request = $this->fakeOuterBooleanSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterBooleanSerialize' + * + * @param bool $body Input boolean as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterBooleanSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/boolean'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterCompositeSerialize + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\OuterComposite + */ + public function fakeOuterCompositeSerialize($outer_composite = null) + { + list($response) = $this->fakeOuterCompositeSerializeWithHttpInfo($outer_composite); + return $response; + } + + /** + * Operation fakeOuterCompositeSerializeWithHttpInfo + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\OuterComposite'; + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterCompositeSerializeAsync($outer_composite = null) + { + return $this->fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterCompositeSerializeAsyncWithHttpInfo + * + * + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterCompositeSerializeAsyncWithHttpInfo($outer_composite = null) + { + $returnType = '\OpenAPI\Client\Model\OuterComposite'; + $request = $this->fakeOuterCompositeSerializeRequest($outer_composite); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterCompositeSerialize' + * + * @param \OpenAPI\Client\Model\OuterComposite $outer_composite Input composite as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterCompositeSerializeRequest($outer_composite = null) + { + + $resourcePath = '/fake/outer/composite'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($outer_composite)) { + $_tempBody = $outer_composite; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterNumberSerialize + * + * @param float $body Input number as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return float + */ + public function fakeOuterNumberSerialize($body = null) + { + list($response) = $this->fakeOuterNumberSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterNumberSerializeWithHttpInfo + * + * @param float $body Input number as post body (optional) + * + * @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) + { + $returnType = 'float'; + $request = $this->fakeOuterNumberSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterNumberSerializeAsync($body = null) + { + return $this->fakeOuterNumberSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterNumberSerializeAsyncWithHttpInfo + * + * + * + * @param float $body Input number as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterNumberSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'float'; + $request = $this->fakeOuterNumberSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterNumberSerialize' + * + * @param float $body Input number as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterNumberSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/number'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation fakeOuterStringSerialize + * + * @param string $body Input string as post body (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return string + */ + public function fakeOuterStringSerialize($body = null) + { + list($response) = $this->fakeOuterStringSerializeWithHttpInfo($body); + return $response; + } + + /** + * Operation fakeOuterStringSerializeWithHttpInfo + * + * @param string $body Input string as post body (optional) + * + * @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) + { + $returnType = 'string'; + $request = $this->fakeOuterStringSerializeRequest($body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterStringSerializeAsync($body = null) + { + return $this->fakeOuterStringSerializeAsyncWithHttpInfo($body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation fakeOuterStringSerializeAsyncWithHttpInfo + * + * + * + * @param string $body Input string as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function fakeOuterStringSerializeAsyncWithHttpInfo($body = null) + { + $returnType = 'string'; + $request = $this->fakeOuterStringSerializeRequest($body); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'fakeOuterStringSerialize' + * + * @param string $body Input string as post body (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function fakeOuterStringSerializeRequest($body = null) + { + + $resourcePath = '/fake/outer/string'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($body)) { + $_tempBody = $body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['*/*'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['*/*'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testClientModel + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testClientModel($client) + { + list($response) = $this->testClientModelWithHttpInfo($client); + return $response; + } + + /** + * Operation testClientModelWithHttpInfo + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClientModelRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClientModelAsync($client) + { + return $this->testClientModelAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testClientModelAsyncWithHttpInfo + * + * To test \"client\" model + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClientModelAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClientModelRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testClientModel' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testClientModelRequest($client) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testEndpointParameters + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $this->testEndpointParametersWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + } + + /** + * Operation testEndpointParametersWithHttpInfo + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $returnType = ''; + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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 double $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) + * + * @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) + { + return $this->testEndpointParametersAsyncWithHttpInfo($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testEndpointParametersAsyncWithHttpInfo + * + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * + * @param float $number None (required) + * @param double $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) + * + * @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) + { + $returnType = ''; + $request = $this->testEndpointParametersRequest($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testEndpointParameters' + * + * @param float $number None (required) + * @param double $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected 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) + { + // 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' + ); + } + // 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 ($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'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($binary), '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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + $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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $this->testEnumParametersWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string); + } + + /** + * 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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $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_form_string_array, $enum_form_string); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + return $this->testEnumParametersAsyncWithHttpInfo($enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double, $enum_form_string_array, $enum_form_string) + ->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 double $enum_query_double Query parameter enum test (double) (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') + * + * @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_form_string_array = '$', $enum_form_string = '-efg') + { + $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_form_string_array, $enum_form_string); + + 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(), + $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 double $enum_query_double Query parameter enum test (double) (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') + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected 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_form_string_array = '$', $enum_form_string = '-efg') + { + + $resourcePath = '/fake'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + if (is_array($enum_query_string_array)) { + $enum_query_string_array = ObjectSerializer::serializeCollection($enum_query_string_array, 'multi', true); + } + if ($enum_query_string_array !== null) { + $queryParams['enum_query_string_array'] = ObjectSerializer::toQueryValue($enum_query_string_array); + } + // query params + if ($enum_query_string !== null) { + $queryParams['enum_query_string'] = ObjectSerializer::toQueryValue($enum_query_string); + } + // query params + if ($enum_query_integer !== null) { + $queryParams['enum_query_integer'] = ObjectSerializer::toQueryValue($enum_query_integer); + } + // query params + if ($enum_query_double !== null) { + $queryParams['enum_query_double'] = ObjectSerializer::toQueryValue($enum_query_double); + } + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testInlineAdditionalProperties + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testInlineAdditionalProperties($request_body) + { + $this->testInlineAdditionalPropertiesWithHttpInfo($request_body); + } + + /** + * Operation testInlineAdditionalPropertiesWithHttpInfo + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @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) + { + $returnType = ''; + $request = $this->testInlineAdditionalPropertiesRequest($request_body); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation testInlineAdditionalPropertiesAsync + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testInlineAdditionalPropertiesAsync($request_body) + { + return $this->testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testInlineAdditionalPropertiesAsyncWithHttpInfo + * + * test inline additionalProperties + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testInlineAdditionalPropertiesAsyncWithHttpInfo($request_body) + { + $returnType = ''; + $request = $this->testInlineAdditionalPropertiesRequest($request_body); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testInlineAdditionalProperties' + * + * @param map[string,string] $request_body request body (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testInlineAdditionalPropertiesRequest($request_body) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($request_body)) { + $_tempBody = $request_body; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation testJsonFormData + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function testJsonFormData($param, $param2) + { + $this->testJsonFormDataWithHttpInfo($param, $param2); + } + + /** + * Operation testJsonFormDataWithHttpInfo + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @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) + { + $returnType = ''; + $request = $this->testJsonFormDataRequest($param, $param2); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testJsonFormDataAsync($param, $param2) + { + return $this->testJsonFormDataAsyncWithHttpInfo($param, $param2) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testJsonFormDataAsyncWithHttpInfo + * + * test json serialization of form data + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testJsonFormDataAsyncWithHttpInfo($param, $param2) + { + $returnType = ''; + $request = $this->testJsonFormDataRequest($param, $param2); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testJsonFormData' + * + * @param string $param field1 (required) + * @param string $param2 field2 (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testJsonFormDataRequest($param, $param2) + { + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php new file mode 100644 index 00000000000..5b833a82e89 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeClassnameTags123Api.php @@ -0,0 +1,370 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Client + */ + public function testClassname($client) + { + list($response) = $this->testClassnameWithHttpInfo($client); + return $response; + } + + /** + * Operation testClassnameWithHttpInfo + * + * To test class name in snake case + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClassnameRequest($client); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsync($client) + { + return $this->testClassnameAsyncWithHttpInfo($client) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation testClassnameAsyncWithHttpInfo + * + * To test class name in snake case + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function testClassnameAsyncWithHttpInfo($client) + { + $returnType = '\OpenAPI\Client\Model\Client'; + $request = $this->testClassnameRequest($client); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'testClassname' + * + * @param \OpenAPI\Client\Model\Client $client client model (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function testClassnameRequest($client) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($client)) { + $_tempBody = $client; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PATCH', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php new file mode 100644 index 00000000000..65b004b8b11 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -0,0 +1,2123 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation addPet + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function addPet($pet) + { + $this->addPetWithHttpInfo($pet); + } + + /** + * Operation addPetWithHttpInfo + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @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) + { + $returnType = ''; + $request = $this->addPetRequest($pet); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation addPetAsync + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPetAsync($pet) + { + return $this->addPetAsyncWithHttpInfo($pet) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation addPetAsyncWithHttpInfo + * + * Add a new pet to the store + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function addPetAsyncWithHttpInfo($pet) + { + $returnType = ''; + $request = $this->addPetRequest($pet); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'addPet' + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function addPetRequest($pet) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($pet)) { + $_tempBody = $pet; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json', 'application/xml'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deletePet + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key api_key (optional) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deletePet($pet_id, $api_key = null) + { + $this->deletePetWithHttpInfo($pet_id, $api_key); + } + + /** + * Operation deletePetWithHttpInfo + * + * Deletes a pet + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * + * @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) + { + $returnType = ''; + $request = $this->deletePetRequest($pet_id, $api_key); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePetAsync($pet_id, $api_key = null) + { + return $this->deletePetAsyncWithHttpInfo($pet_id, $api_key) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deletePetAsyncWithHttpInfo($pet_id, $api_key = null) + { + $returnType = ''; + $request = $this->deletePetRequest($pet_id, $api_key); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deletePet' + * + * @param int $pet_id Pet id to delete (required) + * @param string $api_key (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deletePetRequest($pet_id, $api_key = null) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation findPetsByStatus + * + * Finds Pets by status + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet[] + */ + public function findPetsByStatus($status) + { + list($response) = $this->findPetsByStatusWithHttpInfo($status); + return $response; + } + + /** + * Operation findPetsByStatusWithHttpInfo + * + * Finds Pets by status + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByStatusRequest($status); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByStatusAsync($status) + { + return $this->findPetsByStatusAsyncWithHttpInfo($status) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByStatusAsyncWithHttpInfo($status) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByStatusRequest($status); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'findPetsByStatus' + * + * @param string[] $status Status values that need to be considered for filter (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function findPetsByStatusRequest($status) + { + // 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 + if (is_array($status)) { + $status = ObjectSerializer::serializeCollection($status, 'csv', true); + } + if ($status !== null) { + $queryParams['status'] = ObjectSerializer::toQueryValue($status); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation findPetsByTags + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet[] + */ + public function findPetsByTags($tags) + { + list($response) = $this->findPetsByTagsWithHttpInfo($tags); + return $response; + } + + /** + * Operation findPetsByTagsWithHttpInfo + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @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 findPetsByTagsWithHttpInfo($tags) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByTagsRequest($tags); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByTagsAsync($tags) + { + return $this->findPetsByTagsAsyncWithHttpInfo($tags) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation findPetsByTagsAsyncWithHttpInfo + * + * Finds Pets by tags + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function findPetsByTagsAsyncWithHttpInfo($tags) + { + $returnType = '\OpenAPI\Client\Model\Pet[]'; + $request = $this->findPetsByTagsRequest($tags); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'findPetsByTags' + * + * @param string[] $tags Tags to filter by (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function findPetsByTagsRequest($tags) + { + // 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 + if (is_array($tags)) { + $tags = ObjectSerializer::serializeCollection($tags, 'csv', true); + } + if ($tags !== null) { + $queryParams['tags'] = ObjectSerializer::toQueryValue($tags); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getPetById + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Pet + */ + public function getPetById($pet_id) + { + list($response) = $this->getPetByIdWithHttpInfo($pet_id); + return $response; + } + + /** + * Operation getPetByIdWithHttpInfo + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Pet'; + $request = $this->getPetByIdRequest($pet_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPetByIdAsync($pet_id) + { + return $this->getPetByIdAsyncWithHttpInfo($pet_id) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getPetByIdAsyncWithHttpInfo + * + * Find pet by ID + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getPetByIdAsyncWithHttpInfo($pet_id) + { + $returnType = '\OpenAPI\Client\Model\Pet'; + $request = $this->getPetByIdRequest($pet_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getPetById' + * + * @param int $pet_id ID of pet to return (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getPetByIdRequest($pet_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation updatePet + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updatePet($pet) + { + $this->updatePetWithHttpInfo($pet); + } + + /** + * Operation updatePetWithHttpInfo + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @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) + { + $returnType = ''; + $request = $this->updatePetRequest($pet); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation updatePetAsync + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetAsync($pet) + { + return $this->updatePetAsyncWithHttpInfo($pet) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation updatePetAsyncWithHttpInfo + * + * Update an existing pet + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetAsyncWithHttpInfo($pet) + { + $returnType = ''; + $request = $this->updatePetRequest($pet); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'updatePet' + * + * @param \OpenAPI\Client\Model\Pet $pet Pet object that needs to be added to the store (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updatePetRequest($pet) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($pet)) { + $_tempBody = $pet; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json', 'application/xml'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * 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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updatePetWithForm($pet_id, $name = null, $status = null) + { + $this->updatePetWithFormWithHttpInfo($pet_id, $name, $status); + } + + /** + * 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) + * + * @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) + { + $returnType = ''; + $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetWithFormAsync($pet_id, $name = null, $status = null) + { + return $this->updatePetWithFormAsyncWithHttpInfo($pet_id, $name, $status) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updatePetWithFormAsyncWithHttpInfo($pet_id, $name = null, $status = null) + { + $returnType = ''; + $request = $this->updatePetWithFormRequest($pet_id, $name, $status); + + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updatePetWithFormRequest($pet_id, $name = null, $status = null) + { + // 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); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/x-www-form-urlencoded'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @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) + { + list($response) = $this->uploadFileWithHttpInfo($pet_id, $additional_metadata, $file); + 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) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileAsync($pet_id, $additional_metadata = null, $file = null) + { + return $this->uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata, $file) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function uploadFileAsyncWithHttpInfo($pet_id, $additional_metadata = null, $file = null) + { + $returnType = '\OpenAPI\Client\Model\ApiResponse'; + $request = $this->uploadFileRequest($pet_id, $additional_metadata, $file); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function uploadFileRequest($pet_id, $additional_metadata = null, $file = null) + { + // 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'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue($file), 'rb'); + } + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['multipart/form-data'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + // this endpoint requires OAuth (access token) + if ($this->config->getAccessToken() !== null) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php new file mode 100644 index 00000000000..2573fae4b0f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/StoreApi.php @@ -0,0 +1,1107 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteOrder($order_id) + { + $this->deleteOrderWithHttpInfo($order_id); + } + + /** + * Operation deleteOrderWithHttpInfo + * + * Delete purchase order by ID + * + * @param string $order_id ID of the order that needs to be deleted (required) + * + * @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) + { + $returnType = ''; + $request = $this->deleteOrderRequest($order_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOrderAsync($order_id) + { + return $this->deleteOrderAsyncWithHttpInfo($order_id) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteOrderAsyncWithHttpInfo($order_id) + { + $returnType = ''; + $request = $this->deleteOrderRequest($order_id); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteOrder' + * + * @param string $order_id ID of the order that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteOrderRequest($order_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation getInventory + * + * Returns pet inventories by status + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return map[string,int] + */ + public function getInventory() + { + list($response) = $this->getInventoryWithHttpInfo(); + return $response; + } + + /** + * Operation getInventoryWithHttpInfo + * + * Returns pet inventories by status + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of map[string,int], HTTP status code, HTTP response headers (array of strings) + */ + public function getInventoryWithHttpInfo() + { + $returnType = 'map[string,int]'; + $request = $this->getInventoryRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + 'map[string,int]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getInventoryAsync + * + * Returns pet inventories by status + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getInventoryAsync() + { + return $this->getInventoryAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getInventoryAsyncWithHttpInfo + * + * Returns pet inventories by status + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getInventoryAsyncWithHttpInfo() + { + $returnType = 'map[string,int]'; + $request = $this->getInventoryRequest(); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getInventory' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getInventoryRequest() + { + + $resourcePath = '/store/inventory'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($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 + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Order + */ + public function getOrderById($order_id) + { + list($response) = $this->getOrderByIdWithHttpInfo($order_id); + return $response; + } + + /** + * Operation getOrderByIdWithHttpInfo + * + * Find purchase order by ID + * + * @param int $order_id ID of pet that needs to be fetched (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->getOrderByIdRequest($order_id); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderByIdAsync($order_id) + { + return $this->getOrderByIdAsyncWithHttpInfo($order_id) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getOrderByIdAsyncWithHttpInfo($order_id) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->getOrderByIdRequest($order_id); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getOrderById' + * + * @param int $order_id ID of pet that needs to be fetched (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getOrderByIdRequest($order_id) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\Order + */ + public function placeOrder($order) + { + list($response) = $this->placeOrderWithHttpInfo($order); + return $response; + } + + /** + * Operation placeOrderWithHttpInfo + * + * Place an order for a pet + * + * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->placeOrderRequest($order); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsync($order) + { + return $this->placeOrderAsyncWithHttpInfo($order) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function placeOrderAsyncWithHttpInfo($order) + { + $returnType = '\OpenAPI\Client\Model\Order'; + $request = $this->placeOrderRequest($order); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'placeOrder' + * + * @param \OpenAPI\Client\Model\Order $order order placed for purchasing the pet (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function placeOrderRequest($order) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($order)) { + $_tempBody = $order; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php new file mode 100644 index 00000000000..e8811f6cc29 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -0,0 +1,1973 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createUser + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUser($user) + { + $this->createUserWithHttpInfo($user); + } + + /** + * Operation createUserWithHttpInfo + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUserRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUserAsync($user) + { + return $this->createUserAsyncWithHttpInfo($user) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createUserAsyncWithHttpInfo + * + * Create user + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUserAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUserRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUser' + * + * @param \OpenAPI\Client\Model\User $user Created user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUserRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUsersWithArrayInput($user) + { + $this->createUsersWithArrayInputWithHttpInfo($user); + } + + /** + * Operation createUsersWithArrayInputWithHttpInfo + * + * Creates list of users with given input array + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUsersWithArrayInputRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithArrayInputAsync($user) + { + return $this->createUsersWithArrayInputAsyncWithHttpInfo($user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithArrayInputAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUsersWithArrayInputRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUsersWithArrayInput' + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUsersWithArrayInputRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createUsersWithListInput($user) + { + $this->createUsersWithListInputWithHttpInfo($user); + } + + /** + * Operation createUsersWithListInputWithHttpInfo + * + * Creates list of users with given input array + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->createUsersWithListInputRequest($user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithListInputAsync($user) + { + return $this->createUsersWithListInputAsyncWithHttpInfo($user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createUsersWithListInputAsyncWithHttpInfo($user) + { + $returnType = ''; + $request = $this->createUsersWithListInputRequest($user); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createUsersWithListInput' + * + * @param \OpenAPI\Client\Model\User[] $user List of user object (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createUsersWithListInputRequest($user) + { + // 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; + + + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation deleteUser + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function deleteUser($username) + { + $this->deleteUserWithHttpInfo($username); + } + + /** + * Operation deleteUserWithHttpInfo + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @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) + { + $returnType = ''; + $request = $this->deleteUserRequest($username); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteUserAsync($username) + { + return $this->deleteUserAsyncWithHttpInfo($username) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation deleteUserAsyncWithHttpInfo + * + * Delete user + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function deleteUserAsyncWithHttpInfo($username) + { + $returnType = ''; + $request = $this->deleteUserRequest($username); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'deleteUser' + * + * @param string $username The name that needs to be deleted (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function deleteUserRequest($username) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'DELETE', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\User + */ + public function getUserByName($username) + { + list($response) = $this->getUserByNameWithHttpInfo($username); + return $response; + } + + /** + * Operation getUserByNameWithHttpInfo + * + * Get user by user name + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * + * @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) + { + $returnType = '\OpenAPI\Client\Model\User'; + $request = $this->getUserByNameRequest($username); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserByNameAsync($username) + { + return $this->getUserByNameAsyncWithHttpInfo($username) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getUserByNameAsyncWithHttpInfo($username) + { + $returnType = '\OpenAPI\Client\Model\User'; + $request = $this->getUserByNameRequest($username); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getUserByName' + * + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function getUserByNameRequest($username) + { + // 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 + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return string + */ + public function loginUser($username, $password) + { + list($response) = $this->loginUserWithHttpInfo($username, $password); + 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) + * + * @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) + { + $returnType = 'string'; + $request = $this->loginUserRequest($username, $password); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function loginUserAsync($username, $password) + { + return $this->loginUserAsyncWithHttpInfo($username, $password) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function loginUserAsyncWithHttpInfo($username, $password) + { + $returnType = 'string'; + $request = $this->loginUserRequest($username, $password); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function loginUserRequest($username, $password) + { + // 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 + if ($username !== null) { + $queryParams['username'] = ObjectSerializer::toQueryValue($username); + } + // query params + if ($password !== null) { + $queryParams['password'] = ObjectSerializer::toQueryValue($password); + } + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/xml', 'application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/xml', 'application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation logoutUser + * + * Logs out current logged in user session + * + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function logoutUser() + { + $this->logoutUserWithHttpInfo(); + } + + /** + * Operation logoutUserWithHttpInfo + * + * Logs out current logged in user session + * + * + * @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() + { + $returnType = ''; + $request = $this->logoutUserRequest(); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + } + throw $e; + } + } + + /** + * Operation logoutUserAsync + * + * Logs out current logged in user session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function logoutUserAsync() + { + return $this->logoutUserAsyncWithHttpInfo() + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation logoutUserAsyncWithHttpInfo + * + * Logs out current logged in user session + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function logoutUserAsyncWithHttpInfo() + { + $returnType = ''; + $request = $this->logoutUserRequest(); + + 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(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'logoutUser' + * + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function logoutUserRequest() + { + + $resourcePath = '/user/logout'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $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) + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function updateUser($username, $user) + { + $this->updateUserWithHttpInfo($username, $user); + } + + /** + * Operation updateUserWithHttpInfo + * + * Updated user + * + * @param string $username name that need to be deleted (required) + * @param \OpenAPI\Client\Model\User $user Updated user object (required) + * + * @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) + { + $returnType = ''; + $request = $this->updateUserRequest($username, $user); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateUserAsync($username, $user) + { + return $this->updateUserAsyncWithHttpInfo($username, $user) + ->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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function updateUserAsyncWithHttpInfo($username, $user) + { + $returnType = ''; + $request = $this->updateUserRequest($username, $user); + + 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(), + $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) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function updateUserRequest($username, $user) + { + // 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 + ); + } + + // body params + $_tempBody = null; + if (isset($user)) { + $_tempBody = $user; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + [] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + [], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\build_query($formParams); + } + } + + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\build_query($queryParams); + return new Request( + 'PUT', + $this->config->getHost() . $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/openapi3/client/petstore/php/OpenAPIClient-php/lib/ApiException.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/ApiException.php new file mode 100644 index 00000000000..2f59401f7a8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/ApiException.php @@ -0,0 +1,121 @@ +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 mixed HTTP body of the server response either as \stdClass or string + */ + public function getResponseBody() + { + return $this->responseBody; + } + + /** + * Sets the deseralized response object (during deserialization) + * + * @param mixed $obj Deserialized response object + * + * @return void + */ + public function setResponseObject($obj) + { + $this->responseObject = $obj; + } + + /** + * Gets the deseralized response object (during deserialization) + * + * @return mixed the deserialized response object + */ + public function getResponseObject() + { + return $this->responseObject; + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Configuration.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Configuration.php new file mode 100644 index 00000000000..7b51d67087d --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Configuration.php @@ -0,0 +1,429 @@ +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 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 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 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 detault 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 .= ' OpenAPI Spec Version: 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 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; + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php new file mode 100644 index 00000000000..80475db54be --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -0,0 +1,110 @@ +selectAcceptHeader($accept); + if ($accept !== null) { + $headers['Accept'] = $accept; + } + + $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes); + return $headers; + } + + /** + * @param string[] $accept + * @return array + */ + public function selectHeadersForMultipart($accept) + { + $headers = $this->selectHeaders($accept, []); + + unset($headers['Content-Type']); + return $headers; + } + + /** + * Return the header 'Accept' based on an array of Accept provided + * + * @param string[] $accept Array of header + * + * @return string Accept (e.g. application/json) + */ + private function selectAcceptHeader($accept) + { + if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) { + return null; + } elseif (preg_grep("/application\/json/i", $accept)) { + return 'application/json'; + } else { + return implode(',', $accept); + } + } + + /** + * Return the content type based on an array of content-type provided + * + * @param string[] $contentType Array fo content-type + * + * @return string Content-Type (e.g. application/json) + */ + private function selectContentTypeHeader($contentType) + { + if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) { + return 'application/json'; + } elseif (preg_grep("/application\/json/i", $contentType)) { + return 'application/json'; + } else { + return implode(',', $contentType); + } + } +} + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php new file mode 100644 index 00000000000..c35728944e7 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AdditionalPropertiesClass.php @@ -0,0 +1,331 @@ + 'map[string,string]', + 'map_of_map_property' => 'map[string,map[string,string]]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'map_property' => null, + 'map_of_map_property' => null + ]; + + /** + * 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 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->container['map_property'] = isset($data['map_property']) ? $data['map_property'] : null; + $this->container['map_of_map_property'] = isset($data['map_of_map_property']) ? $data['map_of_map_property'] : null; + } + + /** + * 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 map[string,string] + */ + public function getMapProperty() + { + return $this->container['map_property']; + } + + /** + * Sets map_property + * + * @param map[string,string] $map_property map_property + * + * @return $this + */ + public function setMapProperty($map_property) + { + $this->container['map_property'] = $map_property; + + return $this; + } + + /** + * Gets map_of_map_property + * + * @return map[string,map[string,string]] + */ + public function getMapOfMapProperty() + { + return $this->container['map_of_map_property']; + } + + /** + * Sets map_of_map_property + * + * @param map[string,map[string,string]] $map_of_map_property map_of_map_property + * + * @return $this + */ + public function setMapOfMapProperty($map_of_map_property) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php new file mode 100644 index 00000000000..6574a08fd6f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Animal.php @@ -0,0 +1,338 @@ + 'string', + 'color' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'class_name' => null, + 'color' => null + ]; + + /** + * 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 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->container['class_name'] = isset($data['class_name']) ? $data['class_name'] : null; + $this->container['color'] = isset($data['color']) ? $data['color'] : 'red'; + + // Initialize discriminator property with the model name. + $discriminator = array_search('className', self::$attributeMap); + $this->container[$discriminator] = static::$openAPIModelName; + } + + /** + * 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 $this + */ + public function setClassName($class_name) + { + $this->container['class_name'] = $class_name; + + return $this; + } + + /** + * Gets color + * + * @return string + */ + public function getColor() + { + return $this->container['color']; + } + + /** + * Sets color + * + * @param string $color color + * + * @return $this + */ + public function setColor($color) + { + $this->container['color'] = $color; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php new file mode 100644 index 00000000000..ba563750be0 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/AnimalFarm.php @@ -0,0 +1,276 @@ +listInvalidProperties()) === 0; + } + + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php new file mode 100644 index 00000000000..571d4983244 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ApiResponse.php @@ -0,0 +1,361 @@ + 'int', + 'type' => 'string', + 'message' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'code' => 'int32', + 'type' => null, + 'message' => null + ]; + + /** + * 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 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->container['code'] = isset($data['code']) ? $data['code'] : null; + $this->container['type'] = isset($data['type']) ? $data['type'] : null; + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + } + + /** + * 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 + */ + public function getCode() + { + return $this->container['code']; + } + + /** + * Sets code + * + * @param int $code code + * + * @return $this + */ + public function setCode($code) + { + $this->container['code'] = $code; + + return $this; + } + + /** + * Gets type + * + * @return string + */ + public function getType() + { + return $this->container['type']; + } + + /** + * Sets type + * + * @param string $type type + * + * @return $this + */ + public function setType($type) + { + $this->container['type'] = $type; + + return $this; + } + + /** + * Gets message + * + * @return string + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string $message message + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php new file mode 100644 index 00000000000..20f5c0be4f1 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfArrayOfNumberOnly.php @@ -0,0 +1,301 @@ + 'float[][]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'array_array_number' => null + ]; + + /** + * 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 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->container['array_array_number'] = isset($data['array_array_number']) ? $data['array_array_number'] : null; + } + + /** + * 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[][] + */ + public function getArrayArrayNumber() + { + return $this->container['array_array_number']; + } + + /** + * Sets array_array_number + * + * @param float[][] $array_array_number array_array_number + * + * @return $this + */ + public function setArrayArrayNumber($array_array_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php new file mode 100644 index 00000000000..ba5dd085926 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayOfNumberOnly.php @@ -0,0 +1,301 @@ + 'float[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'array_number' => null + ]; + + /** + * 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 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->container['array_number'] = isset($data['array_number']) ? $data['array_number'] : null; + } + + /** + * 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[] + */ + public function getArrayNumber() + { + return $this->container['array_number']; + } + + /** + * Sets array_number + * + * @param float[] $array_number array_number + * + * @return $this + */ + public function setArrayNumber($array_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php new file mode 100644 index 00000000000..4d88a5f484e --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ArrayTest.php @@ -0,0 +1,361 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'array_of_string' => null, + 'array_array_of_integer' => 'int64', + 'array_array_of_model' => null + ]; + + /** + * 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 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->container['array_of_string'] = isset($data['array_of_string']) ? $data['array_of_string'] : null; + $this->container['array_array_of_integer'] = isset($data['array_array_of_integer']) ? $data['array_array_of_integer'] : null; + $this->container['array_array_of_model'] = isset($data['array_array_of_model']) ? $data['array_array_of_model'] : null; + } + + /** + * 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_of_string + * + * @return string[] + */ + public function getArrayOfString() + { + return $this->container['array_of_string']; + } + + /** + * Sets array_of_string + * + * @param string[] $array_of_string array_of_string + * + * @return $this + */ + public function setArrayOfString($array_of_string) + { + $this->container['array_of_string'] = $array_of_string; + + return $this; + } + + /** + * Gets array_array_of_integer + * + * @return int[][] + */ + public function getArrayArrayOfInteger() + { + return $this->container['array_array_of_integer']; + } + + /** + * Sets array_array_of_integer + * + * @param int[][] $array_array_of_integer array_array_of_integer + * + * @return $this + */ + public function setArrayArrayOfInteger($array_array_of_integer) + { + $this->container['array_array_of_integer'] = $array_array_of_integer; + + return $this; + } + + /** + * Gets array_array_of_model + * + * @return \OpenAPI\Client\Model\ReadOnlyFirst[][] + */ + public function getArrayArrayOfModel() + { + return $this->container['array_array_of_model']; + } + + /** + * Sets array_array_of_model + * + * @param \OpenAPI\Client\Model\ReadOnlyFirst[][] $array_array_of_model array_array_of_model + * + * @return $this + */ + public function setArrayArrayOfModel($array_array_of_model) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php new file mode 100644 index 00000000000..165c41fcc8b --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Capitalization.php @@ -0,0 +1,451 @@ + '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[] + */ + 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 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 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->container['small_camel'] = isset($data['small_camel']) ? $data['small_camel'] : null; + $this->container['capital_camel'] = isset($data['capital_camel']) ? $data['capital_camel'] : null; + $this->container['small_snake'] = isset($data['small_snake']) ? $data['small_snake'] : null; + $this->container['capital_snake'] = isset($data['capital_snake']) ? $data['capital_snake'] : null; + $this->container['sca_eth_flow_points'] = isset($data['sca_eth_flow_points']) ? $data['sca_eth_flow_points'] : null; + $this->container['att_name'] = isset($data['att_name']) ? $data['att_name'] : null; + } + + /** + * 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 + */ + public function getSmallCamel() + { + return $this->container['small_camel']; + } + + /** + * Sets small_camel + * + * @param string $small_camel small_camel + * + * @return $this + */ + public function setSmallCamel($small_camel) + { + $this->container['small_camel'] = $small_camel; + + return $this; + } + + /** + * Gets capital_camel + * + * @return string + */ + public function getCapitalCamel() + { + return $this->container['capital_camel']; + } + + /** + * Sets capital_camel + * + * @param string $capital_camel capital_camel + * + * @return $this + */ + public function setCapitalCamel($capital_camel) + { + $this->container['capital_camel'] = $capital_camel; + + return $this; + } + + /** + * Gets small_snake + * + * @return string + */ + public function getSmallSnake() + { + return $this->container['small_snake']; + } + + /** + * Sets small_snake + * + * @param string $small_snake small_snake + * + * @return $this + */ + public function setSmallSnake($small_snake) + { + $this->container['small_snake'] = $small_snake; + + return $this; + } + + /** + * Gets capital_snake + * + * @return string + */ + public function getCapitalSnake() + { + return $this->container['capital_snake']; + } + + /** + * Sets capital_snake + * + * @param string $capital_snake capital_snake + * + * @return $this + */ + public function setCapitalSnake($capital_snake) + { + $this->container['capital_snake'] = $capital_snake; + + return $this; + } + + /** + * Gets sca_eth_flow_points + * + * @return string + */ + public function getScaEthFlowPoints() + { + return $this->container['sca_eth_flow_points']; + } + + /** + * Sets sca_eth_flow_points + * + * @param string $sca_eth_flow_points sca_eth_flow_points + * + * @return $this + */ + public function setScaEthFlowPoints($sca_eth_flow_points) + { + $this->container['sca_eth_flow_points'] = $sca_eth_flow_points; + + return $this; + } + + /** + * Gets att_name + * + * @return string + */ + public function getAttName() + { + return $this->container['att_name']; + } + + /** + * Sets att_name + * + * @param string $att_name Name of the pet + * + * @return $this + */ + public function setAttName($att_name) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php new file mode 100644 index 00000000000..24d015d48e0 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Cat.php @@ -0,0 +1,295 @@ + 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'declawed' => null + ]; + + /** + * 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 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->container['declawed'] = isset($data['declawed']) ? $data['declawed'] : null; + } + + /** + * 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 + */ + public function getDeclawed() + { + return $this->container['declawed']; + } + + /** + * Sets declawed + * + * @param bool $declawed declawed + * + * @return $this + */ + public function setDeclawed($declawed) + { + $this->container['declawed'] = $declawed; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php new file mode 100644 index 00000000000..976e578c1e5 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Category.php @@ -0,0 +1,331 @@ + 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php new file mode 100644 index 00000000000..b6525b02054 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ClassModel.php @@ -0,0 +1,302 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + '_class' => null + ]; + + /** + * 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 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->container['_class'] = isset($data['_class']) ? $data['_class'] : null; + } + + /** + * 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 + */ + public function getClass() + { + return $this->container['_class']; + } + + /** + * Sets _class + * + * @param string $_class _class + * + * @return $this + */ + public function setClass($_class) + { + $this->container['_class'] = $_class; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php new file mode 100644 index 00000000000..43be0f8a5ec --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Client.php @@ -0,0 +1,301 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'client' => null + ]; + + /** + * 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 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->container['client'] = isset($data['client']) ? $data['client'] : null; + } + + /** + * 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 + */ + public function getClient() + { + return $this->container['client']; + } + + /** + * Sets client + * + * @param string $client client + * + * @return $this + */ + public function setClient($client) + { + $this->container['client'] = $client; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php new file mode 100644 index 00000000000..c849f2e75b8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Dog.php @@ -0,0 +1,295 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'breed' => null + ]; + + /** + * 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 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->container['breed'] = isset($data['breed']) ? $data['breed'] : null; + } + + /** + * 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 + */ + public function getBreed() + { + return $this->container['breed']; + } + + /** + * Sets breed + * + * @param string $breed breed + * + * @return $this + */ + public function setBreed($breed) + { + $this->container['breed'] = $breed; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php new file mode 100644 index 00000000000..98985fbc9e8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumArrays.php @@ -0,0 +1,387 @@ + 'string', + 'array_enum' => 'string[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'just_symbol' => null, + 'array_enum' => null + ]; + + /** + * 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 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; + } + + const JUST_SYMBOL_GREATER_THAN_OR_EQUAL_TO = '>='; + const JUST_SYMBOL_DOLLAR = '$'; + const ARRAY_ENUM_FISH = 'fish'; + 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->container['just_symbol'] = isset($data['just_symbol']) ? $data['just_symbol'] : null; + $this->container['array_enum'] = isset($data['array_enum']) ? $data['array_enum'] : null; + } + + /** + * 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 for 'just_symbol', must be one of '%s'", + 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 + */ + public function getJustSymbol() + { + return $this->container['just_symbol']; + } + + /** + * Sets just_symbol + * + * @param string $just_symbol just_symbol + * + * @return $this + */ + public function setJustSymbol($just_symbol) + { + $allowedValues = $this->getJustSymbolAllowableValues(); + if (!is_null($just_symbol) && !in_array($just_symbol, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'just_symbol', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['just_symbol'] = $just_symbol; + + return $this; + } + + /** + * Gets array_enum + * + * @return string[] + */ + public function getArrayEnum() + { + return $this->container['array_enum']; + } + + /** + * Sets array_enum + * + * @param string[] $array_enum array_enum + * + * @return $this + */ + public function setArrayEnum($array_enum) + { + $allowedValues = $this->getArrayEnumAllowableValues(); + if (!is_null($array_enum) && 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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php new file mode 100644 index 00000000000..d8e282ed4cb --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/EnumClass.php @@ -0,0 +1,64 @@ + 'string', + 'enum_string_required' => 'string', + 'enum_integer' => 'int', + 'enum_number' => 'double', + 'outer_enum' => '\OpenAPI\Client\Model\OuterEnum' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'enum_string' => null, + 'enum_string_required' => null, + 'enum_integer' => 'int32', + 'enum_number' => 'double', + 'outer_enum' => null + ]; + + /** + * 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 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' + ]; + + /** + * 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' + ]; + + /** + * 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' + ]; + + /** + * 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; + } + + const ENUM_STRING_UPPER = 'UPPER'; + const ENUM_STRING_LOWER = 'lower'; + const ENUM_STRING_EMPTY = ''; + const ENUM_STRING_REQUIRED_UPPER = 'UPPER'; + const ENUM_STRING_REQUIRED_LOWER = 'lower'; + const ENUM_STRING_REQUIRED_EMPTY = ''; + const ENUM_INTEGER_1 = 1; + const ENUM_INTEGER_MINUS_1 = -1; + const ENUM_NUMBER_1_DOT_1 = 1.1; + 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->container['enum_string'] = isset($data['enum_string']) ? $data['enum_string'] : null; + $this->container['enum_string_required'] = isset($data['enum_string_required']) ? $data['enum_string_required'] : null; + $this->container['enum_integer'] = isset($data['enum_integer']) ? $data['enum_integer'] : null; + $this->container['enum_number'] = isset($data['enum_number']) ? $data['enum_number'] : null; + $this->container['outer_enum'] = isset($data['outer_enum']) ? $data['outer_enum'] : null; + } + + /** + * 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 for 'enum_string', must be one of '%s'", + 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 for 'enum_string_required', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getEnumIntegerAllowableValues(); + if (!is_null($this->container['enum_integer']) && !in_array($this->container['enum_integer'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getEnumNumberAllowableValues(); + if (!is_null($this->container['enum_number']) && !in_array($this->container['enum_number'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_number', must be one of '%s'", + 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 + */ + public function getEnumString() + { + return $this->container['enum_string']; + } + + /** + * Sets enum_string + * + * @param string $enum_string enum_string + * + * @return $this + */ + public function setEnumString($enum_string) + { + $allowedValues = $this->getEnumStringAllowableValues(); + if (!is_null($enum_string) && !in_array($enum_string, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_string', must be one of '%s'", + 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 $this + */ + public function setEnumStringRequired($enum_string_required) + { + $allowedValues = $this->getEnumStringRequiredAllowableValues(); + if (!in_array($enum_string_required, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_string_required', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_string_required'] = $enum_string_required; + + return $this; + } + + /** + * Gets enum_integer + * + * @return int + */ + public function getEnumInteger() + { + return $this->container['enum_integer']; + } + + /** + * Sets enum_integer + * + * @param int $enum_integer enum_integer + * + * @return $this + */ + public function setEnumInteger($enum_integer) + { + $allowedValues = $this->getEnumIntegerAllowableValues(); + if (!is_null($enum_integer) && !in_array($enum_integer, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_integer', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_integer'] = $enum_integer; + + return $this; + } + + /** + * Gets enum_number + * + * @return double + */ + public function getEnumNumber() + { + return $this->container['enum_number']; + } + + /** + * Sets enum_number + * + * @param double $enum_number enum_number + * + * @return $this + */ + public function setEnumNumber($enum_number) + { + $allowedValues = $this->getEnumNumberAllowableValues(); + if (!is_null($enum_number) && !in_array($enum_number, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_number', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_number'] = $enum_number; + + return $this; + } + + /** + * Gets outer_enum + * + * @return \OpenAPI\Client\Model\OuterEnum + */ + public function getOuterEnum() + { + return $this->container['outer_enum']; + } + + /** + * Sets outer_enum + * + * @param \OpenAPI\Client\Model\OuterEnum $outer_enum outer_enum + * + * @return $this + */ + public function setOuterEnum($outer_enum) + { + $this->container['outer_enum'] = $outer_enum; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php new file mode 100644 index 00000000000..959015b7a74 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/FormatTest.php @@ -0,0 +1,768 @@ + 'int', + 'int32' => 'int', + 'int64' => 'int', + 'number' => 'float', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'byte' => 'string', + 'binary' => '\SplFileObject', + 'date' => '\DateTime', + 'date_time' => '\DateTime', + 'uuid' => 'string', + 'password' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'integer' => 'int32', + 'int32' => 'int32', + 'int64' => 'int64', + 'number' => null, + 'float' => 'float', + 'double' => 'double', + 'string' => null, + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'date-time', + 'uuid' => 'uuid', + 'password' => 'password' + ]; + + /** + * 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 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', + 'string' => 'string', + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'dateTime', + 'uuid' => 'uuid', + 'password' => 'password' + ]; + + /** + * 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', + 'string' => 'setString', + 'byte' => 'setByte', + 'binary' => 'setBinary', + 'date' => 'setDate', + 'date_time' => 'setDateTime', + 'uuid' => 'setUuid', + 'password' => 'setPassword' + ]; + + /** + * 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', + 'string' => 'getString', + 'byte' => 'getByte', + 'binary' => 'getBinary', + 'date' => 'getDate', + 'date_time' => 'getDateTime', + 'uuid' => 'getUuid', + 'password' => 'getPassword' + ]; + + /** + * 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->container['integer'] = isset($data['integer']) ? $data['integer'] : null; + $this->container['int32'] = isset($data['int32']) ? $data['int32'] : null; + $this->container['int64'] = isset($data['int64']) ? $data['int64'] : null; + $this->container['number'] = isset($data['number']) ? $data['number'] : null; + $this->container['float'] = isset($data['float']) ? $data['float'] : null; + $this->container['double'] = isset($data['double']) ? $data['double'] : null; + $this->container['string'] = isset($data['string']) ? $data['string'] : null; + $this->container['byte'] = isset($data['byte']) ? $data['byte'] : null; + $this->container['binary'] = isset($data['binary']) ? $data['binary'] : null; + $this->container['date'] = isset($data['date']) ? $data['date'] : null; + $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; + $this->container['password'] = isset($data['password']) ? $data['password'] : null; + } + + /** + * 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 ($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."; + } + + 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 + */ + public function getInteger() + { + return $this->container['integer']; + } + + /** + * Sets integer + * + * @param int $integer integer + * + * @return $this + */ + public function setInteger($integer) + { + + if (!is_null($integer) && ($integer > 100)) { + throw new \InvalidArgumentException('invalid value for $integer when calling FormatTest., must be smaller than or equal to 100.'); + } + if (!is_null($integer) && ($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 + */ + public function getInt32() + { + return $this->container['int32']; + } + + /** + * Sets int32 + * + * @param int $int32 int32 + * + * @return $this + */ + public function setInt32($int32) + { + + if (!is_null($int32) && ($int32 > 200)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling FormatTest., must be smaller than or equal to 200.'); + } + if (!is_null($int32) && ($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 + */ + public function getInt64() + { + return $this->container['int64']; + } + + /** + * Sets int64 + * + * @param int $int64 int64 + * + * @return $this + */ + public function setInt64($int64) + { + $this->container['int64'] = $int64; + + return $this; + } + + /** + * Gets number + * + * @return float + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param float $number number + * + * @return $this + */ + public function setNumber($number) + { + + 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 + */ + public function getFloat() + { + return $this->container['float']; + } + + /** + * Sets float + * + * @param float $float float + * + * @return $this + */ + public function setFloat($float) + { + + if (!is_null($float) && ($float > 987.6)) { + throw new \InvalidArgumentException('invalid value for $float when calling FormatTest., must be smaller than or equal to 987.6.'); + } + if (!is_null($float) && ($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 double + */ + public function getDouble() + { + return $this->container['double']; + } + + /** + * Sets double + * + * @param double $double double + * + * @return $this + */ + public function setDouble($double) + { + + if (!is_null($double) && ($double > 123.4)) { + throw new \InvalidArgumentException('invalid value for $double when calling FormatTest., must be smaller than or equal to 123.4.'); + } + if (!is_null($double) && ($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 string + * + * @return string + */ + public function getString() + { + return $this->container['string']; + } + + /** + * Sets string + * + * @param string $string string + * + * @return $this + */ + public function setString($string) + { + $this->container['string'] = $string; + + return $this; + } + + /** + * Gets byte + * + * @return string + */ + public function getByte() + { + return $this->container['byte']; + } + + /** + * Sets byte + * + * @param string $byte byte + * + * @return $this + */ + public function setByte($byte) + { + $this->container['byte'] = $byte; + + return $this; + } + + /** + * Gets binary + * + * @return \SplFileObject + */ + public function getBinary() + { + return $this->container['binary']; + } + + /** + * Sets binary + * + * @param \SplFileObject $binary binary + * + * @return $this + */ + public function setBinary($binary) + { + $this->container['binary'] = $binary; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime $date date + * + * @return $this + */ + public function setDate($date) + { + $this->container['date'] = $date; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime $date_time date_time + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets uuid + * + * @return string + */ + public function getUuid() + { + return $this->container['uuid']; + } + + /** + * Sets uuid + * + * @param string $uuid uuid + * + * @return $this + */ + public function setUuid($uuid) + { + $this->container['uuid'] = $uuid; + + return $this; + } + + /** + * Gets password + * + * @return string + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string $password password + * + * @return $this + */ + public function setPassword($password) + { + 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; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php new file mode 100644 index 00000000000..ba447b30c42 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/HasOnlyReadOnly.php @@ -0,0 +1,331 @@ + 'string', + 'foo' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'bar' => null, + 'foo' => null + ]; + + /** + * 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 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->container['bar'] = isset($data['bar']) ? $data['bar'] : null; + $this->container['foo'] = isset($data['foo']) ? $data['foo'] : null; + } + + /** + * 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 + */ + public function getBar() + { + return $this->container['bar']; + } + + /** + * Sets bar + * + * @param string $bar bar + * + * @return $this + */ + public function setBar($bar) + { + $this->container['bar'] = $bar; + + return $this; + } + + /** + * Gets foo + * + * @return string + */ + public function getFoo() + { + return $this->container['foo']; + } + + /** + * Sets foo + * + * @param string $foo foo + * + * @return $this + */ + public function setFoo($foo) + { + $this->container['foo'] = $foo; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php new file mode 100644 index 00000000000..868afa3d3f8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MapTest.php @@ -0,0 +1,355 @@ + 'map[string,map[string,string]]', + 'map_of_enum_string' => 'map[string,string]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'map_map_of_string' => null, + 'map_of_enum_string' => null + ]; + + /** + * 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 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' + ]; + + /** + * 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' + ]; + + /** + * 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' + ]; + + /** + * 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; + } + + const MAP_OF_ENUM_STRING_UPPER = 'UPPER'; + 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->container['map_map_of_string'] = isset($data['map_map_of_string']) ? $data['map_map_of_string'] : null; + $this->container['map_of_enum_string'] = isset($data['map_of_enum_string']) ? $data['map_of_enum_string'] : null; + } + + /** + * 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 map[string,map[string,string]] + */ + public function getMapMapOfString() + { + return $this->container['map_map_of_string']; + } + + /** + * Sets map_map_of_string + * + * @param map[string,map[string,string]] $map_map_of_string map_map_of_string + * + * @return $this + */ + public function setMapMapOfString($map_map_of_string) + { + $this->container['map_map_of_string'] = $map_map_of_string; + + return $this; + } + + /** + * Gets map_of_enum_string + * + * @return map[string,string] + */ + public function getMapOfEnumString() + { + return $this->container['map_of_enum_string']; + } + + /** + * Sets map_of_enum_string + * + * @param map[string,string] $map_of_enum_string map_of_enum_string + * + * @return $this + */ + public function setMapOfEnumString($map_of_enum_string) + { + $allowedValues = $this->getMapOfEnumStringAllowableValues(); + if (!is_null($map_of_enum_string) && 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; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php new file mode 100644 index 00000000000..0e23c1cf7d7 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php @@ -0,0 +1,361 @@ + 'string', + 'date_time' => '\DateTime', + 'map' => 'map[string,\OpenAPI\Client\Model\Animal]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'uuid' => 'uuid', + 'date_time' => 'date-time', + 'map' => null + ]; + + /** + * 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 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->container['uuid'] = isset($data['uuid']) ? $data['uuid'] : null; + $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['map'] = isset($data['map']) ? $data['map'] : null; + } + + /** + * 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 + */ + public function getUuid() + { + return $this->container['uuid']; + } + + /** + * Sets uuid + * + * @param string $uuid uuid + * + * @return $this + */ + public function setUuid($uuid) + { + $this->container['uuid'] = $uuid; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime $date_time date_time + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets map + * + * @return map[string,\OpenAPI\Client\Model\Animal] + */ + public function getMap() + { + return $this->container['map']; + } + + /** + * Sets map + * + * @param map[string,\OpenAPI\Client\Model\Animal] $map map + * + * @return $this + */ + public function setMap($map) + { + $this->container['map'] = $map; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php new file mode 100644 index 00000000000..f781ba56e36 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Model200Response.php @@ -0,0 +1,332 @@ + 'int', + 'class' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => 'int32', + 'class' => null + ]; + + /** + * 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 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->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['class'] = isset($data['class']) ? $data['class'] : null; + } + + /** + * 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 + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param int $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets class + * + * @return string + */ + public function getClass() + { + return $this->container['class']; + } + + /** + * Sets class + * + * @param string $class class + * + * @return $this + */ + public function setClass($class) + { + $this->container['class'] = $class; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php new file mode 100644 index 00000000000..7df58906de6 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelInterface.php @@ -0,0 +1,96 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + '_123_list' => null + ]; + + /** + * 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 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->container['_123_list'] = isset($data['_123_list']) ? $data['_123_list'] : null; + } + + /** + * 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 + */ + public function get123List() + { + return $this->container['_123_list']; + } + + /** + * Sets _123_list + * + * @param string $_123_list _123_list + * + * @return $this + */ + public function set123List($_123_list) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php new file mode 100644 index 00000000000..4d0663e296d --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -0,0 +1,302 @@ + 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'return' => 'int32' + ]; + + /** + * 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 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->container['return'] = isset($data['return']) ? $data['return'] : null; + } + + /** + * 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 + */ + public function getReturn() + { + return $this->container['return']; + } + + /** + * Sets return + * + * @param int $return return + * + * @return $this + */ + public function setReturn($return) + { + $this->container['return'] = $return; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php new file mode 100644 index 00000000000..7a67b5882ee --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Name.php @@ -0,0 +1,395 @@ + 'int', + 'snake_case' => 'int', + 'property' => 'string', + '_123_number' => 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => 'int32', + 'snake_case' => 'int32', + 'property' => null, + '_123_number' => 'int32' + ]; + + /** + * 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 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->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['snake_case'] = isset($data['snake_case']) ? $data['snake_case'] : null; + $this->container['property'] = isset($data['property']) ? $data['property'] : null; + $this->container['_123_number'] = isset($data['_123_number']) ? $data['_123_number'] : null; + } + + /** + * 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 $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets snake_case + * + * @return int + */ + public function getSnakeCase() + { + return $this->container['snake_case']; + } + + /** + * Sets snake_case + * + * @param int $snake_case snake_case + * + * @return $this + */ + public function setSnakeCase($snake_case) + { + $this->container['snake_case'] = $snake_case; + + return $this; + } + + /** + * Gets property + * + * @return string + */ + public function getProperty() + { + return $this->container['property']; + } + + /** + * Sets property + * + * @param string $property property + * + * @return $this + */ + public function setProperty($property) + { + $this->container['property'] = $property; + + return $this; + } + + /** + * Gets _123_number + * + * @return int + */ + public function get123Number() + { + return $this->container['_123_number']; + } + + /** + * Sets _123_number + * + * @param int $_123_number _123_number + * + * @return $this + */ + public function set123Number($_123_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php new file mode 100644 index 00000000000..c88ef7f338c --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/NumberOnly.php @@ -0,0 +1,301 @@ + 'float' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'just_number' => null + ]; + + /** + * 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 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->container['just_number'] = isset($data['just_number']) ? $data['just_number'] : null; + } + + /** + * 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 + */ + public function getJustNumber() + { + return $this->container['just_number']; + } + + /** + * Sets just_number + * + * @param float $just_number just_number + * + * @return $this + */ + public function setJustNumber($just_number) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php new file mode 100644 index 00000000000..2551c35f8b4 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Order.php @@ -0,0 +1,485 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'pet_id' => 'int64', + 'quantity' => 'int32', + 'ship_date' => 'date-time', + 'status' => null, + 'complete' => null + ]; + + /** + * 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 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; + } + + const STATUS_PLACED = 'placed'; + const STATUS_APPROVED = 'approved'; + 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['pet_id'] = isset($data['pet_id']) ? $data['pet_id'] : null; + $this->container['quantity'] = isset($data['quantity']) ? $data['quantity'] : null; + $this->container['ship_date'] = isset($data['ship_date']) ? $data['ship_date'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['complete'] = isset($data['complete']) ? $data['complete'] : false; + } + + /** + * 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 for 'status', must be one of '%s'", + 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets pet_id + * + * @return int + */ + public function getPetId() + { + return $this->container['pet_id']; + } + + /** + * Sets pet_id + * + * @param int $pet_id pet_id + * + * @return $this + */ + public function setPetId($pet_id) + { + $this->container['pet_id'] = $pet_id; + + return $this; + } + + /** + * Gets quantity + * + * @return int + */ + public function getQuantity() + { + return $this->container['quantity']; + } + + /** + * Sets quantity + * + * @param int $quantity quantity + * + * @return $this + */ + public function setQuantity($quantity) + { + $this->container['quantity'] = $quantity; + + return $this; + } + + /** + * Gets ship_date + * + * @return \DateTime + */ + public function getShipDate() + { + return $this->container['ship_date']; + } + + /** + * Sets ship_date + * + * @param \DateTime $ship_date ship_date + * + * @return $this + */ + public function setShipDate($ship_date) + { + $this->container['ship_date'] = $ship_date; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status Order Status + * + * @return $this + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets complete + * + * @return bool + */ + public function getComplete() + { + return $this->container['complete']; + } + + /** + * Sets complete + * + * @param bool $complete complete + * + * @return $this + */ + public function setComplete($complete) + { + $this->container['complete'] = $complete; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php new file mode 100644 index 00000000000..17093d35f68 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterComposite.php @@ -0,0 +1,361 @@ + 'float', + 'my_string' => 'string', + 'my_boolean' => 'bool' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'my_number' => null, + 'my_string' => null, + 'my_boolean' => null + ]; + + /** + * 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 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->container['my_number'] = isset($data['my_number']) ? $data['my_number'] : null; + $this->container['my_string'] = isset($data['my_string']) ? $data['my_string'] : null; + $this->container['my_boolean'] = isset($data['my_boolean']) ? $data['my_boolean'] : null; + } + + /** + * 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 + */ + public function getMyNumber() + { + return $this->container['my_number']; + } + + /** + * Sets my_number + * + * @param float $my_number my_number + * + * @return $this + */ + public function setMyNumber($my_number) + { + $this->container['my_number'] = $my_number; + + return $this; + } + + /** + * Gets my_string + * + * @return string + */ + public function getMyString() + { + return $this->container['my_string']; + } + + /** + * Sets my_string + * + * @param string $my_string my_string + * + * @return $this + */ + public function setMyString($my_string) + { + $this->container['my_string'] = $my_string; + + return $this; + } + + /** + * Gets my_boolean + * + * @return bool + */ + public function getMyBoolean() + { + return $this->container['my_boolean']; + } + + /** + * Sets my_boolean + * + * @param bool $my_boolean my_boolean + * + * @return $this + */ + public function setMyBoolean($my_boolean) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php new file mode 100644 index 00000000000..afcef74733e --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/OuterEnum.php @@ -0,0 +1,64 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'category' => null, + 'name' => null, + 'photo_urls' => null, + 'tags' => null, + 'status' => null + ]; + + /** + * 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 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; + } + + const STATUS_AVAILABLE = 'available'; + const STATUS_PENDING = 'pending'; + 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['category'] = isset($data['category']) ? $data['category'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['photo_urls'] = isset($data['photo_urls']) ? $data['photo_urls'] : null; + $this->container['tags'] = isset($data['tags']) ? $data['tags'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + } + + /** + * 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 for 'status', must be one of '%s'", + 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets category + * + * @return \OpenAPI\Client\Model\Category + */ + public function getCategory() + { + return $this->container['category']; + } + + /** + * Sets category + * + * @param \OpenAPI\Client\Model\Category $category category + * + * @return $this + */ + public function setCategory($category) + { + $this->container['category'] = $category; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $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 $this + */ + public function setPhotoUrls($photo_urls) + { + $this->container['photo_urls'] = $photo_urls; + + return $this; + } + + /** + * Gets tags + * + * @return \OpenAPI\Client\Model\Tag[] + */ + public function getTags() + { + return $this->container['tags']; + } + + /** + * Sets tags + * + * @param \OpenAPI\Client\Model\Tag[] $tags tags + * + * @return $this + */ + public function setTags($tags) + { + $this->container['tags'] = $tags; + + return $this; + } + + /** + * Gets status + * + * @return string + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string $status pet status in the store + * + * @return $this + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + 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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php new file mode 100644 index 00000000000..792262e0a07 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/ReadOnlyFirst.php @@ -0,0 +1,331 @@ + 'string', + 'baz' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'bar' => null, + 'baz' => null + ]; + + /** + * 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 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->container['bar'] = isset($data['bar']) ? $data['bar'] : null; + $this->container['baz'] = isset($data['baz']) ? $data['baz'] : null; + } + + /** + * 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 + */ + public function getBar() + { + return $this->container['bar']; + } + + /** + * Sets bar + * + * @param string $bar bar + * + * @return $this + */ + public function setBar($bar) + { + $this->container['bar'] = $bar; + + return $this; + } + + /** + * Gets baz + * + * @return string + */ + public function getBaz() + { + return $this->container['baz']; + } + + /** + * Sets baz + * + * @param string $baz baz + * + * @return $this + */ + public function setBaz($baz) + { + $this->container['baz'] = $baz; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php new file mode 100644 index 00000000000..62bd9f5b217 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/SpecialModelName.php @@ -0,0 +1,301 @@ + 'int' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'special_property_name' => 'int64' + ]; + + /** + * 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 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->container['special_property_name'] = isset($data['special_property_name']) ? $data['special_property_name'] : null; + } + + /** + * 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 + */ + public function getSpecialPropertyName() + { + return $this->container['special_property_name']; + } + + /** + * Sets special_property_name + * + * @param int $special_property_name special_property_name + * + * @return $this + */ + public function setSpecialPropertyName($special_property_name) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php new file mode 100644 index 00000000000..d2527268cdb --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Tag.php @@ -0,0 +1,331 @@ + 'int', + 'name' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'name' => null + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets name + * + * @return string + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string $name name + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/User.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/User.php new file mode 100644 index 00000000000..a63067f4d02 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/User.php @@ -0,0 +1,511 @@ + '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[] + */ + protected static $openAPIFormats = [ + 'id' => 'int64', + 'username' => null, + 'first_name' => null, + 'last_name' => null, + 'email' => null, + 'password' => null, + 'phone' => null, + 'user_status' => 'int32' + ]; + + /** + * 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 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->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['username'] = isset($data['username']) ? $data['username'] : null; + $this->container['first_name'] = isset($data['first_name']) ? $data['first_name'] : null; + $this->container['last_name'] = isset($data['last_name']) ? $data['last_name'] : null; + $this->container['email'] = isset($data['email']) ? $data['email'] : null; + $this->container['password'] = isset($data['password']) ? $data['password'] : null; + $this->container['phone'] = isset($data['phone']) ? $data['phone'] : null; + $this->container['user_status'] = isset($data['user_status']) ? $data['user_status'] : null; + } + + /** + * 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 + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param int $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets username + * + * @return string + */ + public function getUsername() + { + return $this->container['username']; + } + + /** + * Sets username + * + * @param string $username username + * + * @return $this + */ + public function setUsername($username) + { + $this->container['username'] = $username; + + return $this; + } + + /** + * Gets first_name + * + * @return string + */ + public function getFirstName() + { + return $this->container['first_name']; + } + + /** + * Sets first_name + * + * @param string $first_name first_name + * + * @return $this + */ + public function setFirstName($first_name) + { + $this->container['first_name'] = $first_name; + + return $this; + } + + /** + * Gets last_name + * + * @return string + */ + public function getLastName() + { + return $this->container['last_name']; + } + + /** + * Sets last_name + * + * @param string $last_name last_name + * + * @return $this + */ + public function setLastName($last_name) + { + $this->container['last_name'] = $last_name; + + return $this; + } + + /** + * Gets email + * + * @return string + */ + public function getEmail() + { + return $this->container['email']; + } + + /** + * Sets email + * + * @param string $email email + * + * @return $this + */ + public function setEmail($email) + { + $this->container['email'] = $email; + + return $this; + } + + /** + * Gets password + * + * @return string + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string $password password + * + * @return $this + */ + public function setPassword($password) + { + $this->container['password'] = $password; + + return $this; + } + + /** + * Gets phone + * + * @return string + */ + public function getPhone() + { + return $this->container['phone']; + } + + /** + * Sets phone + * + * @param string $phone phone + * + * @return $this + */ + public function setPhone($phone) + { + $this->container['phone'] = $phone; + + return $this; + } + + /** + * Gets user_status + * + * @return int + */ + public function getUserStatus() + { + return $this->container['user_status']; + } + + /** + * Sets user_status + * + * @param int $user_status User Status + * + * @return $this + */ + public function setUserStatus($user_status) + { + $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) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php new file mode 100644 index 00000000000..25262d1d07f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -0,0 +1,317 @@ +format('Y-m-d') : $data->format(\DateTime::ATOM); + } elseif (is_array($data)) { + foreach ($data as $property => $value) { + $data[$property] = self::sanitizeForSerialization($value); + } + return $data; + } elseif (is_object($data)) { + $values = []; + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($openAPIType, 'getAllowableEnumValues') + && !in_array($value, $openAPIType::getAllowableEnumValues())) { + $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } + } + 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; + } + } + + /** + * 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)); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. + * + * @param string[]|string|\DateTime $object an object to be serialized to a string + * + * @return string the serialized object + */ + public static function toQueryValue($object) + { + if (is_array($object)) { + return implode(',', $object); + } else { + return self::toString($object); + } + } + + /** + * 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) + { + 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 + * + * @param string|\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(\DateTime::ATOM); + } else { + return $value; + } + } + + /** + * Serialize an array to a string. + * + * @param array $collection collection to serialize to a string + * @param string $collectionFormat 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, $collectionFormat, $allowCollectionFormatMulti = false) + { + if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) { + // 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 ($collectionFormat) { + case 'pipes': + return implode('|', $collection); + + case 'tsv': + return implode("\t", $collection); + + case 'ssv': + return implode(' ', $collection); + + 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 + * @param string $discriminator discriminator if polymorphism is used + * + * @return object|array|null an single or an array of $class instances + */ + public static function deserialize($data, $class, $httpHeaders = null) + { + if (null === $data) { + return null; + } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] + $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; + } elseif (strcasecmp(substr($class, -2), '[]') === 0) { + $subClass = substr($class, 0, -2); + $values = []; + foreach ($data as $key => $value) { + $values[] = self::deserialize($value, $subClass, null); + } + return $values; + } elseif ($class === 'object') { + settype($data, 'array'); + return $data; + } elseif ($class === '\DateTime') { + // Some API's 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)) { + return new \DateTime($data); + } else { + return null; + } + } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { + settype($data, $class); + return $data; + } elseif ($class === '\SplFileObject') { + /** @var \Psr\Http\Message\StreamInterface $data */ + + // determine file name + if (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'); + } elseif (method_exists($class, 'getAllowableEnumValues')) { + if (!in_array($data, $class::getAllowableEnumValues())) { + $imploded = implode("', '", $class::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); + } + return $data; + } else { + // 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; + } + } + $instance = new $class(); + foreach ($instance::openAPITypes() as $property => $type) { + $propertySetter = $instance::setters()[$property]; + + if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) { + continue; + } + + $propertyValue = $data->{$instance::attributeMap()[$property]}; + if (isset($propertyValue)) { + $instance->$propertySetter(self::deserialize($propertyValue, $type, null)); + } + } + return $instance; + } + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist b/samples/openapi3/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist new file mode 100644 index 00000000000..c12ee148477 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./test/Api + ./test/Model + + + + + + ./lib/Api + ./lib/Model + + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php similarity index 87% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php index 2fb493e741f..751ae065157 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/AnotherFakeApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * AnotherFakeApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php similarity index 92% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php index 19261c6cb4f..f0b58e99910 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * FakeApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php similarity index 87% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php index 3d39e6d42f9..3b055d126dc 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/FakeClassnameTags123ApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/FakeClassnameTags123ApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * FakeClassnameTags123ApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php similarity index 91% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php index f4ce9e18e45..e3ff5eb1047 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/PetApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/PetApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * PetApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php similarity index 89% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php index 20e6e2bbb55..b01601ddaf7 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/StoreApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/StoreApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * StoreApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php similarity index 92% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php index 7d1f2031be2..abcb622dabe 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Api/UserApiTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/UserApiTest.php @@ -4,7 +4,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -26,17 +26,17 @@ * Please update the test case below to test the endpoint. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; -use \OpenAPITools\Client\Configuration; -use \OpenAPITools\Client\ApiException; -use \OpenAPITools\Client\ObjectSerializer; +use \OpenAPI\Client\Configuration; +use \OpenAPI\Client\ApiException; +use \OpenAPI\Client\ObjectSerializer; /** * UserApiTest Class Doc Comment * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php index 954b1ef159f..84c4cd39362 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AdditionalPropertiesClassTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AdditionalPropertiesClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AdditionalPropertiesClassTest Class Doc Comment * * @category Class * @description AdditionalPropertiesClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php index 9df0d2347c4..adc12bb876f 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalFarmTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalFarmTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AnimalFarmTest Class Doc Comment * * @category Class * @description AnimalFarm - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php index 166bf161ce3..7056d16b0cf 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/AnimalTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/AnimalTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * AnimalTest Class Doc Comment * * @category Class * @description Animal - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php index d0f02fcea88..0c00ef8cb47 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ApiResponseTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ApiResponseTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ApiResponseTest Class Doc Comment * * @category Class * @description ApiResponse - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php index 86001b65197..5a5147cffa1 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfArrayOfNumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayOfArrayOfNumberOnlyTest Class Doc Comment * * @category Class * @description ArrayOfArrayOfNumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php index 4e02d0525fc..a53cb832bca 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayOfNumberOnlyTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayOfNumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayOfNumberOnlyTest Class Doc Comment * * @category Class * @description ArrayOfNumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php index 737e4c9874f..fa2f37a58fa 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ArrayTestTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ArrayTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ArrayTestTest Class Doc Comment * * @category Class * @description ArrayTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php index 96698110920..f7acf13d262 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CapitalizationTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CapitalizationTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CapitalizationTest Class Doc Comment * * @category Class * @description Capitalization - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php index 5db87d38e66..5cc579ed177 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/CatTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CatTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CatTest Class Doc Comment * * @category Class * @description Cat - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php index bd41a94f3b9..8dd7c9200c7 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/CategoryTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/CategoryTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * CategoryTest Class Doc Comment * * @category Class * @description Category - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php index e0560988f7b..5d9a0f9014e 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClassModelTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClassModelTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ClassModelTest Class Doc Comment * * @category Class * @description Model for testing model with \"_class\" property - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php index 3567c068a45..b9d9b8c5260 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ClientTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ClientTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ClientTest Class Doc Comment * * @category Class * @description Client - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php index 4075a3b85bd..99256d561ff 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/DogTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/DogTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * DogTest Class Doc Comment * * @category Class * @description Dog - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php index d3b933748cd..a01055a8cec 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumArraysTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumArraysTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumArraysTest Class Doc Comment * * @category Class * @description EnumArrays - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php index 36175d90760..7f7cd925493 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumClassTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumClassTest Class Doc Comment * * @category Class * @description EnumClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php index 28dfd5af5be..1e5770584cf 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/EnumTestTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/EnumTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * EnumTestTest Class Doc Comment * * @category Class * @description EnumTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php similarity index 96% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php index 40581f4dc58..269bbfa9983 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/FormatTestTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/FormatTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * FormatTestTest Class Doc Comment * * @category Class * @description FormatTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php index 712ac2f1fb0..ee9f4c59594 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/HasOnlyReadOnlyTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/HasOnlyReadOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * HasOnlyReadOnlyTest Class Doc Comment * * @category Class * @description HasOnlyReadOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php index 5d7e83b8617..fb850048e9c 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MapTestTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MapTestTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * MapTestTest Class Doc Comment * * @category Class * @description MapTest - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php index 2f9b49dd212..2d1e95c5032 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/MixedPropertiesAndAdditionalPropertiesClassTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * MixedPropertiesAndAdditionalPropertiesClassTest Class Doc Comment * * @category Class * @description MixedPropertiesAndAdditionalPropertiesClass - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php index df20e34bb3f..a963bcae3be 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/Model200ResponseTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Model200ResponseTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * Model200ResponseTest Class Doc Comment * * @category Class * @description Model for testing model name starting with number - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php index 492bec1a03b..d24dc028525 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelListTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelListTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ModelListTest Class Doc Comment * * @category Class * @description ModelList - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php index 3a743e83cbe..ad55c38b56d 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ModelReturnTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ModelReturnTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ModelReturnTest Class Doc Comment * * @category Class * @description Model for testing reserved words - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php similarity index 94% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php index 040dddabd1a..fef59be669a 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NameTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NameTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * NameTest Class Doc Comment * * @category Class * @description Model for testing model name same as property name - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php index a06ccb1e84c..3ec1911c053 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/NumberOnlyTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/NumberOnlyTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * NumberOnlyTest Class Doc Comment * * @category Class * @description NumberOnly - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php similarity index 95% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php index 3d5cafb7d15..56e3f10930e 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OrderTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OrderTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OrderTest Class Doc Comment * * @category Class * @description Order - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php index 771a03c8c85..f8cc46983b3 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterCompositeTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterCompositeTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OuterCompositeTest Class Doc Comment * * @category Class * @description OuterComposite - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php similarity index 93% rename from samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php index 83b56d68154..db909de55fe 100644 --- a/samples/client/petstore/php/OpenAPIToolsClient-php/test/Model/OuterEnumTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/OuterEnumTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * OuterEnumTest Class Doc Comment * * @category Class * @description OuterEnum - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php index 4eb71836195..7d33e91cdf9 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/PetTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/PetTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * PetTest Class Doc Comment * * @category Class * @description Pet - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php index 022a7d746e0..afad4d62ad0 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/ReadOnlyFirstTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/ReadOnlyFirstTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * ReadOnlyFirstTest Class Doc Comment * * @category Class * @description ReadOnlyFirst - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php index ef19680ba36..713d2acd05f 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/SpecialModelNameTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/SpecialModelNameTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * SpecialModelNameTest Class Doc Comment * * @category Class * @description SpecialModelName - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php similarity index 94% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php index f8c2bc2ce30..e37e3aabec4 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/TagTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/TagTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * TagTest Class Doc Comment * * @category Class * @description Tag - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php similarity index 95% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php index d22b6f3e957..20adea143e1 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/test/Model/UserTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/UserTest.php @@ -5,7 +5,7 @@ * PHP version 5 * * @category Class - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ @@ -27,14 +27,14 @@ * Please update the test case below to test the model. */ -namespace OpenAPITools\Client; +namespace OpenAPI\Client; /** * UserTest Class Doc Comment * * @category Class * @description User - * @package OpenAPITools\Client + * @package OpenAPI\Client * @author OpenAPI Generator team * @link https://openapi-generator.tech */ diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php new file mode 100644 index 00000000000..0ac3ad36ada --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AsyncTest.php @@ -0,0 +1,85 @@ +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->assertInternalType('array', $headers); + $this->assertInstanceOf(Pet::class, $pet); + } + + public function testAsyncThrowingException() + { + $this->setExpectedException(ApiException::class); + + $promise = $this->api->getPetByIdAsync(0); + $promise->wait(); + } + + public function testAsyncApiExceptionWithoutWaitIsNotThrown() + { + $promise = $this->api->getPetByIdAsync(0); + sleep(1); + } + + public function testAsyncHttpInfoThrowingException() + { + $this->setExpectedException(ApiException::class); + + $promise = $this->api->getPetByIdAsyncWithHttpInfo(0); + $promise->wait(); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AuthTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AuthTest.php new file mode 100644 index 00000000000..271c13fa39a --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/AuthTest.php @@ -0,0 +1,62 @@ +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()); + + $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/openapi3/client/petstore/php/OpenAPIClient-php/tests/DateTimeSerializerTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/DateTimeSerializerTest.php new file mode 100644 index 00000000000..288f491f67e --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/DateTimeSerializerTest.php @@ -0,0 +1,34 @@ + $dateTime, + ]); + + $data = ObjectSerializer::sanitizeForSerialization($input); + + $this->assertEquals($data->dateTime, '1973-04-30T17:05:00+02:00'); + } + + public function testDateSanitazion() + { + $dateTime = new \DateTime('April 30, 1973 17:05 CEST'); + + $input = new FormatTest([ + 'date' => $dateTime, + ]); + + $data = ObjectSerializer::sanitizeForSerialization($input); + + $this->assertEquals($data->date, '1973-04-30'); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/DebugTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php similarity index 96% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/DebugTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php index a0168a37eca..1f3b7c1e7b9 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/DebugTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/DebugTest.php @@ -1,5 +1,5 @@ assertSame(EnumClass::ABC, '_abc'); + $this->assertSame(EnumClass::EFG, '-efg'); + $this->assertSame(EnumClass::XYZ, '(xyz)'); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumTestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/EnumTestTest.php similarity index 93% rename from samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumTestTest.php rename to samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/EnumTestTest.php index 9d9897fc626..67ed4d93311 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIToolsClient-php/tests/EnumTestTest.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/EnumTestTest.php @@ -1,8 +1,8 @@ setHost('http://petstore.swagger.io/INVALID_URL'); + + $api = new Api\StoreApi( + new Client(), + $config + ); + $api->getInventory(); + } + + /** + * @expectedException \OpenAPI\Client\ApiException + * @expectedExceptionMessage Could not resolve host + */ + public function testWrongHost() + { + $config = new Configuration(); + $config->setHost('http://wrong_host.zxc'); + + $api = new Api\StoreApi( + new Client(), + $config + ); + $api->getInventory(); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php new file mode 100644 index 00000000000..d93b8f8b0b3 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/FakeHttpClient.php @@ -0,0 +1,69 @@ +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 = []) + { + $this->request = $request; + return $this->response ?: new Response(200); + } + + public function sendAsync(RequestInterface $request, array $options = []) + { + throw new \RuntimeException('not implemented'); + } + + public function request($method, $uri, array $options = []) + { + throw new \RuntimeException('not implemented'); + } + + public function requestAsync($method, $uri, array $options = []) + { + throw new \RuntimeException('not implemented'); + } + + public function getConfig($option = null) + { + throw new \RuntimeException('not implemented'); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php new file mode 100644 index 00000000000..89ee7a8df15 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeaderSelectorTest.php @@ -0,0 +1,56 @@ +selectHeaders([ + 'application/xml', + 'application/json' + ], []); + $this->assertSame('application/json', $headers['Accept']); + + $headers = $selector->selectHeaders([], []); + $this->assertArrayNotHasKey('Accept', $headers); + + $header = $selector->selectHeaders([ + 'application/yaml', + 'application/xml' + ], []); + $this->assertSame('application/yaml,application/xml', $header['Accept']); + + // test selectHeaderContentType + $headers = $selector->selectHeaders([], [ + 'application/xml', + 'application/json' + ]); + $this->assertSame('application/json', $headers['Content-Type']); + + $headers = $selector->selectHeaders([], []); + $this->assertSame('application/json', $headers['Content-Type']); + $headers = $selector->selectHeaders([], [ + 'application/yaml', + 'application/xml' + ]); + $this->assertSame('application/yaml,application/xml', $headers['Content-Type']); + } + + public function testSelectingHeadersForMultipartBody() + { + // test selectHeaderAccept + $selector = new HeaderSelector(); + $headers = $selector->selectHeadersForMultipart([ + 'application/xml', + 'application/json' + ]); + $this->assertSame('application/json', $headers['Accept']); + $this->assertArrayNotHasKey('Content-Type', $headers); + + $headers = $selector->selectHeadersForMultipart([]); + $this->assertArrayNotHasKey('Accept', $headers); + $this->assertArrayNotHasKey('Content-Type', $headers); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeadersTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeadersTest.php new file mode 100644 index 00000000000..7d3816fe844 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/HeadersTest.php @@ -0,0 +1,31 @@ +fakeHttpClient = new FakeHttpClient(); + } + + public function testUserAgent() + { + $config = new Configuration(); + $config->setUserAgent('value'); + $api = new Api\PetApi($this->fakeHttpClient, $config); + + $api->getPetById(3); + + $request = $this->fakeHttpClient->getLastRequest(); + $headers = $request->getHeaders(); + + $this->assertArrayHasKey('User-Agent', $headers); + $this->assertEquals(['value'], $headers['User-Agent']); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ModelInheritanceTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ModelInheritanceTest.php new file mode 100644 index 00000000000..0b802a62f8f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ModelInheritanceTest.php @@ -0,0 +1,96 @@ +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 AnimalFarm which is an object implementing the ArrayAccess interface + $farm = new AnimalFarm(); + + // 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/openapi3/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php new file mode 100644 index 00000000000..c65dbdc3e38 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ObjectSerializerTest.php @@ -0,0 +1,25 @@ +assertSame("sun.gif", $s->sanitizeFilename("sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename("../sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename("/var/tmp/sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename("./sun.gif")); + + $this->assertSame("sun", $s->sanitizeFilename("sun")); + $this->assertSame("sun.gif", $s->sanitizeFilename("..\sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename("\var\tmp\sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename("c:\var\tmp\sun.gif")); + $this->assertSame("sun.gif", $s->sanitizeFilename(".\sun.gif")); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OrderApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OrderApiTest.php new file mode 100644 index 00000000000..e5839eeabf3 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OrderApiTest.php @@ -0,0 +1,133 @@ +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()); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testOrderException() + { + // initialize the API client + $order = new Model\Order(); + $order->setStatus("invalid_value"); + } + + // test deseralization 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 deseralization 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 deseralization 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()); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php new file mode 100644 index 00000000000..862832ca0a8 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/OuterEnumTest.php @@ -0,0 +1,94 @@ +assertInternalType('string', $result); + $this->assertEquals('placed', $result); + } + + public function testDeserializeInvalidValue() + { + $this->setExpectedException(\InvalidArgumentException::class, '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->assertInternalType('string', $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->assertInternalType('object', $result); + $this->assertInstanceOf(\stdClass::class, $result); + + $this->assertInternalType('string', $result->outerEnum); + $this->assertEquals('approved', $result->outerEnum); + } + + public function testSanitizeNestedInvalidValue() + { + $this->setExpectedException(\InvalidArgumentException::class, '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/openapi3/client/petstore/php/OpenAPIClient-php/tests/ParametersTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ParametersTest.php new file mode 100644 index 00000000000..25ba7d90d56 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ParametersTest.php @@ -0,0 +1,65 @@ +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($param); + + $request = $this->fakeHttpClient->getLastRequest(); + $this->assertSame('{"foo":"bar"}', $request->getBody()->getContents()); + } + +// 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/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php new file mode 100644 index 00000000000..97469118070 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetApiTest.php @@ -0,0 +1,390 @@ +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); + \PHPUnit_Framework_Assert::assertEquals(200, $status); + } + + public function setUp() + { + $this->api = new Api\PetApi(); + } + + public function testGetPetById() + { + $petId = 10005; + + $pet = $this->api->getPetById($petId); + $this->assertSame($pet->getId(), $petId); + $this->assertSame($pet->getName(), 'PHP Unit Test'); + $this->assertSame($pet->getPhotoUrls()[0], 'http://test_php_unit_test.com'); + $this->assertSame($pet->getCategory()->getId(), $petId); + $this->assertSame($pet->getCategory()->getName(), 'test php category'); + $this->assertSame($pet->getTags()[0]->getId(), $petId); + $this->assertSame($pet->getTags()[0]->getName(), 'test php tag'); + } + + /** + * 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($pet->getId(), $petId); + $this->assertSame($pet->getName(), 'PHP Unit Test'); + $this->assertSame($pet->getCategory()->getId(), $petId); + $this->assertSame($pet->getCategory()->getName(), 'test php category'); + $this->assertSame($pet->getTags()[0]->getId(), $petId); + $this->assertSame($pet->getTags()[0]->getName(), 'test php tag'); + $this->assertSame($status_code, 200); + $this->assertSame($response_headers['Content-Type'], ['application/json']); + } + + public function testFindPetByStatus() + { + $response = $this->api->findPetsByStatus('available'); + $this->assertGreaterThan(0, count($response)); // at least one object returned + + $this->assertSame(get_class($response[0]), Pet::class); // verify the object is Pet + foreach ($response as $pet) { + $this->assertSame($pet['status'], 'available'); + } + + $response = $this->api->findPetsByStatus('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'); + $result = $this->api->updatePet($updatedPet); + $this->assertNull($result); + + // verify updated Pet + $result = $this->api->getPetById($petId); + $this->assertSame($result->getId(), $petId); + $this->assertSame($result->getStatus(), 'pending'); + $this->assertSame($result->getName(), 'updatePet'); + } + + // 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($status_code, 200); + $this->assertSame($http_headers['Content-Type'], ['application/json']); + $response = $this->api->getPetById($petId); + $this->assertSame($response->getId(), $petId); + $this->assertSame($response->getName(), 'update pet with form with http info'); + } + + // 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($response->getId(), $pet_id); + $this->assertSame($response->getName(), 'update pet with form'); + $this->assertSame($response->getStatus(), 'sold'); + } + + // 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"); + + // 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($response->getId(), $new_pet_id); + $this->assertSame($response->getName(), 'PHP Unit Test 2'); + } + + /* + * 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 empty object serialization + public function testEmptyPetSerialization() + { + $new_pet = new Model\Pet; + // the empty object should be serialised to {} + $this->assertSame("{}", "$new_pet"); + } + + // 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 AnimalFarm which is an object implementing the + // ArrayAccess interface + $farm = new Model\AnimalFarm(); + + // 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 + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Missing the required parameter $status when calling findPetsByStatus + */ + public function testInvalidArgument() + { + // the argument is required, and we must specify one or some from 'available', 'pending', 'sold' + $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/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetTest.php new file mode 100644 index 00000000000..5e4a3f2a195 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/PetTest.php @@ -0,0 +1,18 @@ +assertSame("{}", "$new_pet"); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/RequestTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/RequestTest.php new file mode 100644 index 00000000000..820a6df3a4b --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/RequestTest.php @@ -0,0 +1,35 @@ +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/openapi3/client/petstore/php/OpenAPIClient-php/tests/ResponseTypesTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ResponseTypesTest.php new file mode 100644 index 00000000000..5735221fb79 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/ResponseTypesTest.php @@ -0,0 +1,95 @@ +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); + } + + /** + * @expectedException \OpenAPI\Client\ApiException + * @expectedExceptionCode 400 + */ + public function testDefinedErrorException() + { + $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); +// } + + /** + * @expectedException \OpenAPI\Client\ApiException + * @expectedExceptionCode 404 + */ + public function testDefaultErrorException() + { + $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/openapi3/client/petstore/php/OpenAPIClient-php/tests/StoreApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/StoreApiTest.php new file mode 100644 index 00000000000..610281d4db4 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/StoreApiTest.php @@ -0,0 +1,56 @@ +api = new StoreApi(); + } + + /** + * Setup before running each test case + */ + public static function setUpBeforeClass() + { + // 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->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->assertInternalType('array', $result); + $this->assertInternalType('int', $result['available']); + } +} diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/UserApiTest.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/UserApiTest.php new file mode 100644 index 00000000000..c9d5753db95 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/tests/UserApiTest.php @@ -0,0 +1,32 @@ +api = new Api\UserApi(); + } + + // test login use + public function testLoginUser() + { + // initialize the API client + // login + $response = $this->api->loginUser('xxxxx', 'yyyyyyyy'); + + $this->assertInternalType('string', $response); + $this->assertRegExp( + '/^logged in user session/', + $response, + "response string starts with 'logged in user session'" + ); + } +}