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