@kattebak/openapi-generator-ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +116 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +26 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +6 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +80 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/convert-template.d.ts +31 -0
- package/dist/cli/convert-template.d.ts.map +1 -0
- package/dist/cli/convert-template.js +204 -0
- package/dist/cli/convert-template.js.map +1 -0
- package/dist/cli/convert-template.test.d.ts +2 -0
- package/dist/cli/convert-template.test.d.ts.map +1 -0
- package/dist/cli/convert-template.test.js +74 -0
- package/dist/cli/convert-template.test.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +246 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +252 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +31 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/generator.d.ts +99 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/generator.js +492 -0
- package/dist/core/generator.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generators/generators.test.d.ts +6 -0
- package/dist/generators/generators.test.d.ts.map +1 -0
- package/dist/generators/generators.test.js +247 -0
- package/dist/generators/generators.test.js.map +1 -0
- package/dist/generators/go.d.ts +10 -0
- package/dist/generators/go.d.ts.map +1 -0
- package/dist/generators/go.js +327 -0
- package/dist/generators/go.js.map +1 -0
- package/dist/generators/index.d.ts +29 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +58 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/php.d.ts +14 -0
- package/dist/generators/php.d.ts.map +1 -0
- package/dist/generators/php.js +241 -0
- package/dist/generators/php.js.map +1 -0
- package/dist/generators/python.d.ts +10 -0
- package/dist/generators/python.d.ts.map +1 -0
- package/dist/generators/python.js +273 -0
- package/dist/generators/python.js.map +1 -0
- package/dist/generators/typescript-fetch.d.ts +14 -0
- package/dist/generators/typescript-fetch.d.ts.map +1 -0
- package/dist/generators/typescript-fetch.js +217 -0
- package/dist/generators/typescript-fetch.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/models/codegen-model.d.ts +123 -0
- package/dist/models/codegen-model.d.ts.map +1 -0
- package/dist/models/codegen-model.js +64 -0
- package/dist/models/codegen-model.js.map +1 -0
- package/dist/models/codegen-model.test.d.ts +6 -0
- package/dist/models/codegen-model.test.d.ts.map +1 -0
- package/dist/models/codegen-model.test.js +143 -0
- package/dist/models/codegen-model.test.js.map +1 -0
- package/dist/models/codegen-operation.d.ts +95 -0
- package/dist/models/codegen-operation.d.ts.map +1 -0
- package/dist/models/codegen-operation.js +54 -0
- package/dist/models/codegen-operation.js.map +1 -0
- package/dist/models/codegen-parameter.d.ts +86 -0
- package/dist/models/codegen-parameter.d.ts.map +1 -0
- package/dist/models/codegen-parameter.js +47 -0
- package/dist/models/codegen-parameter.js.map +1 -0
- package/dist/models/codegen-property.d.ts +95 -0
- package/dist/models/codegen-property.d.ts.map +1 -0
- package/dist/models/codegen-property.js +47 -0
- package/dist/models/codegen-property.js.map +1 -0
- package/dist/models/codegen-response.d.ts +64 -0
- package/dist/models/codegen-response.d.ts.map +1 -0
- package/dist/models/codegen-response.js +42 -0
- package/dist/models/codegen-response.js.map +1 -0
- package/dist/models/codegen-security.d.ts +34 -0
- package/dist/models/codegen-security.d.ts.map +1 -0
- package/dist/models/codegen-security.js +18 -0
- package/dist/models/codegen-security.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +4 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/openapi-parser.d.ts +71 -0
- package/dist/parser/openapi-parser.d.ts.map +1 -0
- package/dist/parser/openapi-parser.js +195 -0
- package/dist/parser/openapi-parser.js.map +1 -0
- package/dist/parser/openapi-parser.test.d.ts +6 -0
- package/dist/parser/openapi-parser.test.d.ts.map +1 -0
- package/dist/parser/openapi-parser.test.js +238 -0
- package/dist/parser/openapi-parser.test.js.map +1 -0
- package/dist/parser/operation-transformer.d.ts +95 -0
- package/dist/parser/operation-transformer.d.ts.map +1 -0
- package/dist/parser/operation-transformer.js +634 -0
- package/dist/parser/operation-transformer.js.map +1 -0
- package/dist/parser/schema-transformer.d.ts +134 -0
- package/dist/parser/schema-transformer.d.ts.map +1 -0
- package/dist/parser/schema-transformer.js +557 -0
- package/dist/parser/schema-transformer.js.map +1 -0
- package/dist/template/engine-adapter.d.ts +55 -0
- package/dist/template/engine-adapter.d.ts.map +1 -0
- package/dist/template/engine-adapter.js +178 -0
- package/dist/template/engine-adapter.js.map +1 -0
- package/dist/template/engine-adapter.test.d.ts +6 -0
- package/dist/template/engine-adapter.test.d.ts.map +1 -0
- package/dist/template/engine-adapter.test.js +186 -0
- package/dist/template/engine-adapter.test.js.map +1 -0
- package/dist/template/index.d.ts +5 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js +5 -0
- package/dist/template/index.js.map +1 -0
- package/dist/template/lambdas/indent-lambdas.d.ts +40 -0
- package/dist/template/lambdas/indent-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/indent-lambdas.js +98 -0
- package/dist/template/lambdas/indent-lambdas.js.map +1 -0
- package/dist/template/lambdas/index.d.ts +44 -0
- package/dist/template/lambdas/index.d.ts.map +1 -0
- package/dist/template/lambdas/index.js +79 -0
- package/dist/template/lambdas/index.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.d.ts +78 -0
- package/dist/template/lambdas/string-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.js +148 -0
- package/dist/template/lambdas/string-lambdas.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts +6 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.js +158 -0
- package/dist/template/lambdas/string-lambdas.test.js.map +1 -0
- package/dist/template/template-locator.d.ts +72 -0
- package/dist/template/template-locator.d.ts.map +1 -0
- package/dist/template/template-locator.js +173 -0
- package/dist/template/template-locator.js.map +1 -0
- package/dist/template/template-manager.d.ts +65 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +185 -0
- package/dist/template/template-manager.js.map +1 -0
- package/package.json +67 -0
- package/templates/go/.travis.yml +8 -0
- package/templates/go/README.mustache +236 -0
- package/templates/go/api.mustache +452 -0
- package/templates/go/api_doc.mustache +92 -0
- package/templates/go/api_test.mustache +59 -0
- package/templates/go/client.mustache +761 -0
- package/templates/go/configuration.mustache +332 -0
- package/templates/go/git_push.sh.mustache +57 -0
- package/templates/go/gitignore.mustache +24 -0
- package/templates/go/go.mod.mustache +16 -0
- package/templates/go/go.sum.mustache +19 -0
- package/templates/go/model.mustache +21 -0
- package/templates/go/model_anyof.mustache +93 -0
- package/templates/go/model_doc.mustache +97 -0
- package/templates/go/model_enum.mustache +101 -0
- package/templates/go/model_oneof.mustache +160 -0
- package/templates/go/model_simple.mustache +572 -0
- package/templates/go/nullable_model.mustache +35 -0
- package/templates/go/openapi.mustache +1 -0
- package/templates/go/partial_header.mustache +18 -0
- package/templates/go/response.mustache +38 -0
- package/templates/go/signing.mustache +453 -0
- package/templates/go/utils.mustache +352 -0
- package/templates/php/.php-cs-fixer.dist.php +29 -0
- package/templates/php/.travis.yml +8 -0
- package/templates/php/ApiException.mustache +111 -0
- package/templates/php/Configuration.mustache +606 -0
- package/templates/php/FormDataProcessor.mustache +238 -0
- package/templates/php/HeaderSelector.mustache +265 -0
- package/templates/php/ModelInterface.mustache +103 -0
- package/templates/php/ObjectSerializer.mustache +591 -0
- package/templates/php/README.mustache +151 -0
- package/templates/php/api.mustache +891 -0
- package/templates/php/api_doc.mustache +105 -0
- package/templates/php/api_test.mustache +80 -0
- package/templates/php/composer.mustache +44 -0
- package/templates/php/git_push.sh.mustache +57 -0
- package/templates/php/gitignore +15 -0
- package/templates/php/libraries/psr-18/ApiException.mustache +114 -0
- package/templates/php/libraries/psr-18/DebugPlugin.mustache +93 -0
- package/templates/php/libraries/psr-18/README.mustache +161 -0
- package/templates/php/libraries/psr-18/api.mustache +833 -0
- package/templates/php/libraries/psr-18/api_doc.mustache +79 -0
- package/templates/php/libraries/psr-18/composer.mustache +56 -0
- package/templates/php/model.mustache +47 -0
- package/templates/php/model_doc.mustache +10 -0
- package/templates/php/model_enum.mustache +33 -0
- package/templates/php/model_generic.mustache +565 -0
- package/templates/php/model_test.mustache +88 -0
- package/templates/php/partial_header.mustache +18 -0
- package/templates/php/php_doc_auth_partial.mustache +23 -0
- package/templates/php/phpunit.xml.mustache +18 -0
- package/templates/python/README.mustache +60 -0
- package/templates/python/README_onlypackage.mustache +50 -0
- package/templates/python/__init__.mustache +1 -0
- package/templates/python/__init__api.mustache +19 -0
- package/templates/python/__init__model.mustache +22 -0
- package/templates/python/__init__package.mustache +49 -0
- package/templates/python/api.mustache +244 -0
- package/templates/python/api_client.mustache +822 -0
- package/templates/python/api_doc.mustache +81 -0
- package/templates/python/api_doc_example.mustache +38 -0
- package/templates/python/api_response.mustache +21 -0
- package/templates/python/api_test.mustache +48 -0
- package/templates/python/asyncio/rest.mustache +209 -0
- package/templates/python/common_README.mustache +85 -0
- package/templates/python/configuration.mustache +806 -0
- package/templates/python/exceptions.mustache +210 -0
- package/templates/python/exports_api.mustache +3 -0
- package/templates/python/exports_model.mustache +3 -0
- package/templates/python/exports_package.mustache +20 -0
- package/templates/python/git_push.sh.mustache +57 -0
- package/templates/python/github-workflow.mustache +35 -0
- package/templates/python/gitignore.mustache +66 -0
- package/templates/python/gitlab-ci.mustache +31 -0
- package/templates/python/httpx/rest.mustache +190 -0
- package/templates/python/model.mustache +16 -0
- package/templates/python/model_anyof.mustache +182 -0
- package/templates/python/model_doc.mustache +40 -0
- package/templates/python/model_enum.mustache +36 -0
- package/templates/python/model_generic.mustache +403 -0
- package/templates/python/model_oneof.mustache +209 -0
- package/templates/python/model_test.mustache +60 -0
- package/templates/python/partial_api.mustache +52 -0
- package/templates/python/partial_api_args.mustache +18 -0
- package/templates/python/partial_header.mustache +19 -0
- package/templates/python/py.typed.mustache +1 -0
- package/templates/python/pyproject.mustache +172 -0
- package/templates/python/python_doc_auth_partial.mustache +108 -0
- package/templates/python/requirements.mustache +23 -0
- package/templates/python/rest.mustache +254 -0
- package/templates/python/setup.mustache +60 -0
- package/templates/python/setup_cfg.mustache +2 -0
- package/templates/python/signing.mustache +422 -0
- package/templates/python/test-requirements.mustache +6 -0
- package/templates/python/tornado/rest.mustache +148 -0
- package/templates/python/tox.mustache +9 -0
- package/templates/python/travis.mustache +17 -0
- package/templates/typescript-fetch/ApiEntitiesRecord.mustache +26 -0
- package/templates/typescript-fetch/ApiEntitiesReducer.mustache +21 -0
- package/templates/typescript-fetch/ApiEntitiesSelectors.mustache +5 -0
- package/templates/typescript-fetch/README.mustache +127 -0
- package/templates/typescript-fetch/allSagas.mustache +19 -0
- package/templates/typescript-fetch/api_doc.mustache +63 -0
- package/templates/typescript-fetch/api_example.mustache +44 -0
- package/templates/typescript-fetch/apis.index.mustache +16 -0
- package/templates/typescript-fetch/apis.mustache +483 -0
- package/templates/typescript-fetch/apisAssignQueryParam.mustache +12 -0
- package/templates/typescript-fetch/gitignore +4 -0
- package/templates/typescript-fetch/index.mustache +17 -0
- package/templates/typescript-fetch/licenseInfo.mustache +11 -0
- package/templates/typescript-fetch/modelEnum.mustache +28 -0
- package/templates/typescript-fetch/modelEnumInterfaces.mustache +37 -0
- package/templates/typescript-fetch/modelGeneric.mustache +261 -0
- package/templates/typescript-fetch/modelGenericInterfaces.mustache +50 -0
- package/templates/typescript-fetch/modelOneOf.mustache +255 -0
- package/templates/typescript-fetch/modelOneOfInterfaces.mustache +6 -0
- package/templates/typescript-fetch/model_doc.mustache +41 -0
- package/templates/typescript-fetch/models.index.mustache +32 -0
- package/templates/typescript-fetch/models.mustache +24 -0
- package/templates/typescript-fetch/npmignore.mustache +1 -0
- package/templates/typescript-fetch/package.mustache +43 -0
- package/templates/typescript-fetch/recordGeneric.mustache +295 -0
- package/templates/typescript-fetch/records.mustache +17 -0
- package/templates/typescript-fetch/runtime.mustache +424 -0
- package/templates/typescript-fetch/runtimeSagasAndRecords.mustache +120 -0
- package/templates/typescript-fetch/sagaApiManager.mustache +28 -0
- package/templates/typescript-fetch/sagas.mustache +245 -0
- package/templates/typescript-fetch/sourceLibraryIndex.mustache +1 -0
- package/templates/typescript-fetch/tsconfig.esm.mustache +7 -0
- package/templates/typescript-fetch/tsconfig.mustache +25 -0
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* {{classname}}
|
|
4
|
+
* PHP version 7.2
|
|
5
|
+
*
|
|
6
|
+
* @category Class
|
|
7
|
+
* @package {{invokerPackage}}
|
|
8
|
+
* @author OpenAPI Generator team
|
|
9
|
+
* @link https://openapi-generator.tech
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
{{>partial_header}}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
16
|
+
* https://openapi-generator.tech
|
|
17
|
+
* Do not edit the class manually.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
namespace {{apiPackage}};
|
|
21
|
+
|
|
22
|
+
use GuzzleHttp\Psr7\MultipartStream;
|
|
23
|
+
use Http\Client\Common\Plugin\ErrorPlugin;
|
|
24
|
+
use Http\Client\Common\Plugin\RedirectPlugin;
|
|
25
|
+
use Http\Client\Common\PluginClient;
|
|
26
|
+
use Http\Client\Common\PluginClientFactory;
|
|
27
|
+
use Http\Client\Exception\HttpException;
|
|
28
|
+
use Http\Client\HttpAsyncClient;
|
|
29
|
+
use Http\Discovery\HttpAsyncClientDiscovery;
|
|
30
|
+
use Http\Discovery\Psr17FactoryDiscovery;
|
|
31
|
+
use Http\Discovery\Psr18ClientDiscovery;
|
|
32
|
+
use Http\Message\RequestFactory;
|
|
33
|
+
use Http\Promise\Promise;
|
|
34
|
+
use {{invokerPackage}}\ApiException;
|
|
35
|
+
use {{invokerPackage}}\Configuration;
|
|
36
|
+
use {{invokerPackage}}\DebugPlugin;
|
|
37
|
+
use {{invokerPackage}}\HeaderSelector;
|
|
38
|
+
use {{invokerPackage}}\FormDataProcessor;
|
|
39
|
+
use {{invokerPackage}}\ObjectSerializer;
|
|
40
|
+
use Psr\Http\Client\ClientExceptionInterface;
|
|
41
|
+
use Psr\Http\Client\ClientInterface;
|
|
42
|
+
use Psr\Http\Message\RequestFactoryInterface;
|
|
43
|
+
use Psr\Http\Message\RequestInterface;
|
|
44
|
+
use Psr\Http\Message\ResponseInterface;
|
|
45
|
+
use Psr\Http\Message\StreamFactoryInterface;
|
|
46
|
+
use Psr\Http\Message\UriFactoryInterface;
|
|
47
|
+
use Psr\Http\Message\UriInterface;
|
|
48
|
+
use function sprintf;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* {{classname}} Class Doc Comment
|
|
52
|
+
*
|
|
53
|
+
* @category Class
|
|
54
|
+
* @package {{invokerPackage}}
|
|
55
|
+
* @author OpenAPI Generator team
|
|
56
|
+
* @link https://openapi-generator.tech
|
|
57
|
+
*/
|
|
58
|
+
{{#operations}}class {{classname}}
|
|
59
|
+
{
|
|
60
|
+
/**
|
|
61
|
+
* @var PluginClient
|
|
62
|
+
*/
|
|
63
|
+
protected $httpClient;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @var PluginClient
|
|
67
|
+
*/
|
|
68
|
+
protected $httpAsyncClient;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @var UriFactoryInterface
|
|
72
|
+
*/
|
|
73
|
+
protected $uriFactory;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @var Configuration
|
|
77
|
+
*/
|
|
78
|
+
protected $config;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @var HeaderSelector
|
|
82
|
+
*/
|
|
83
|
+
protected $headerSelector;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @var int Host index
|
|
87
|
+
*/
|
|
88
|
+
protected $hostIndex;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @var RequestFactoryInterface
|
|
92
|
+
*/
|
|
93
|
+
protected $requestFactory;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @var StreamFactoryInterface
|
|
97
|
+
*/
|
|
98
|
+
protected $streamFactory;
|
|
99
|
+
|
|
100
|
+
public function __construct(
|
|
101
|
+
?ClientInterface $httpClient = null,
|
|
102
|
+
?Configuration $config = null,
|
|
103
|
+
?HttpAsyncClient $httpAsyncClient = null,
|
|
104
|
+
?UriFactoryInterface $uriFactory = null,
|
|
105
|
+
?RequestFactoryInterface $requestFactory = null,
|
|
106
|
+
?StreamFactoryInterface $streamFactory = null,
|
|
107
|
+
?HeaderSelector $selector = null,
|
|
108
|
+
?array $plugins = null,
|
|
109
|
+
$hostIndex = 0
|
|
110
|
+
) {
|
|
111
|
+
$this->config = $config ?? (new Configuration())->setHost('{{basePath}}');
|
|
112
|
+
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
|
|
113
|
+
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
|
|
114
|
+
|
|
115
|
+
$plugins = $plugins ?? [
|
|
116
|
+
new RedirectPlugin(['strict' => true]),
|
|
117
|
+
new ErrorPlugin(),
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
if ($this->config->getDebug()) {
|
|
121
|
+
$plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
$this->httpClient = (new PluginClientFactory())->createClient(
|
|
125
|
+
$httpClient ?? Psr18ClientDiscovery::find(),
|
|
126
|
+
$plugins
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
$this->httpAsyncClient = (new PluginClientFactory())->createClient(
|
|
130
|
+
$httpAsyncClient ?? HttpAsyncClientDiscovery::find(),
|
|
131
|
+
$plugins
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
$this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
|
|
135
|
+
|
|
136
|
+
$this->headerSelector = $selector ?? new HeaderSelector();
|
|
137
|
+
|
|
138
|
+
$this->hostIndex = $hostIndex;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Set the host index
|
|
143
|
+
*
|
|
144
|
+
* @param int $hostIndex Host index (required)
|
|
145
|
+
*/
|
|
146
|
+
public function setHostIndex($hostIndex): void
|
|
147
|
+
{
|
|
148
|
+
$this->hostIndex = $hostIndex;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get the host index
|
|
153
|
+
*
|
|
154
|
+
* @return int Host index
|
|
155
|
+
*/
|
|
156
|
+
public function getHostIndex()
|
|
157
|
+
{
|
|
158
|
+
return $this->hostIndex;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @return Configuration
|
|
163
|
+
*/
|
|
164
|
+
public function getConfig()
|
|
165
|
+
{
|
|
166
|
+
return $this->config;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
{{#operation}}
|
|
170
|
+
/**
|
|
171
|
+
* Operation {{{operationId}}}
|
|
172
|
+
{{#if summary}}
|
|
173
|
+
*
|
|
174
|
+
* {{summary}}
|
|
175
|
+
{{/if}}
|
|
176
|
+
*
|
|
177
|
+
{{#if description}}
|
|
178
|
+
* {{description}}
|
|
179
|
+
*
|
|
180
|
+
{{/if}}
|
|
181
|
+
{{#exts.x-group-parameters}}
|
|
182
|
+
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
|
183
|
+
*
|
|
184
|
+
{{/exts.x-group-parameters}}
|
|
185
|
+
{{#servers}}
|
|
186
|
+
{{#if @first}}
|
|
187
|
+
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
|
188
|
+
{{/if}}
|
|
189
|
+
* URL: {{{url}}}
|
|
190
|
+
{{#if @last}}
|
|
191
|
+
*
|
|
192
|
+
{{/if}}
|
|
193
|
+
{{/servers}}
|
|
194
|
+
{{#allParams}}
|
|
195
|
+
* @param {{{dataType}}} ${{paramName}}{{#if description}} {{description}}{{/if}}{{#unless description}} {{paramName}}{{/unless}} {{#required}}(required){{/required}}{{^required}}(optional{{#if defaultValue}}, default to {{{defaultValue}}}{{/if}}){{/required}}
|
|
196
|
+
{{/allParams}}
|
|
197
|
+
*
|
|
198
|
+
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
|
199
|
+
* @throws \InvalidArgumentException
|
|
200
|
+
* @return {{#if returnType}}{{#responses}}{{#dataType}}{{#unless @first}}|{{/unless}}{{/dataType}}{{{dataType}}}{{/responses}}{{/if}}{{#unless returnType}}void{{/unless}}
|
|
201
|
+
*/
|
|
202
|
+
public function {{operationId}}({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
203
|
+
{
|
|
204
|
+
{{#if returnType}}list($response) = {{/if}}$this->{{operationId}}WithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});{{#if returnType}}
|
|
205
|
+
return $response;{{/if}}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Operation {{{operationId}}}WithHttpInfo
|
|
210
|
+
{{#if summary}}
|
|
211
|
+
*
|
|
212
|
+
* {{summary}}
|
|
213
|
+
{{/if}}
|
|
214
|
+
*
|
|
215
|
+
{{#if description}}
|
|
216
|
+
* {{description}}
|
|
217
|
+
*
|
|
218
|
+
{{/if}}
|
|
219
|
+
{{#exts.x-group-parameters}}
|
|
220
|
+
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
|
221
|
+
*
|
|
222
|
+
{{/exts.x-group-parameters}}
|
|
223
|
+
{{#servers}}
|
|
224
|
+
{{#if @first}}
|
|
225
|
+
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
|
226
|
+
{{/if}}
|
|
227
|
+
* URL: {{{url}}}
|
|
228
|
+
{{#if @last}}
|
|
229
|
+
*
|
|
230
|
+
{{/if}}
|
|
231
|
+
{{/servers}}
|
|
232
|
+
{{#allParams}}
|
|
233
|
+
* @param {{{dataType}}} ${{paramName}}{{#if description}} {{description}}{{/if}} {{#required}}(required){{/required}}{{^required}}(optional{{#if defaultValue}}, default to {{{defaultValue}}}{{/if}}){{/required}}
|
|
234
|
+
{{/allParams}}
|
|
235
|
+
*
|
|
236
|
+
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
|
237
|
+
* @throws \InvalidArgumentException
|
|
238
|
+
* @return array of {{#if returnType}}{{#responses}}{{#dataType}}{{#unless @first}}|{{/unless}}{{/dataType}}{{{dataType}}}{{/responses}}{{/if}}{{#unless returnType}}null{{/unless}}, HTTP status code, HTTP response headers (array of strings)
|
|
239
|
+
*/
|
|
240
|
+
public function {{operationId}}WithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
241
|
+
{
|
|
242
|
+
$request = $this->{{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
try {
|
|
246
|
+
$response = $this->httpClient->sendRequest($request);
|
|
247
|
+
} catch (HttpException $e) {
|
|
248
|
+
$response = $e->getResponse();
|
|
249
|
+
throw new ApiException(
|
|
250
|
+
sprintf(
|
|
251
|
+
'[%d] Error connecting to the API (%s)',
|
|
252
|
+
$response->getStatusCode(),
|
|
253
|
+
(string) $request->getUri()
|
|
254
|
+
),
|
|
255
|
+
$request,
|
|
256
|
+
$response,
|
|
257
|
+
$e
|
|
258
|
+
);
|
|
259
|
+
} catch (ClientExceptionInterface $e) {
|
|
260
|
+
throw new ApiException(
|
|
261
|
+
"[{$e->getCode()}] {$e->getMessage()}",
|
|
262
|
+
$request,
|
|
263
|
+
null,
|
|
264
|
+
$e
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
$statusCode = $response->getStatusCode();
|
|
269
|
+
|
|
270
|
+
{{#if returnType}}
|
|
271
|
+
{{#responses}}
|
|
272
|
+
{{#if @first}}
|
|
273
|
+
|
|
274
|
+
switch($statusCode) {
|
|
275
|
+
{{/if}}
|
|
276
|
+
{{#dataType}}
|
|
277
|
+
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
|
|
278
|
+
return $this->handleResponseWithDataType(
|
|
279
|
+
'{{{dataType}}}',
|
|
280
|
+
$request,
|
|
281
|
+
$response,
|
|
282
|
+
);{{/isRange}}
|
|
283
|
+
{{/dataType}}
|
|
284
|
+
{{#if @last}}
|
|
285
|
+
}
|
|
286
|
+
{{/if}}
|
|
287
|
+
{{/responses}}
|
|
288
|
+
|
|
289
|
+
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}if ($this->responseWithinRangeCode('{{code}}', $statusCode)) {
|
|
290
|
+
return $this->handleResponseWithDataType(
|
|
291
|
+
'{{{dataType}}}',
|
|
292
|
+
$request,
|
|
293
|
+
$response,
|
|
294
|
+
);
|
|
295
|
+
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
|
|
296
|
+
|
|
297
|
+
if ($statusCode < 200 || $statusCode > 299) {
|
|
298
|
+
throw new ApiException(
|
|
299
|
+
sprintf(
|
|
300
|
+
'[%d] Error connecting to the API (%s)',
|
|
301
|
+
$statusCode,
|
|
302
|
+
(string) $request->getUri()
|
|
303
|
+
),
|
|
304
|
+
$request,
|
|
305
|
+
$response
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return $this->handleResponseWithDataType(
|
|
310
|
+
'{{{returnType}}}',
|
|
311
|
+
$request,
|
|
312
|
+
$response,
|
|
313
|
+
);
|
|
314
|
+
{{/if}}
|
|
315
|
+
{{#unless returnType}}
|
|
316
|
+
|
|
317
|
+
return [null, $statusCode, $response->getHeaders()];
|
|
318
|
+
{{/unless}}
|
|
319
|
+
} catch (ApiException $e) {
|
|
320
|
+
switch ($e->getCode()) {
|
|
321
|
+
{{#responses}}
|
|
322
|
+
{{#dataType}}
|
|
323
|
+
{{^isRange}}{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
|
|
324
|
+
$data = ObjectSerializer::deserialize(
|
|
325
|
+
$e->getResponseBody(),
|
|
326
|
+
'{{{dataType}}}',
|
|
327
|
+
$e->getResponseHeaders()
|
|
328
|
+
);
|
|
329
|
+
$e->setResponseObject($data);
|
|
330
|
+
throw $e;{{/isRange}}
|
|
331
|
+
{{/dataType}}
|
|
332
|
+
{{/responses}}
|
|
333
|
+
}
|
|
334
|
+
{{#responses}}{{#dataType}}{{#isRange}}{{^isWildcard}}
|
|
335
|
+
if ($this->responseWithinRangeCode('{{code}}', $e->getCode())) {
|
|
336
|
+
$data = ObjectSerializer::deserialize(
|
|
337
|
+
$e->getResponseBody(),
|
|
338
|
+
'{{{dataType}}}',
|
|
339
|
+
$e->getResponseHeaders()
|
|
340
|
+
);
|
|
341
|
+
$e->setResponseObject($data);
|
|
342
|
+
throw $e;
|
|
343
|
+
}{{/isWildcard}}{{/isRange}}{{/dataType}}{{/responses}}
|
|
344
|
+
|
|
345
|
+
throw $e;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Operation {{{operationId}}}Async
|
|
351
|
+
*
|
|
352
|
+
{{#if summary}}
|
|
353
|
+
* {{summary}}
|
|
354
|
+
*
|
|
355
|
+
{{/if}}
|
|
356
|
+
{{#if description}}
|
|
357
|
+
* {{description}}
|
|
358
|
+
*
|
|
359
|
+
{{/if}}
|
|
360
|
+
{{#exts.x-group-parameters}}
|
|
361
|
+
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
|
362
|
+
*
|
|
363
|
+
{{/exts.x-group-parameters}}
|
|
364
|
+
{{#servers}}
|
|
365
|
+
{{#if @first}}
|
|
366
|
+
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
|
367
|
+
{{/if}}
|
|
368
|
+
* URL: {{{url}}}
|
|
369
|
+
{{#if @last}}
|
|
370
|
+
*
|
|
371
|
+
{{/if}}
|
|
372
|
+
{{/servers}}
|
|
373
|
+
{{#allParams}}
|
|
374
|
+
* @param {{{dataType}}} ${{paramName}}{{#if description}} {{description}}{{/if}} {{#required}}(required){{/required}}{{^required}}(optional{{#if defaultValue}}, default to {{{defaultValue}}}{{/if}}){{/required}}
|
|
375
|
+
{{/allParams}}
|
|
376
|
+
*
|
|
377
|
+
* @throws \InvalidArgumentException
|
|
378
|
+
* @return Promise
|
|
379
|
+
*/
|
|
380
|
+
public function {{operationId}}Async({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
381
|
+
{
|
|
382
|
+
return $this->{{operationId}}AsyncWithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
383
|
+
->then(
|
|
384
|
+
function ($response) {
|
|
385
|
+
return $response[0];
|
|
386
|
+
}
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Operation {{{operationId}}}AsyncWithHttpInfo
|
|
392
|
+
*
|
|
393
|
+
{{#if summary}}
|
|
394
|
+
* {{summary}}
|
|
395
|
+
*
|
|
396
|
+
{{/if}}
|
|
397
|
+
{{#if description}}
|
|
398
|
+
* {{description}}
|
|
399
|
+
*
|
|
400
|
+
{{/if}}
|
|
401
|
+
{{#exts.x-group-parameters}}
|
|
402
|
+
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
|
403
|
+
*
|
|
404
|
+
{{/exts.x-group-parameters}}
|
|
405
|
+
{{#servers}}
|
|
406
|
+
{{#if @first}}
|
|
407
|
+
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
|
408
|
+
{{/if}}
|
|
409
|
+
* URL: {{{url}}}
|
|
410
|
+
{{#if @last}}
|
|
411
|
+
*
|
|
412
|
+
{{/if}}
|
|
413
|
+
{{/servers}}
|
|
414
|
+
{{#allParams}}
|
|
415
|
+
* @param {{{dataType}}} ${{paramName}}{{#if description}} {{description}}{{/if}} {{#required}}(required){{/required}}{{^required}}(optional{{#if defaultValue}}, default to {{{defaultValue}}}{{/if}}){{/required}}
|
|
416
|
+
{{/allParams}}
|
|
417
|
+
*
|
|
418
|
+
* @throws \InvalidArgumentException
|
|
419
|
+
* @return Promise
|
|
420
|
+
*/
|
|
421
|
+
public function {{operationId}}AsyncWithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
422
|
+
{
|
|
423
|
+
$returnType = '{{{returnType}}}';
|
|
424
|
+
$request = $this->{{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});
|
|
425
|
+
|
|
426
|
+
return $this->httpAsyncClient->sendAsyncRequest($request)
|
|
427
|
+
->then(
|
|
428
|
+
function ($response) use ($returnType) {
|
|
429
|
+
{{#if returnType}}
|
|
430
|
+
if ($returnType === '\SplFileObject') {
|
|
431
|
+
$content = $response->getBody(); //stream goes to serializer
|
|
432
|
+
} else {
|
|
433
|
+
$content = (string) $response->getBody();
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return [
|
|
437
|
+
ObjectSerializer::deserialize($content, $returnType, []),
|
|
438
|
+
$response->getStatusCode(),
|
|
439
|
+
$response->getHeaders()
|
|
440
|
+
];
|
|
441
|
+
{{/if}}
|
|
442
|
+
{{#unless returnType}}
|
|
443
|
+
return [null, $response->getStatusCode(), $response->getHeaders()];
|
|
444
|
+
{{/unless}}
|
|
445
|
+
},
|
|
446
|
+
function (HttpException $exception) {
|
|
447
|
+
$response = $exception->getResponse();
|
|
448
|
+
$statusCode = $response->getStatusCode();
|
|
449
|
+
throw new ApiException(
|
|
450
|
+
sprintf(
|
|
451
|
+
'[%d] Error connecting to the API (%s)',
|
|
452
|
+
$statusCode,
|
|
453
|
+
$exception->getRequest()->getUri()
|
|
454
|
+
),
|
|
455
|
+
$exception->getRequest(),
|
|
456
|
+
$exception->getResponse(),
|
|
457
|
+
$exception
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Create request for operation '{{{operationId}}}'
|
|
465
|
+
*
|
|
466
|
+
{{#exts.x-group-parameters}}
|
|
467
|
+
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
|
468
|
+
*
|
|
469
|
+
{{/exts.x-group-parameters}}
|
|
470
|
+
{{#servers}}
|
|
471
|
+
{{#if @first}}
|
|
472
|
+
* This operation contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
|
473
|
+
{{/if}}
|
|
474
|
+
* URL: {{{url}}}
|
|
475
|
+
{{#if @last}}
|
|
476
|
+
*
|
|
477
|
+
{{/if}}
|
|
478
|
+
{{/servers}}
|
|
479
|
+
{{#allParams}}
|
|
480
|
+
* @param {{{dataType}}} ${{paramName}}{{#if description}} {{description}}{{/if}} {{#required}}(required){{/required}}{{^required}}(optional{{#if defaultValue}}, default to {{{defaultValue}}}{{/if}}){{/required}}
|
|
481
|
+
{{/allParams}}
|
|
482
|
+
*
|
|
483
|
+
* @throws \InvalidArgumentException
|
|
484
|
+
* @return RequestInterface
|
|
485
|
+
*/
|
|
486
|
+
public function {{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
|
|
487
|
+
{
|
|
488
|
+
{{#exts.x-group-parameters}}
|
|
489
|
+
// unbox the parameters from the associative array
|
|
490
|
+
{{#allParams}}
|
|
491
|
+
${{paramName}} = array_key_exists('{{paramName}}', $associative_array) ? $associative_array['{{paramName}}'] : {{{defaultValue}}}{{#unless defaultValue}}null{{/unless}};
|
|
492
|
+
{{/allParams}}
|
|
493
|
+
|
|
494
|
+
{{/exts.x-group-parameters}}
|
|
495
|
+
{{#allParams}}
|
|
496
|
+
{{#required}}
|
|
497
|
+
// verify the required parameter '{{paramName}}' is set
|
|
498
|
+
if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) {
|
|
499
|
+
throw new \InvalidArgumentException(
|
|
500
|
+
'Missing the required parameter ${{paramName}} when calling {{operationId}}'
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
{{/required}}
|
|
504
|
+
{{#hasValidation}}
|
|
505
|
+
{{#if maxLength}}
|
|
506
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) > {{maxLength}}) {
|
|
507
|
+
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
|
|
508
|
+
}
|
|
509
|
+
{{/if}}
|
|
510
|
+
{{#if minLength}}
|
|
511
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) < {{minLength}}) {
|
|
512
|
+
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
|
|
513
|
+
}
|
|
514
|
+
{{/if}}
|
|
515
|
+
{{#if maximum}}
|
|
516
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}) {
|
|
517
|
+
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.');
|
|
518
|
+
}
|
|
519
|
+
{{/if}}
|
|
520
|
+
{{#if minimum}}
|
|
521
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}) {
|
|
522
|
+
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.');
|
|
523
|
+
}
|
|
524
|
+
{{/if}}
|
|
525
|
+
{{#if pattern}}
|
|
526
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}!preg_match("{{{pattern}}}", ${{paramName}})) {
|
|
527
|
+
throw new \InvalidArgumentException("invalid value for \"{{paramName}}\" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.");
|
|
528
|
+
}
|
|
529
|
+
{{/if}}
|
|
530
|
+
{{#maxItems}}
|
|
531
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) > {{maxItems}}) {
|
|
532
|
+
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.');
|
|
533
|
+
}
|
|
534
|
+
{{/maxItems}}
|
|
535
|
+
{{#minItems}}
|
|
536
|
+
if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) < {{minItems}}) {
|
|
537
|
+
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.');
|
|
538
|
+
}
|
|
539
|
+
{{/minItems}}
|
|
540
|
+
|
|
541
|
+
{{/hasValidation}}
|
|
542
|
+
{{/allParams}}
|
|
543
|
+
|
|
544
|
+
$resourcePath = '{{{path}}}';
|
|
545
|
+
$formParams = [];
|
|
546
|
+
$queryParams = [];
|
|
547
|
+
$headerParams = [];
|
|
548
|
+
$httpBody = null;
|
|
549
|
+
$multipart = false;
|
|
550
|
+
|
|
551
|
+
{{#queryParams}}
|
|
552
|
+
// query params
|
|
553
|
+
{{#isExplode}}
|
|
554
|
+
if (${{paramName}} !== null) {
|
|
555
|
+
{{#style}}
|
|
556
|
+
if('form' === '{{style}}' && is_array(${{paramName}})) {
|
|
557
|
+
foreach(${{paramName}} as $key => $value) {
|
|
558
|
+
$queryParams[$key] = $value;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
$queryParams['{{baseName}}'] = ${{paramName}};
|
|
563
|
+
}
|
|
564
|
+
{{/style}}
|
|
565
|
+
{{^style}}
|
|
566
|
+
$queryParams['{{baseName}}'] = ${{paramName}};
|
|
567
|
+
{{/style}}
|
|
568
|
+
}
|
|
569
|
+
{{/isExplode}}
|
|
570
|
+
{{^isExplode}}
|
|
571
|
+
if (is_array(${{paramName}})) {
|
|
572
|
+
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{#style}}{{style}}{{/style}}{{^style}}{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}{{/style}}', true);
|
|
573
|
+
}
|
|
574
|
+
if (${{paramName}} !== null) {
|
|
575
|
+
$queryParams['{{baseName}}'] = ${{paramName}};
|
|
576
|
+
}
|
|
577
|
+
{{/isExplode}}
|
|
578
|
+
{{/queryParams}}
|
|
579
|
+
|
|
580
|
+
{{#headerParams}}
|
|
581
|
+
// header params
|
|
582
|
+
{{#collectionFormat}}
|
|
583
|
+
if (is_array(${{paramName}})) {
|
|
584
|
+
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}');
|
|
585
|
+
}
|
|
586
|
+
{{/collectionFormat}}
|
|
587
|
+
if (${{paramName}} !== null) {
|
|
588
|
+
$headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}});
|
|
589
|
+
}
|
|
590
|
+
{{/headerParams}}
|
|
591
|
+
|
|
592
|
+
{{#pathParams}}
|
|
593
|
+
// path params
|
|
594
|
+
{{#collectionFormat}}
|
|
595
|
+
if (is_array(${{paramName}})) {
|
|
596
|
+
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}');
|
|
597
|
+
}
|
|
598
|
+
{{/collectionFormat}}
|
|
599
|
+
if (${{paramName}} !== null) {
|
|
600
|
+
$resourcePath = str_replace(
|
|
601
|
+
'{' . '{{baseName}}' . '}',
|
|
602
|
+
ObjectSerializer::toPathValue(${{paramName}}),
|
|
603
|
+
$resourcePath
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
{{/pathParams}}
|
|
607
|
+
|
|
608
|
+
{{#formParams}}
|
|
609
|
+
{{#if @first}}
|
|
610
|
+
// form params
|
|
611
|
+
$formDataProcessor = new FormDataProcessor();
|
|
612
|
+
|
|
613
|
+
$formData = $formDataProcessor->prepare([
|
|
614
|
+
{{/if}}
|
|
615
|
+
'{{paramName}}' => ${{paramName}},
|
|
616
|
+
{{#if @last}}
|
|
617
|
+
]);
|
|
618
|
+
|
|
619
|
+
$formParams = $formDataProcessor->flatten($formData);
|
|
620
|
+
$multipart = $formDataProcessor->has_file;
|
|
621
|
+
{{/if}}
|
|
622
|
+
{{/formParams}}
|
|
623
|
+
|
|
624
|
+
$headers = $this->headerSelector->selectHeaders(
|
|
625
|
+
[{{#produces}}'{{{mediaType}}}'{{#unless @last}}, {{/unless}}{{/produces}}],
|
|
626
|
+
'{{#consumes}}{{{mediaType}}}{{/consumes}}',
|
|
627
|
+
$multipart
|
|
628
|
+
);
|
|
629
|
+
|
|
630
|
+
// for model (json/xml)
|
|
631
|
+
{{#bodyParams}}
|
|
632
|
+
if (isset(${{paramName}})) {
|
|
633
|
+
if ($this->headerSelector->isJsonMime($headers['Content-Type'])) {
|
|
634
|
+
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}));
|
|
635
|
+
} else {
|
|
636
|
+
$httpBody = ${{paramName}};
|
|
637
|
+
}
|
|
638
|
+
} elseif (count($formParams) > 0) {
|
|
639
|
+
{{/bodyParams}}
|
|
640
|
+
{{^bodyParams}}
|
|
641
|
+
if (count($formParams) > 0) {
|
|
642
|
+
{{/bodyParams}}
|
|
643
|
+
if ($multipart) {
|
|
644
|
+
$multipartContents = [];
|
|
645
|
+
foreach ($formParams as $formParamName => $formParamValue) {
|
|
646
|
+
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
|
|
647
|
+
foreach ($formParamValueItems as $formParamValueItem) {
|
|
648
|
+
$multipartContents[] = [
|
|
649
|
+
'name' => $formParamName,
|
|
650
|
+
'contents' => $formParamValueItem
|
|
651
|
+
];
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
// for HTTP post (form)
|
|
655
|
+
$httpBody = new MultipartStream($multipartContents);
|
|
656
|
+
|
|
657
|
+
} elseif ($this->headerSelector->isJsonMime($headers['Content-Type'])) {
|
|
658
|
+
$httpBody = json_encode($formParams);
|
|
659
|
+
|
|
660
|
+
} else {
|
|
661
|
+
// for HTTP post (form)
|
|
662
|
+
$httpBody = ObjectSerializer::buildQuery($formParams);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
{{#authMethods}}
|
|
667
|
+
{{#isApiKey}}
|
|
668
|
+
// this endpoint requires API key authentication
|
|
669
|
+
$apiKey = $this->config->getApiKeyWithPrefix('{{keyParamName}}');
|
|
670
|
+
if ($apiKey !== null) {
|
|
671
|
+
{{#isKeyInHeader}}$headers['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
|
|
672
|
+
}
|
|
673
|
+
{{/isApiKey}}
|
|
674
|
+
{{#isBasic}}
|
|
675
|
+
{{#isBasicBasic}}
|
|
676
|
+
// this endpoint requires HTTP basic authentication
|
|
677
|
+
if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) {
|
|
678
|
+
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
|
|
679
|
+
}
|
|
680
|
+
{{/isBasicBasic}}
|
|
681
|
+
{{#isBasicBearer}}
|
|
682
|
+
// this endpoint requires Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authentication (access token)
|
|
683
|
+
if ($this->config->getAccessToken() !== null) {
|
|
684
|
+
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
|
685
|
+
}
|
|
686
|
+
{{/isBasicBearer}}
|
|
687
|
+
{{/isBasic}}
|
|
688
|
+
{{#isOAuth}}
|
|
689
|
+
// this endpoint requires OAuth (access token)
|
|
690
|
+
if ($this->config->getAccessToken() !== null) {
|
|
691
|
+
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
|
692
|
+
}
|
|
693
|
+
{{/isOAuth}}
|
|
694
|
+
{{/authMethods}}
|
|
695
|
+
|
|
696
|
+
$defaultHeaders = [];
|
|
697
|
+
if ($this->config->getUserAgent()) {
|
|
698
|
+
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
$headers = array_merge(
|
|
702
|
+
$defaultHeaders,
|
|
703
|
+
$headerParams,
|
|
704
|
+
$headers
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
{{#unless servers}}
|
|
708
|
+
$operationHost = $this->config->getHost();
|
|
709
|
+
{{/if}}
|
|
710
|
+
{{#if servers}}
|
|
711
|
+
$operationHosts = [{{#servers}}"{{{url}}}"{{#unless @last}}, {{/unless}}{{/servers}}];
|
|
712
|
+
if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) {
|
|
713
|
+
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".sizeof($operationHosts));
|
|
714
|
+
}
|
|
715
|
+
$operationHost = $operationHosts[$this->hostIndex];
|
|
716
|
+
{{/if}}
|
|
717
|
+
|
|
718
|
+
$uri = $this->createUri($operationHost, $resourcePath, $queryParams);
|
|
719
|
+
|
|
720
|
+
return $this->createRequest('{{httpMethod}}', $uri, $headers, $httpBody);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
{{/operation}}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* @param string $method
|
|
727
|
+
* @param string|UriInterface $uri
|
|
728
|
+
* @param array $headers
|
|
729
|
+
* @param string|StreamInterface|null $body
|
|
730
|
+
*
|
|
731
|
+
* @return RequestInterface
|
|
732
|
+
*/
|
|
733
|
+
protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface
|
|
734
|
+
{
|
|
735
|
+
if ($this->requestFactory instanceof RequestFactory) {
|
|
736
|
+
return $this->requestFactory->createRequest(
|
|
737
|
+
$method,
|
|
738
|
+
$uri,
|
|
739
|
+
$headers,
|
|
740
|
+
$body
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
if (is_string($body) && '' !== $body && null === $this->streamFactory) {
|
|
745
|
+
throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.');
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
$request = $this->requestFactory->createRequest($method, $uri);
|
|
749
|
+
|
|
750
|
+
foreach ($headers as $key => $value) {
|
|
751
|
+
$request = $request->withHeader($key, $value);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
if (null !== $body && '' !== $body) {
|
|
755
|
+
$request = $request->withBody(
|
|
756
|
+
is_string($body) ? $this->streamFactory->createStream($body) : $body
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
return $request;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
private function createUri(
|
|
764
|
+
string $operationHost,
|
|
765
|
+
string $resourcePath,
|
|
766
|
+
array $queryParams
|
|
767
|
+
): UriInterface {
|
|
768
|
+
$parsedUrl = parse_url($operationHost);
|
|
769
|
+
|
|
770
|
+
$host = $parsedUrl['host'] ?? null;
|
|
771
|
+
$scheme = $parsedUrl['scheme'] ?? null;
|
|
772
|
+
$basePath = $parsedUrl['path'] ?? null;
|
|
773
|
+
$port = $parsedUrl['port'] ?? null;
|
|
774
|
+
$user = $parsedUrl['user'] ?? null;
|
|
775
|
+
$password = $parsedUrl['pass'] ?? null;
|
|
776
|
+
|
|
777
|
+
$uri = $this->uriFactory->createUri($basePath . $resourcePath)
|
|
778
|
+
->withHost($host)
|
|
779
|
+
->withScheme($scheme)
|
|
780
|
+
->withPort($port)
|
|
781
|
+
->withQuery(ObjectSerializer::buildQuery($queryParams));
|
|
782
|
+
|
|
783
|
+
if ($user) {
|
|
784
|
+
$uri = $uri->withUserInfo($user, $password);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
return $uri;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
private function handleResponseWithDataType(
|
|
791
|
+
string $dataType,
|
|
792
|
+
RequestInterface $request,
|
|
793
|
+
ResponseInterface $response
|
|
794
|
+
): array {
|
|
795
|
+
if ($dataType === '\SplFileObject') {
|
|
796
|
+
$content = $response->getBody(); //stream goes to serializer
|
|
797
|
+
} else {
|
|
798
|
+
$content = (string) $response->getBody();
|
|
799
|
+
if ($dataType !== 'string') {
|
|
800
|
+
try {
|
|
801
|
+
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
|
|
802
|
+
} catch (\JsonException $exception) {
|
|
803
|
+
throw new ApiException(
|
|
804
|
+
sprintf(
|
|
805
|
+
'Error JSON decoding server response (%s)',
|
|
806
|
+
$request->getUri()
|
|
807
|
+
),
|
|
808
|
+
$request,
|
|
809
|
+
$response,
|
|
810
|
+
$exception
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
return [
|
|
817
|
+
ObjectSerializer::deserialize($content, $dataType, []),
|
|
818
|
+
$response->getStatusCode(),
|
|
819
|
+
$response->getHeaders()
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
private function responseWithinRangeCode(
|
|
824
|
+
string $rangeCode,
|
|
825
|
+
int $statusCode
|
|
826
|
+
): bool {
|
|
827
|
+
$left = (int) ($rangeCode[0].'00');
|
|
828
|
+
$right = (int) ($rangeCode[0].'99');
|
|
829
|
+
|
|
830
|
+
return $statusCode >= $left && $statusCode <= $right;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
{{/operations}}
|