diff --git a/bin/openapi3/security/php-petstore.sh b/bin/openapi3/security/php-petstore.sh index 46f7d469451..bdeadc96e22 100755 --- a/bin/openapi3/security/php-petstore.sh +++ b/bin/openapi3/security/php-petstore.sh @@ -33,6 +33,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/client/petstore-security-test/php $@" +ags="generate -t modules/openapi-generator/src/main/resources/php -i modules/openapi-generator/src/test/resources/3_0/petstore-security-test.yaml -g php -o samples/openapi3/client/petstore-security-test/php/OpenAPIClient-php $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/openapi3/security/windows/php-petstore.bat b/bin/openapi3/security/windows/php-petstore.bat new file mode 100644 index 00000000000..6e83022255c --- /dev/null +++ b/bin/openapi3/security/windows/php-petstore.bat @@ -0,0 +1,10 @@ +set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M +set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-security-test.yaml -g php -o samples\openapi3\client\petstore-security-test\php\OpenAPIClient-php + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/bin/openapi3/windows/php-petstore.bat b/bin/openapi3/windows/php-petstore.bat new file mode 100644 index 00000000000..edd5e5c45ea --- /dev/null +++ b/bin/openapi3/windows/php-petstore.bat @@ -0,0 +1,10 @@ +set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M +set ags=generate -i modules\openapi-generator\src\test\resources\3_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples\openapi3\client\petstore\php\OpenAPIClient-php + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/bin/security/windows/php-petstore.bat b/bin/security/windows/php-petstore.bat new file mode 100644 index 00000000000..a23c42fed82 --- /dev/null +++ b/bin/security/windows/php-petstore.bat @@ -0,0 +1,10 @@ +set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M +set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-security-test.yaml -g php -o samples\client\petstore-security-test\php\OpenAPIClient-php + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/bin/windows/php-petstore.bat b/bin/windows/php-petstore.bat index dc420067232..ba088beade2 100755 --- a/bin/windows/php-petstore.bat +++ b/bin/windows/php-petstore.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g php -o samples\client\petstore\php\OpenAPIClient-php +set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g php -o samples\client\petstore\php\OpenAPIClient-php java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 7a9ee0114b1..6fac0d07488 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -581,7 +581,7 @@ use {{invokerPackage}}\ObjectSerializer; {{#isBasic}} {{^isBasicBearer}} // this endpoint requires HTTP basic authentication - if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } {{/isBasicBearer}} diff --git a/samples/client/petstore-security-test/php/.gitignore b/samples/client/petstore-security-test/php/.gitignore deleted file mode 100644 index edcf63f6aee..00000000000 --- a/samples/client/petstore-security-test/php/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore - -composer.phar -/vendor/ - -# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control -# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file -composer.lock \ No newline at end of file diff --git a/samples/client/petstore-security-test/php/.openapi-generator-ignore b/samples/client/petstore-security-test/php/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a3..00000000000 --- a/samples/client/petstore-security-test/php/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/samples/client/petstore-security-test/php/.php_cs b/samples/client/petstore-security-test/php/.php_cs deleted file mode 100644 index 4fbe53ec5ff..00000000000 --- a/samples/client/petstore-security-test/php/.php_cs +++ /dev/null @@ -1,23 +0,0 @@ -setUsingCache(true) - ->setRules([ - '@PSR2' => true, - 'ordered_imports' => true, - 'phpdoc_order' => true, - 'array_syntax' => [ 'syntax' => 'short' ], - 'strict_comparison' => true, - 'strict_param' => true, - 'no_trailing_whitespace' => false, - 'no_trailing_whitespace_in_comment' => false, - 'braces' => false, - 'single_blank_line_at_eof' => false, - 'blank_line_after_namespace' => false, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('test') - ->exclude('tests') - ->in(__DIR__) - ); diff --git a/samples/client/petstore-security-test/php/.travis.yml b/samples/client/petstore-security-test/php/.travis.yml deleted file mode 100644 index d77f3825f6f..00000000000 --- a/samples/client/petstore-security-test/php/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -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-security-test/php/LICENSE b/samples/client/petstore-security-test/php/LICENSE deleted file mode 100644 index 8dada3edaf5..00000000000 --- a/samples/client/petstore-security-test/php/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION b/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION index d077ffb477a..afa63656064 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.4-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md b/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md index 5322ee7822a..e7a0065856d 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/README.md @@ -56,15 +56,17 @@ Please follow the [installation procedure](#installation--usage) and then run th testCodeInjectEndRnNR($unknown_base_type); + $apiInstance->testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); } catch (Exception $e) { echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; } @@ -95,14 +97,15 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key */ ' " =end -- \r\n \n \r - **Location**: HTTP header + ## petstore_auth - **Type**: OAuth - **Flow**: implicit - **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog - **Scopes**: - - **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r - - **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r +- **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r +- **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r ## Author diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json b/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json index 8d2abc121eb..df2e7f52710 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json @@ -4,12 +4,13 @@ "keywords": [ "openapitools", "openapi-generator", + "openapi", "php", "sdk", "rest", "api" ], - "homepage": "http://openapi-generator.tech", + "homepage": "https://openapi-generator.tech", "license": "proprietary", "authors": [ { diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md b/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md index afee7db1162..532dc2ff511 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/docs/Api/FakeApi.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **testCodeInjectEndRnNR** -> testCodeInjectEndRnNR($unknown_base_type) +> testCodeInjectEndRnNR($test_code_inject____end____rn_n_r) To test code injection *_/ ' \" =end -- \\r\\n \\n \\r @@ -19,15 +19,16 @@ To test code injection *_/ ' \" =end -- \\r\\n \\n \\r testCodeInjectEndRnNR($unknown_base_type); + $apiInstance->testCodeInjectEndRnNR($test_code_inject____end____rn_n_r); } catch (Exception $e) { echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; } @@ -38,7 +39,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **unknown_base_type** | [**\OpenAPI\Client\Model\UNKNOWN_BASE_TYPE**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] + **test_code_inject____end____rn_n_r** | **string**| To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r | [optional] ### Return type @@ -50,7 +51,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json, *_/ \" =end -- + - **Content-Type**: application/x-www-form-urlencoded, *_/ \" =end -- - **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-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php index d210ab40797..c236e10d9e3 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** @@ -64,19 +64,47 @@ class FakeApi */ protected $headerSelector; + /** + * @var int Host index + */ + protected $hostIndex; + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector + * @param int $host_index (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, - HeaderSelector $selector = null + HeaderSelector $selector = null, + $host_index = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; } /** @@ -92,15 +120,15 @@ class FakeApi * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type unknown_base_type (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException * @return void */ - public function testCodeInjectEndRnNR($unknown_base_type = null) + public function testCodeInjectEndRnNR($test_code_inject____end____rn_n_r = null) { - $this->testCodeInjectEndRnNRWithHttpInfo($unknown_base_type); + $this->testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn_n_r); } /** @@ -108,15 +136,15 @@ class FakeApi * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (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 testCodeInjectEndRnNRWithHttpInfo($unknown_base_type = null) + public function testCodeInjectEndRnNRWithHttpInfo($test_code_inject____end____rn_n_r = null) { - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); + $request = $this->testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n_r); try { $options = $this->createHttpClientOption(); @@ -160,14 +188,14 @@ class FakeApi * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testCodeInjectEndRnNRAsync($unknown_base_type = null) + public function testCodeInjectEndRnNRAsync($test_code_inject____end____rn_n_r = null) { - return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type) + return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end____rn_n_r) ->then( function ($response) { return $response[0]; @@ -180,15 +208,15 @@ class FakeApi * * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type = null) + public function testCodeInjectEndRnNRAsyncWithHttpInfo($test_code_inject____end____rn_n_r = null) { $returnType = ''; - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); + $request = $this->testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n_r); return $this->client ->sendAsync($request, $this->createHttpClientOption()) @@ -216,12 +244,12 @@ class FakeApi /** * Create request for operation 'testCodeInjectEndRnNR' * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) + * @param string $test_code_inject____end____rn_n_r To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - protected function testCodeInjectEndRnNRRequest($unknown_base_type = null) + protected function testCodeInjectEndRnNRRequest($test_code_inject____end____rn_n_r = null) { $resourcePath = '/fake'; @@ -233,11 +261,12 @@ class FakeApi + // form params + if ($test_code_inject____end____rn_n_r !== null) { + $formParams['test code inject */ ' " =end -- \r\n \n \r'] = ObjectSerializer::toFormValue($test_code_inject____end____rn_n_r); + } // body params $_tempBody = null; - if (isset($unknown_base_type)) { - $_tempBody = $unknown_base_type; - } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( @@ -246,7 +275,7 @@ class FakeApi } else { $headers = $this->headerSelector->selectHeaders( [], - ['application/json', '*_/ \" =end --'] + ['application/x-www-form-urlencoded', '*_/ \" =end --'] ); } diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php index 85d35f83630..791ed3d05cb 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php index efcacba885d..b6c6f003810 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** @@ -56,7 +56,7 @@ class Configuration protected $apiKeyPrefixes = []; /** - * Access token for OAuth + * Access token for OAuth/Bearer authentication * * @var string */ @@ -426,4 +426,59 @@ class Configuration return $keyWithPrefix; } + + /** + * Returns an array of host settings + * + * @return an array of host settings + */ + public function getHostSettings() + { + return array( + array( + "url" => "//petstore.swagger.io */ ' " =end -- \r\n \n \r/v2 */ ' " =end -- \r\n \n \r", + "description" => "No description provided", + ) + ); + } + + /** + * Returns URL based on the index and variables + * + * @param index array index of the host settings + * @param variables hash of variable and the corresponding value (optional) + * @return URL based on host settings + */ + public function getHostFromSettings($index, $variables = null) + { + if (null === $variables) { + $variables = array(); + } + + $hosts = $this->getHostSettings(); + + // check array index out of bound + if ($index < 0 || $index >= sizeof($hosts)) { + throw new \InvalidArgumentException("Invalid index $index when selecting the host. Must be less than ".sizeof($hosts)); + } + + $host = $hosts[$index]; + $url = $host["url"]; + + // go through variable and assign a value + foreach ($host["variables"] as $name => $variable) { + if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user + if (in_array($variables[$name], $variable["enum_values"])) { // check to see if the value is in the enum + $url = str_replace("{".$name."}", $variables[$name], $url); + } else { + throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"])."."); + } + } else { + // use default value + $url = str_replace("{".$name."}", $variable["default_value"], $url); + } + } + + return $url; + } } diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php index a08d9d4a0e5..d2b74b6489e 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php index 4b4c7449706..227a7d0021b 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php index ada5d2e2154..82d23d55660 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php index c7da9e2f345..6395ea58aa3 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.4-SNAPSHOT + * OpenAPI Generator version: 4.0.0-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/.php_cs b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/.php_cs deleted file mode 100644 index 6b8e23c818a..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/.php_cs +++ /dev/null @@ -1,18 +0,0 @@ -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-security-test/php/OpenAPIToolsClient-php/.travis.yml b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/.travis.yml deleted file mode 100644 index d77f3825f6f..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -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-security-test/php/OpenAPIToolsClient-php/README.md b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/README.md deleted file mode 100644 index b65a011db11..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# OpenAPIToolsClient-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: \" \\ *_/ ' \" =end -- - -This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r -- 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/OpenAPIToolsClient-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 -testCodeInjectEndRnNR($unknown_base_type); -} catch (Exception $e) { - echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; -} - -?> -``` - -## Documentation for API Endpoints - -All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*FakeApi* | [**testCodeInjectEndRnNR**](docs/Api/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - - -## Documentation For Models - - - [ModelReturn](docs/Model/ModelReturn.md) - - -## Documentation For Authorization - - -## api_key - -- **Type**: API key -- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r -- **Location**: HTTP header - -## petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r - - **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r - - -## Author - -something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r - - diff --git a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/composer.json b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/composer.json deleted file mode 100644 index 2991dfef929..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/composer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "GIT_USER_ID/GIT_REPO_ID", - "description": "", - "keywords": [ - "openapitools", - "php", - "sdk", - "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": { "OpenAPITools\\Client\\" : "lib/" } - }, - "autoload-dev": { - "psr-4": { "OpenAPITools\\Client\\" : "test/" } - } -} diff --git a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/docs/Api/FakeApi.md b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/docs/Api/FakeApi.md deleted file mode 100644 index 6b4ab35a1e8..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/docs/Api/FakeApi.md +++ /dev/null @@ -1,55 +0,0 @@ -# OpenAPITools\Client\FakeApi - -All URIs are relative to *petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**testCodeInjectEndRnNR**](FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - - -# **testCodeInjectEndRnNR** -> testCodeInjectEndRnNR($unknown_base_type) - -To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - -### Example -```php -testCodeInjectEndRnNR($unknown_base_type); -} catch (Exception $e) { - echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **unknown_base_type** | [**object**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] - -### Return type - -void (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json, *_/ \" =end -- - - **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-security-test/php/OpenAPIToolsClient-php/git_push.sh b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/git_push.sh deleted file mode 100644 index 20057f67ade..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/git_push.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/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-security-test/php/OpenAPIToolsClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Api/FakeApi.php deleted file mode 100644 index cbdef6d970f..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Api/FakeApi.php +++ /dev/null @@ -1,322 +0,0 @@ -client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); - $this->headerSelector = $selector ?: new HeaderSelector(); - } - - /** - * @return Configuration - */ - public function getConfig() - { - return $this->config; - } - - /** - * Operation testCodeInjectEndRnNR - * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param object $unknown_base_type unknown_base_type (optional) - * - * @throws \OpenAPITools\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return void - */ - public function testCodeInjectEndRnNR($unknown_base_type = null) - { - $this->testCodeInjectEndRnNRWithHttpInfo($unknown_base_type); - } - - /** - * Operation testCodeInjectEndRnNRWithHttpInfo - * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param object $unknown_base_type (optional) - * - * @throws \OpenAPITools\Client\ApiException on non-2xx response - * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) - */ - public function testCodeInjectEndRnNRWithHttpInfo($unknown_base_type = null) - { - $returnType = ''; - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); - - 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 testCodeInjectEndRnNRAsync - * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param object $unknown_base_type (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testCodeInjectEndRnNRAsync($unknown_base_type = null) - { - return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type) - ->then( - function ($response) { - return $response[0]; - } - ); - } - - /** - * Operation testCodeInjectEndRnNRAsyncWithHttpInfo - * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param object $unknown_base_type (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public function testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type = null) - { - $returnType = ''; - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); - - 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 'testCodeInjectEndRnNR' - * - * @param object $unknown_base_type (optional) - * - * @throws \InvalidArgumentException - * @return \GuzzleHttp\Psr7\Request - */ - protected function testCodeInjectEndRnNRRequest($unknown_base_type = null) - { - - $resourcePath = '/fake'; - $formParams = []; - $queryParams = []; - $headerParams = []; - $httpBody = ''; - $multipart = false; - - - - // body params - $_tempBody = null; - if (isset($unknown_base_type)) { - $_tempBody = $unknown_base_type; - } - - if ($multipart) { - $headers = $this->headerSelector->selectHeadersForMultipart( - [] - ); - } else { - $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', '*_/ \" =end --'] - ); - } - - // 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-security-test/php/OpenAPIToolsClient-php/lib/ApiException.php b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/ApiException.php deleted file mode 100644 index a142ed50335..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/ApiException.php +++ /dev/null @@ -1,121 +0,0 @@ -responseHeaders = $responseHeaders; - $this->responseBody = $responseBody; - } - - /** - * Gets the HTTP response header - * - * @return string[]|null HTTP response header - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * Gets the HTTP body of the server response either as Json or string - * - * @return 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-security-test/php/OpenAPIToolsClient-php/lib/Configuration.php b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Configuration.php deleted file mode 100644 index 1dbbf8684ea..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Configuration.php +++ /dev/null @@ -1,429 +0,0 @@ -tempFolderPath = sys_get_temp_dir(); - } - - /** - * Sets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $key API key or token - * - * @return $this - */ - public function setApiKey($apiKeyIdentifier, $key) - { - $this->apiKeys[$apiKeyIdentifier] = $key; - return $this; - } - - /** - * Gets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return 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 (OpenAPITools\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 *_/ ' \" =end -- \\r\\n \\n \\r' . 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-security-test/php/OpenAPIToolsClient-php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/HeaderSelector.php deleted file mode 100644 index b5775196681..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/HeaderSelector.php +++ /dev/null @@ -1,110 +0,0 @@ -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-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelInterface.php deleted file mode 100644 index 7356242d8a3..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelInterface.php +++ /dev/null @@ -1,96 +0,0 @@ -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::openAPIToolsFormats(); - foreach ($data::openAPIToolsTypes() as $property => $openAPIToolsType) { - $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null - && !in_array($openAPIToolsType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], 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'"); - } - if ($value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIToolsType, $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 = '\OpenAPITools\Client\Model\\' . $data->{$discriminator}; - if (is_subclass_of($subclass, $class)) { - $class = $subclass; - } - } - $instance = new $class(); - foreach ($instance::openAPIToolsTypes() 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-security-test/php/OpenAPIToolsClient-php/phpunit.xml.dist b/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/phpunit.xml.dist deleted file mode 100644 index c12ee148477..00000000000 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/phpunit.xml.dist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - ./test/Api - ./test/Model - - - - - - ./lib/Api - ./lib/Model - - - diff --git a/samples/client/petstore-security-test/php/README.md b/samples/client/petstore-security-test/php/README.md deleted file mode 100644 index 72e324853a6..00000000000 --- a/samples/client/petstore-security-test/php/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# 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: \" \\ *_/ ' \" =end -- - -This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r -- 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 -testCodeInjectEndRnNR($unknown_base_type); -} catch (Exception $e) { - echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; -} - -?> -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*FakeApi* | [**testCodeInjectEndRnNR**](docs/Api/FakeApi.md#testcodeinjectendrnnr) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - - -## Documentation For Models - - - [ModelReturn](docs/Model/ModelReturn.md) - - -## Documentation For Authorization - - -## api_key - -- **Type**: API key -- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r -- **Location**: HTTP header - -## petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog -- **Scopes**: - - **write:pets**: modify pets in your account *_/ ' \" =end -- \\r\\n \\n \\r - - **read:pets**: read your pets *_/ ' \" =end -- \\r\\n \\n \\r - - -## Author - -something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r - - diff --git a/samples/client/petstore-security-test/php/composer.json b/samples/client/petstore-security-test/php/composer.json deleted file mode 100644 index 834ab01d201..00000000000 --- a/samples/client/petstore-security-test/php/composer.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "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": "~2.12" - }, - "autoload": { - "psr-4": { "OpenAPI\\Client\\" : "lib/" } - }, - "autoload-dev": { - "psr-4": { "OpenAPI\\Client\\" : "test/" } - } -} diff --git a/samples/client/petstore-security-test/php/docs/Api/FakeApi.md b/samples/client/petstore-security-test/php/docs/Api/FakeApi.md deleted file mode 100644 index afee7db1162..00000000000 --- a/samples/client/petstore-security-test/php/docs/Api/FakeApi.md +++ /dev/null @@ -1,57 +0,0 @@ -# OpenAPI\Client\FakeApi - -All URIs are relative to *http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**testCodeInjectEndRnNR**](FakeApi.md#testCodeInjectEndRnNR) | **PUT** /fake | To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - - -# **testCodeInjectEndRnNR** -> testCodeInjectEndRnNR($unknown_base_type) - -To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - -To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - -### Example -```php -testCodeInjectEndRnNR($unknown_base_type); -} catch (Exception $e) { - echo 'Exception when calling FakeApi->testCodeInjectEndRnNR: ', $e->getMessage(), PHP_EOL; -} -?> -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **unknown_base_type** | [**\OpenAPI\Client\Model\UNKNOWN_BASE_TYPE**](../Model/UNKNOWN_BASE_TYPE.md)| | [optional] - -### Return type - -void (empty response body) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json, *_/ \" =end -- - - **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-security-test/php/git_push.sh b/samples/client/petstore-security-test/php/git_push.sh deleted file mode 100644 index 20057f67ade..00000000000 --- a/samples/client/petstore-security-test/php/git_push.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/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-security-test/php/lib/ApiException.php b/samples/client/petstore-security-test/php/lib/ApiException.php deleted file mode 100644 index 06960702b35..00000000000 --- a/samples/client/petstore-security-test/php/lib/ApiException.php +++ /dev/null @@ -1,121 +0,0 @@ -responseHeaders = $responseHeaders; - $this->responseBody = $responseBody; - } - - /** - * Gets the HTTP response header - * - * @return string[]|null HTTP response header - */ - public function getResponseHeaders() - { - return $this->responseHeaders; - } - - /** - * Gets the HTTP body of the server response either as Json or string - * - * @return 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-security-test/php/lib/Configuration.php b/samples/client/petstore-security-test/php/lib/Configuration.php deleted file mode 100644 index 1e2b013ccf0..00000000000 --- a/samples/client/petstore-security-test/php/lib/Configuration.php +++ /dev/null @@ -1,429 +0,0 @@ -tempFolderPath = sys_get_temp_dir(); - } - - /** - * Sets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * @param string $key API key or token - * - * @return $this - */ - public function setApiKey($apiKeyIdentifier, $key) - { - $this->apiKeys[$apiKeyIdentifier] = $key; - return $this; - } - - /** - * Gets API key - * - * @param string $apiKeyIdentifier API key identifier (authentication scheme) - * - * @return 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 *_/ ' \" =end -- \\r\\n \\n \\r' . 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-security-test/php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/lib/HeaderSelector.php deleted file mode 100644 index fac0c0df7d8..00000000000 --- a/samples/client/petstore-security-test/php/lib/HeaderSelector.php +++ /dev/null @@ -1,110 +0,0 @@ -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-security-test/php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/lib/Model/ModelInterface.php deleted file mode 100644 index b1bff06abb2..00000000000 --- a/samples/client/petstore-security-test/php/lib/Model/ModelInterface.php +++ /dev/null @@ -1,96 +0,0 @@ -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(), true)) { - $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 a 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(), true)) { - $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-security-test/php/phpunit.xml.dist b/samples/client/petstore-security-test/php/phpunit.xml.dist deleted file mode 100644 index c12ee148477..00000000000 --- a/samples/client/petstore-security-test/php/phpunit.xml.dist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - ./test/Api - ./test/Model - - - - - - ./lib/Api - ./lib/Model - - - diff --git a/samples/client/petstore-security-test/php/test/Api/FakeApiTest.php b/samples/client/petstore-security-test/php/test/Api/FakeApiTest.php deleted file mode 100644 index 07057cd8a7f..00000000000 --- a/samples/client/petstore-security-test/php/test/Api/FakeApiTest.php +++ /dev/null @@ -1,83 +0,0 @@ - \OpenAPI\Client\Model\InlineResponseDefault fooGet() + + + +### Example +```php +fooGet(); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling DefaultApi->fooGet: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**\OpenAPI\Client\Model\InlineResponseDefault**](../Model/InlineResponseDefault.md) + +### Authorization + +No authorization required + +### 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) + diff --git a/samples/client/petstore-security-test/php/docs/Model/ModelReturn.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Foo.md similarity index 69% rename from samples/client/petstore-security-test/php/docs/Model/ModelReturn.md rename to samples/client/petstore/php/OpenAPIClient-php/docs/Model/Foo.md index efd25fe6d22..ee5ddff7206 100644 --- a/samples/client/petstore-security-test/php/docs/Model/ModelReturn.md +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/Foo.md @@ -1,9 +1,9 @@ -# ModelReturn +# Foo ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**return** | **int** | property description *_/ ' \" =end -- \\r\\n \\n \\r | [optional] +**bar** | **string** | | [optional] [default to 'bar'] [[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/InlineObject.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject.md new file mode 100644 index 00000000000..101275879be --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject.md @@ -0,0 +1,11 @@ +# InlineObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Updated name of the pet | [optional] +**status** | **string** | Updated status 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/InlineObject1.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject1.md new file mode 100644 index 00000000000..dc428e8ea6c --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject1.md @@ -0,0 +1,11 @@ +# InlineObject1 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additional_metadata** | **string** | Additional data to pass to server | [optional] +**file** | [**\SplFileObject**](\SplFileObject.md) | file to upload | [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/InlineObject2.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject2.md new file mode 100644 index 00000000000..7e2ee7c9570 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject2.md @@ -0,0 +1,11 @@ +# InlineObject2 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_form_string_array** | **string[]** | Form parameter enum test (string array) | [optional] +**enum_form_string** | **string** | Form parameter enum test (string) | [optional] [default to '-efg'] + +[[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/InlineObject3.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject3.md new file mode 100644 index 00000000000..cef75b28262 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject3.md @@ -0,0 +1,23 @@ +# InlineObject3 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **int** | None | [optional] +**int32** | **int** | None | [optional] +**int64** | **int** | None | [optional] +**number** | **float** | None | +**float** | **float** | None | [optional] +**double** | **double** | None | +**string** | **string** | None | [optional] +**pattern_without_delimiter** | **string** | None | +**byte** | **string** | None | +**binary** | [**\SplFileObject**](\SplFileObject.md) | None | [optional] +**date** | [**\DateTime**](\DateTime.md) | None | [optional] +**date_time** | [**\DateTime**](\DateTime.md) | None | [optional] +**password** | **string** | None | [optional] +**callback** | **string** | None | [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-security-test/php/OpenAPIToolsClient-php/docs/Model/ModelReturn.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject4.md similarity index 69% rename from samples/client/petstore-security-test/php/OpenAPIToolsClient-php/docs/Model/ModelReturn.md rename to samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject4.md index efd25fe6d22..6675b7f47ce 100644 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/docs/Model/ModelReturn.md +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject4.md @@ -1,9 +1,10 @@ -# ModelReturn +# InlineObject4 ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**return** | **int** | property description *_/ ' \" =end -- \\r\\n \\n \\r | [optional] +**param** | **string** | field1 | +**param2** | **string** | field2 | [[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/InlineObject5.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject5.md new file mode 100644 index 00000000000..d1d27f7cc65 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineObject5.md @@ -0,0 +1,11 @@ +# InlineObject5 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additional_metadata** | **string** | Additional data to pass to server | [optional] +**required_file** | [**\SplFileObject**](\SplFileObject.md) | file to upload | + +[[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/InlineResponseDefault.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineResponseDefault.md new file mode 100644 index 00000000000..9f25c169f64 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/InlineResponseDefault.md @@ -0,0 +1,10 @@ +# InlineResponseDefault + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**string** | [**\OpenAPI\Client\Model\Foo**](Foo.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-security-test/php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php similarity index 66% rename from samples/client/petstore-security-test/php/lib/Api/FakeApi.php rename to samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php index 9908f6d7075..96f465d3cb1 100644 --- a/samples/client/petstore-security-test/php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/DefaultApi.php @@ -1,6 +1,6 @@ testCodeInjectEndRnNRWithHttpInfo($unknown_base_type); + list($response) = $this->fooGetWithHttpInfo(); + return $response; } /** - * Operation testCodeInjectEndRnNRWithHttpInfo + * Operation fooGetWithHttpInfo * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r - * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \OpenAPI\Client\ApiException on non-2xx response * @throws \InvalidArgumentException - * @return array of null, HTTP status code, HTTP response headers (array of strings) + * @return array of \OpenAPI\Client\Model\InlineResponseDefault, HTTP status code, HTTP response headers (array of strings) */ - public function testCodeInjectEndRnNRWithHttpInfo($unknown_base_type = null) + public function fooGetWithHttpInfo() { - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); + $request = $this->fooGetRequest(); try { $options = $this->createHttpClientOption(); @@ -146,28 +141,63 @@ class FakeApi ); } - return [null, $statusCode, $response->getHeaders()]; + $responseBody = $response->getBody(); + switch($statusCode) { + default: + if ('\OpenAPI\Client\Model\InlineResponseDefault' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\InlineResponseDefault', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\InlineResponseDefault'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; } catch (ApiException $e) { switch ($e->getCode()) { + default: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\InlineResponseDefault', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; } throw $e; } } /** - * Operation testCodeInjectEndRnNRAsync + * Operation fooGetAsync * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testCodeInjectEndRnNRAsync($unknown_base_type = null) + public function fooGetAsync() { - return $this->testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type) + return $this->fooGetAsyncWithHttpInfo() ->then( function ($response) { return $response[0]; @@ -176,25 +206,35 @@ class FakeApi } /** - * Operation testCodeInjectEndRnNRAsyncWithHttpInfo + * Operation fooGetAsyncWithHttpInfo * - * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ - public function testCodeInjectEndRnNRAsyncWithHttpInfo($unknown_base_type = null) + public function fooGetAsyncWithHttpInfo() { - $returnType = ''; - $request = $this->testCodeInjectEndRnNRRequest($unknown_base_type); + $returnType = '\OpenAPI\Client\Model\InlineResponseDefault'; + $request = $this->fooGetRequest(); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { - return [null, $response->getStatusCode(), $response->getHeaders()]; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = $responseBody->getContents(); + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; }, function ($exception) { $response = $exception->getResponse(); @@ -214,17 +254,16 @@ class FakeApi } /** - * Create request for operation 'testCodeInjectEndRnNR' + * Create request for operation 'fooGet' * - * @param \OpenAPI\Client\Model\UNKNOWN_BASE_TYPE $unknown_base_type (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ - protected function testCodeInjectEndRnNRRequest($unknown_base_type = null) + protected function fooGetRequest() { - $resourcePath = '/fake'; + $resourcePath = '/foo'; $formParams = []; $queryParams = []; $headerParams = []; @@ -235,28 +274,25 @@ class FakeApi // body params $_tempBody = null; - if (isset($unknown_base_type)) { - $_tempBody = $unknown_base_type; - } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( - [] + ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( - [], - ['application/json', '*_/ \" =end --'] + ['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); + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; } } elseif (count($formParams) > 0) { if ($multipart) { @@ -293,7 +329,7 @@ class FakeApi $query = \GuzzleHttp\Psr7\build_query($queryParams); return new Request( - 'PUT', + 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 7e33b9d328e..415236fa31f 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -2457,7 +2457,7 @@ class FakeApi } // this endpoint requires HTTP basic authentication - if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } diff --git a/samples/client/petstore-security-test/php/lib/Model/ModelReturn.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php similarity index 83% rename from samples/client/petstore-security-test/php/lib/Model/ModelReturn.php rename to samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php index bbf4b3f5ef9..bbc53c2243b 100644 --- a/samples/client/petstore-security-test/php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/Foo.php @@ -1,6 +1,6 @@ 'int' + 'bar' => 'string' ]; /** @@ -67,7 +66,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $openAPIFormats = [ - 'return' => 'int32' + 'bar' => null ]; /** @@ -97,7 +96,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $attributeMap = [ - 'return' => 'return' + 'bar' => 'bar' ]; /** @@ -106,7 +105,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $setters = [ - 'return' => 'setReturn' + 'bar' => 'setBar' ]; /** @@ -115,7 +114,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $getters = [ - 'return' => 'getReturn' + 'bar' => 'getBar' ]; /** @@ -178,7 +177,7 @@ class ModelReturn implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['return'] = isset($data['return']) ? $data['return'] : null; + $this->container['bar'] = isset($data['bar']) ? $data['bar'] : 'bar'; } /** @@ -206,25 +205,25 @@ class ModelReturn implements ModelInterface, ArrayAccess /** - * Gets return + * Gets bar * - * @return int|null + * @return string|null */ - public function getReturn() + public function getBar() { - return $this->container['return']; + return $this->container['bar']; } /** - * Sets return + * Sets bar * - * @param int|null $return property description *_/ ' \" =end -- \\r\\n \\n \\r + * @param string|null $bar bar * * @return $this */ - public function setReturn($return) + public function setBar($bar) { - $this->container['return'] = $return; + $this->container['bar'] = $bar; return $this; } diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php new file mode 100644 index 00000000000..3a9aa432007 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject.php @@ -0,0 +1,327 @@ + 'string', + 'status' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => 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 = [ + 'name' => 'name', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + '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; + } + + + + + + /** + * 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['status'] = isset($data['status']) ? $data['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 name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Updated name of the pet + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status Updated status of the pet + * + * @return $this + */ + public function setStatus($status) + { + $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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php new file mode 100644 index 00000000000..0da191b5833 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject1.php @@ -0,0 +1,327 @@ + 'string', + 'file' => '\SplFileObject' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'additional_metadata' => null, + 'file' => 'binary' + ]; + + /** + * 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 = [ + 'additional_metadata' => 'additionalMetadata', + 'file' => 'file' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'additional_metadata' => 'setAdditionalMetadata', + 'file' => 'setFile' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'additional_metadata' => 'getAdditionalMetadata', + 'file' => 'getFile' + ]; + + /** + * 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['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; + $this->container['file'] = isset($data['file']) ? $data['file'] : 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 additional_metadata + * + * @return string|null + */ + public function getAdditionalMetadata() + { + return $this->container['additional_metadata']; + } + + /** + * Sets additional_metadata + * + * @param string|null $additional_metadata Additional data to pass to server + * + * @return $this + */ + public function setAdditionalMetadata($additional_metadata) + { + $this->container['additional_metadata'] = $additional_metadata; + + return $this; + } + + /** + * Gets file + * + * @return \SplFileObject|null + */ + public function getFile() + { + return $this->container['file']; + } + + /** + * Sets file + * + * @param \SplFileObject|null $file file to upload + * + * @return $this + */ + public function setFile($file) + { + $this->container['file'] = $file; + + 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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php new file mode 100644 index 00000000000..80280518693 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject2.php @@ -0,0 +1,385 @@ + 'string[]', + 'enum_form_string' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'enum_form_string_array' => null, + 'enum_form_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 = [ + 'enum_form_string_array' => 'enum_form_string_array', + 'enum_form_string' => 'enum_form_string' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'enum_form_string_array' => 'setEnumFormStringArray', + 'enum_form_string' => 'setEnumFormString' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'enum_form_string_array' => 'getEnumFormStringArray', + 'enum_form_string' => 'getEnumFormString' + ]; + + /** + * 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_FORM_STRING_ARRAY_GREATER_THAN = '>'; + const ENUM_FORM_STRING_ARRAY_DOLLAR = '$'; + const ENUM_FORM_STRING_ABC = '_abc'; + const ENUM_FORM_STRING_EFG = '-efg'; + const ENUM_FORM_STRING_XYZ = '(xyz)'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getEnumFormStringArrayAllowableValues() + { + return [ + self::ENUM_FORM_STRING_ARRAY_GREATER_THAN, + self::ENUM_FORM_STRING_ARRAY_DOLLAR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getEnumFormStringAllowableValues() + { + return [ + self::ENUM_FORM_STRING_ABC, + self::ENUM_FORM_STRING_EFG, + self::ENUM_FORM_STRING_XYZ, + ]; + } + + + /** + * 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_form_string_array'] = isset($data['enum_form_string_array']) ? $data['enum_form_string_array'] : null; + $this->container['enum_form_string'] = isset($data['enum_form_string']) ? $data['enum_form_string'] : '-efg'; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getEnumFormStringAllowableValues(); + if (!is_null($this->container['enum_form_string']) && !in_array($this->container['enum_form_string'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_form_string', 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_form_string_array + * + * @return string[]|null + */ + public function getEnumFormStringArray() + { + return $this->container['enum_form_string_array']; + } + + /** + * Sets enum_form_string_array + * + * @param string[]|null $enum_form_string_array Form parameter enum test (string array) + * + * @return $this + */ + public function setEnumFormStringArray($enum_form_string_array) + { + $allowedValues = $this->getEnumFormStringArrayAllowableValues(); + if (!is_null($enum_form_string_array) && array_diff($enum_form_string_array, $allowedValues)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_form_string_array', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_form_string_array'] = $enum_form_string_array; + + return $this; + } + + /** + * Gets enum_form_string + * + * @return string|null + */ + public function getEnumFormString() + { + return $this->container['enum_form_string']; + } + + /** + * Sets enum_form_string + * + * @param string|null $enum_form_string Form parameter enum test (string) + * + * @return $this + */ + public function setEnumFormString($enum_form_string) + { + $allowedValues = $this->getEnumFormStringAllowableValues(); + if (!is_null($enum_form_string) && !in_array($enum_form_string, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_form_string', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_form_string'] = $enum_form_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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php new file mode 100644 index 00000000000..b6c4e18fbf3 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject3.php @@ -0,0 +1,805 @@ + 'int', + 'int32' => 'int', + 'int64' => 'int', + 'number' => 'float', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'pattern_without_delimiter' => 'string', + 'byte' => 'string', + 'binary' => '\SplFileObject', + 'date' => '\DateTime', + 'date_time' => '\DateTime', + 'password' => 'string', + 'callback' => '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, + 'pattern_without_delimiter' => null, + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'date-time', + 'password' => 'password', + 'callback' => 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 = [ + 'integer' => 'integer', + 'int32' => 'int32', + 'int64' => 'int64', + 'number' => 'number', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'pattern_without_delimiter' => 'pattern_without_delimiter', + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'dateTime', + 'password' => 'password', + 'callback' => 'callback' + ]; + + /** + * 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', + 'pattern_without_delimiter' => 'setPatternWithoutDelimiter', + 'byte' => 'setByte', + 'binary' => 'setBinary', + 'date' => 'setDate', + 'date_time' => 'setDateTime', + 'password' => 'setPassword', + 'callback' => 'setCallback' + ]; + + /** + * 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', + 'pattern_without_delimiter' => 'getPatternWithoutDelimiter', + 'byte' => 'getByte', + 'binary' => 'getBinary', + 'date' => 'getDate', + 'date_time' => 'getDateTime', + 'password' => 'getPassword', + 'callback' => 'getCallback' + ]; + + /** + * 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['pattern_without_delimiter'] = isset($data['pattern_without_delimiter']) ? $data['pattern_without_delimiter'] : 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['password'] = isset($data['password']) ? $data['password'] : null; + $this->container['callback'] = isset($data['callback']) ? $data['callback'] : 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 ($this->container['double'] === null) { + $invalidProperties[] = "'double' can't be null"; + } + if (($this->container['double'] > 123.4)) { + $invalidProperties[] = "invalid value for 'double', must be smaller than or equal to 123.4."; + } + + if (($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['pattern_without_delimiter'] === null) { + $invalidProperties[] = "'pattern_without_delimiter' can't be null"; + } + if (!preg_match("/^[A-Z].*/", $this->container['pattern_without_delimiter'])) { + $invalidProperties[] = "invalid value for 'pattern_without_delimiter', must be conform to the pattern /^[A-Z].*/."; + } + + if ($this->container['byte'] === null) { + $invalidProperties[] = "'byte' can't be null"; + } + if (!is_null($this->container['password']) && (mb_strlen($this->container['password']) > 64)) { + $invalidProperties[] = "invalid value for 'password', the character length must be smaller than or equal to 64."; + } + + if (!is_null($this->container['password']) && (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|null + */ + public function getInteger() + { + return $this->container['integer']; + } + + /** + * Sets integer + * + * @param int|null $integer None + * + * @return $this + */ + public function setInteger($integer) + { + + if (!is_null($integer) && ($integer > 100)) { + throw new \InvalidArgumentException('invalid value for $integer when calling InlineObject3., must be smaller than or equal to 100.'); + } + if (!is_null($integer) && ($integer < 10)) { + throw new \InvalidArgumentException('invalid value for $integer when calling InlineObject3., must be bigger than or equal to 10.'); + } + + $this->container['integer'] = $integer; + + return $this; + } + + /** + * Gets int32 + * + * @return int|null + */ + public function getInt32() + { + return $this->container['int32']; + } + + /** + * Sets int32 + * + * @param int|null $int32 None + * + * @return $this + */ + public function setInt32($int32) + { + + if (!is_null($int32) && ($int32 > 200)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling InlineObject3., must be smaller than or equal to 200.'); + } + if (!is_null($int32) && ($int32 < 20)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling InlineObject3., must be bigger than or equal to 20.'); + } + + $this->container['int32'] = $int32; + + return $this; + } + + /** + * Gets int64 + * + * @return int|null + */ + public function getInt64() + { + return $this->container['int64']; + } + + /** + * Sets int64 + * + * @param int|null $int64 None + * + * @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 None + * + * @return $this + */ + public function setNumber($number) + { + + if (($number > 543.2)) { + throw new \InvalidArgumentException('invalid value for $number when calling InlineObject3., must be smaller than or equal to 543.2.'); + } + if (($number < 32.1)) { + throw new \InvalidArgumentException('invalid value for $number when calling InlineObject3., must be bigger than or equal to 32.1.'); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets float + * + * @return float|null + */ + public function getFloat() + { + return $this->container['float']; + } + + /** + * Sets float + * + * @param float|null $float None + * + * @return $this + */ + public function setFloat($float) + { + + if (!is_null($float) && ($float > 987.6)) { + throw new \InvalidArgumentException('invalid value for $float when calling InlineObject3., must be smaller than or equal to 987.6.'); + } + + $this->container['float'] = $float; + + return $this; + } + + /** + * Gets double + * + * @return double + */ + public function getDouble() + { + return $this->container['double']; + } + + /** + * Sets double + * + * @param double $double None + * + * @return $this + */ + public function setDouble($double) + { + + if (($double > 123.4)) { + throw new \InvalidArgumentException('invalid value for $double when calling InlineObject3., must be smaller than or equal to 123.4.'); + } + if (($double < 67.8)) { + throw new \InvalidArgumentException('invalid value for $double when calling InlineObject3., must be bigger than or equal to 67.8.'); + } + + $this->container['double'] = $double; + + return $this; + } + + /** + * Gets string + * + * @return string|null + */ + public function getString() + { + return $this->container['string']; + } + + /** + * Sets string + * + * @param string|null $string None + * + * @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 InlineObject3., must conform to the pattern /[a-z]/i."); + } + + $this->container['string'] = $string; + + return $this; + } + + /** + * Gets pattern_without_delimiter + * + * @return string + */ + public function getPatternWithoutDelimiter() + { + return $this->container['pattern_without_delimiter']; + } + + /** + * Sets pattern_without_delimiter + * + * @param string $pattern_without_delimiter None + * + * @return $this + */ + public function setPatternWithoutDelimiter($pattern_without_delimiter) + { + + if ((!preg_match("/^[A-Z].*/", $pattern_without_delimiter))) { + throw new \InvalidArgumentException("invalid value for $pattern_without_delimiter when calling InlineObject3., must conform to the pattern /^[A-Z].*/."); + } + + $this->container['pattern_without_delimiter'] = $pattern_without_delimiter; + + return $this; + } + + /** + * Gets byte + * + * @return string + */ + public function getByte() + { + return $this->container['byte']; + } + + /** + * Sets byte + * + * @param string $byte None + * + * @return $this + */ + public function setByte($byte) + { + $this->container['byte'] = $byte; + + return $this; + } + + /** + * Gets binary + * + * @return \SplFileObject|null + */ + public function getBinary() + { + return $this->container['binary']; + } + + /** + * Sets binary + * + * @param \SplFileObject|null $binary None + * + * @return $this + */ + public function setBinary($binary) + { + $this->container['binary'] = $binary; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date None + * + * @return $this + */ + public function setDate($date) + { + $this->container['date'] = $date; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime|null + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime|null $date_time None + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets password + * + * @return string|null + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string|null $password None + * + * @return $this + */ + public function setPassword($password) + { + if (!is_null($password) && (mb_strlen($password) > 64)) { + throw new \InvalidArgumentException('invalid length for $password when calling InlineObject3., must be smaller than or equal to 64.'); + } + if (!is_null($password) && (mb_strlen($password) < 10)) { + throw new \InvalidArgumentException('invalid length for $password when calling InlineObject3., must be bigger than or equal to 10.'); + } + + $this->container['password'] = $password; + + return $this; + } + + /** + * Gets callback + * + * @return string|null + */ + public function getCallback() + { + return $this->container['callback']; + } + + /** + * Sets callback + * + * @param string|null $callback None + * + * @return $this + */ + public function setCallback($callback) + { + $this->container['callback'] = $callback; + + 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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php new file mode 100644 index 00000000000..e06180ca5a3 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject4.php @@ -0,0 +1,333 @@ + 'string', + 'param2' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'param' => null, + 'param2' => 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 = [ + 'param' => 'param', + 'param2' => 'param2' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'param' => 'setParam', + 'param2' => 'setParam2' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'param' => 'getParam', + 'param2' => 'getParam2' + ]; + + /** + * 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['param'] = isset($data['param']) ? $data['param'] : null; + $this->container['param2'] = isset($data['param2']) ? $data['param2'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['param'] === null) { + $invalidProperties[] = "'param' can't be null"; + } + if ($this->container['param2'] === null) { + $invalidProperties[] = "'param2' 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 param + * + * @return string + */ + public function getParam() + { + return $this->container['param']; + } + + /** + * Sets param + * + * @param string $param field1 + * + * @return $this + */ + public function setParam($param) + { + $this->container['param'] = $param; + + return $this; + } + + /** + * Gets param2 + * + * @return string + */ + public function getParam2() + { + return $this->container['param2']; + } + + /** + * Sets param2 + * + * @param string $param2 field2 + * + * @return $this + */ + public function setParam2($param2) + { + $this->container['param2'] = $param2; + + 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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php new file mode 100644 index 00000000000..bf42a623537 --- /dev/null +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineObject5.php @@ -0,0 +1,330 @@ + 'string', + 'required_file' => '\SplFileObject' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'additional_metadata' => null, + 'required_file' => 'binary' + ]; + + /** + * 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 = [ + 'additional_metadata' => 'additionalMetadata', + 'required_file' => 'requiredFile' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'additional_metadata' => 'setAdditionalMetadata', + 'required_file' => 'setRequiredFile' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'additional_metadata' => 'getAdditionalMetadata', + 'required_file' => 'getRequiredFile' + ]; + + /** + * 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['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; + $this->container['required_file'] = isset($data['required_file']) ? $data['required_file'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['required_file'] === null) { + $invalidProperties[] = "'required_file' 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 additional_metadata + * + * @return string|null + */ + public function getAdditionalMetadata() + { + return $this->container['additional_metadata']; + } + + /** + * Sets additional_metadata + * + * @param string|null $additional_metadata Additional data to pass to server + * + * @return $this + */ + public function setAdditionalMetadata($additional_metadata) + { + $this->container['additional_metadata'] = $additional_metadata; + + return $this; + } + + /** + * Gets required_file + * + * @return \SplFileObject + */ + public function getRequiredFile() + { + return $this->container['required_file']; + } + + /** + * Sets required_file + * + * @param \SplFileObject $required_file file to upload + * + * @return $this + */ + public function setRequiredFile($required_file) + { + $this->container['required_file'] = $required_file; + + 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() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php similarity index 72% rename from samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelReturn.php rename to samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php index 759c08090a2..9aab09e323e 100644 --- a/samples/client/petstore-security-test/php/OpenAPIToolsClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/InlineResponseDefault.php @@ -1,24 +1,24 @@ 'int' + protected static $openAPITypes = [ + 'string' => '\OpenAPI\Client\Model\Foo' ]; /** @@ -66,8 +65,8 @@ class ModelReturn implements ModelInterface, ArrayAccess * * @var string[] */ - protected static $openAPIToolsFormats = [ - 'return' => 'int32' + protected static $openAPIFormats = [ + 'string' => null ]; /** @@ -75,9 +74,9 @@ class ModelReturn implements ModelInterface, ArrayAccess * * @return array */ - public static function openAPIToolsTypes() + public static function openAPITypes() { - return self::$openAPIToolsTypes; + return self::$openAPITypes; } /** @@ -85,9 +84,9 @@ class ModelReturn implements ModelInterface, ArrayAccess * * @return array */ - public static function openAPIToolsFormats() + public static function openAPIFormats() { - return self::$openAPIToolsFormats; + return self::$openAPIFormats; } /** @@ -97,7 +96,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $attributeMap = [ - 'return' => 'return' + 'string' => 'string' ]; /** @@ -106,7 +105,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $setters = [ - 'return' => 'setReturn' + 'string' => 'setString' ]; /** @@ -115,7 +114,7 @@ class ModelReturn implements ModelInterface, ArrayAccess * @var string[] */ protected static $getters = [ - 'return' => 'getReturn' + 'string' => 'getString' ]; /** @@ -156,7 +155,7 @@ class ModelReturn implements ModelInterface, ArrayAccess */ public function getModelName() { - return self::$openAPIToolsModelName; + return self::$openAPIModelName; } @@ -178,7 +177,7 @@ class ModelReturn implements ModelInterface, ArrayAccess */ public function __construct(array $data = null) { - $this->container['return'] = isset($data['return']) ? $data['return'] : null; + $this->container['string'] = isset($data['string']) ? $data['string'] : null; } /** @@ -206,25 +205,25 @@ class ModelReturn implements ModelInterface, ArrayAccess /** - * Gets return + * Gets string * - * @return int + * @return \OpenAPI\Client\Model\Foo|null */ - public function getReturn() + public function getString() { - return $this->container['return']; + return $this->container['string']; } /** - * Sets return + * Sets string * - * @param int $return property description *_/ ' \" =end -- \\r\\n \\n \\r + * @param \OpenAPI\Client\Model\Foo|null $string string * * @return $this */ - public function setReturn($return) + public function setString($string) { - $this->container['return'] = $return; + $this->container['string'] = $string; return $this; } @@ -288,14 +287,10 @@ class ModelReturn implements ModelInterface, ArrayAccess */ 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)); + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); } } 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 index db3649ee1d6..735839f8934 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -2491,7 +2491,7 @@ class FakeApi } // this endpoint requires HTTP basic authentication - if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) { + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); }