@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,565 @@
1
+ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^parentSchema}}implements ModelInterface, ArrayAccess, \JsonSerializable{{/parentSchema}}
2
+ {
3
+ public const DISCRIMINATOR = {{#discriminator}}'{{discriminatorName}}'{{/discriminator}}{{^discriminator}}null{{/discriminator}};
4
+
5
+ /**
6
+ * The original name of the model.
7
+ *
8
+ * @var string
9
+ */
10
+ protected static $openAPIModelName = '{{name}}';
11
+
12
+ /**
13
+ * Array of property to type mappings. Used for (de)serialization
14
+ *
15
+ * @var string[]
16
+ */
17
+ protected static $openAPITypes = [
18
+ {{#vars}}'{{name}}' => '{{{dataType}}}'{{#unless @last}},
19
+ {{/unless}}{{/vars}}
20
+ ];
21
+
22
+ /**
23
+ * Array of property to format mappings. Used for (de)serialization
24
+ *
25
+ * @var string[]
26
+ * @phpstan-var array<string, string|null>
27
+ * @psalm-var array<string, string|null>
28
+ */
29
+ protected static $openAPIFormats = [
30
+ {{#vars}}'{{name}}' => {{#if dataFormat}}'{{{dataFormat}}}'{{/if}}{{#unless dataFormat}}null{{/unless}}{{#unless @last}},
31
+ {{/unless}}{{/vars}}
32
+ ];
33
+
34
+ /**
35
+ * Array of nullable properties. Used for (de)serialization
36
+ *
37
+ * @var boolean[]
38
+ */
39
+ protected static array $openAPINullables = [
40
+ {{#vars}}'{{name}}' => {{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}}{{#unless @last}},
41
+ {{/unless}}{{/vars}}
42
+ ];
43
+
44
+ /**
45
+ * If a nullable field gets set to null, insert it here
46
+ *
47
+ * @var boolean[]
48
+ */
49
+ protected array $openAPINullablesSetToNull = [];
50
+
51
+ /**
52
+ * Array of property to type mappings. Used for (de)serialization
53
+ *
54
+ * @return array
55
+ */
56
+ public static function openAPITypes()
57
+ {
58
+ return self::$openAPITypes{{#parentSchema}} + parent::openAPITypes(){{/parentSchema}};
59
+ }
60
+
61
+ /**
62
+ * Array of property to format mappings. Used for (de)serialization
63
+ *
64
+ * @return array
65
+ */
66
+ public static function openAPIFormats()
67
+ {
68
+ return self::$openAPIFormats{{#parentSchema}} + parent::openAPIFormats(){{/parentSchema}};
69
+ }
70
+
71
+ /**
72
+ * Array of nullable properties
73
+ *
74
+ * @return array
75
+ */
76
+ protected static function openAPINullables(): array
77
+ {
78
+ return self::$openAPINullables{{#parentSchema}} + parent::openAPINullables(){{/parentSchema}};
79
+ }
80
+
81
+ /**
82
+ * Array of nullable field names deliberately set to null
83
+ *
84
+ * @return boolean[]
85
+ */
86
+ private function getOpenAPINullablesSetToNull(): array
87
+ {
88
+ return $this->openAPINullablesSetToNull;
89
+ }
90
+
91
+ /**
92
+ * Setter - Array of nullable field names deliberately set to null
93
+ *
94
+ * @param boolean[] $openAPINullablesSetToNull
95
+ */
96
+ private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
97
+ {
98
+ $this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
99
+ }
100
+
101
+ /**
102
+ * Checks if a property is nullable
103
+ *
104
+ * @param string $property
105
+ * @return bool
106
+ */
107
+ public static function isNullable(string $property): bool
108
+ {
109
+ return self::openAPINullables()[$property] ?? false;
110
+ }
111
+
112
+ /**
113
+ * Checks if a nullable property is set to null.
114
+ *
115
+ * @param string $property
116
+ * @return bool
117
+ */
118
+ public function isNullableSetToNull(string $property): bool
119
+ {
120
+ return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
121
+ }
122
+
123
+ /**
124
+ * Array of attributes where the key is the local name,
125
+ * and the value is the original name
126
+ *
127
+ * @var string[]
128
+ */
129
+ protected static $attributeMap = [
130
+ {{#vars}}'{{name}}' => '{{baseName}}'{{#unless @last}},
131
+ {{/unless}}{{/vars}}
132
+ ];
133
+
134
+ /**
135
+ * Array of attributes to setter functions (for deserialization of responses)
136
+ *
137
+ * @var string[]
138
+ */
139
+ protected static $setters = [
140
+ {{#vars}}'{{name}}' => '{{setter}}'{{#unless @last}},
141
+ {{/unless}}{{/vars}}
142
+ ];
143
+
144
+ /**
145
+ * Array of attributes to getter functions (for serialization of requests)
146
+ *
147
+ * @var string[]
148
+ */
149
+ protected static $getters = [
150
+ {{#vars}}'{{name}}' => '{{getter}}'{{#unless @last}},
151
+ {{/unless}}{{/vars}}
152
+ ];
153
+
154
+ /**
155
+ * Array of attributes where the key is the local name,
156
+ * and the value is the original name
157
+ *
158
+ * @return array
159
+ */
160
+ public static function attributeMap()
161
+ {
162
+ return {{#parentSchema}}parent::attributeMap() + {{/parentSchema}}self::$attributeMap;
163
+ }
164
+
165
+ /**
166
+ * Array of attributes to setter functions (for deserialization of responses)
167
+ *
168
+ * @return array
169
+ */
170
+ public static function setters()
171
+ {
172
+ return {{#parentSchema}}parent::setters() + {{/parentSchema}}self::$setters;
173
+ }
174
+
175
+ /**
176
+ * Array of attributes to getter functions (for serialization of requests)
177
+ *
178
+ * @return array
179
+ */
180
+ public static function getters()
181
+ {
182
+ return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
183
+ }
184
+
185
+ /**
186
+ * The original name of the model.
187
+ *
188
+ * @return string
189
+ */
190
+ public function getModelName()
191
+ {
192
+ return self::$openAPIModelName;
193
+ }
194
+
195
+ {{#vars}}
196
+ {{#isEnum}}
197
+ {{#allowableValues}}
198
+ {{#enumVars}}
199
+ public const {{enumName}}_{{{name}}} = {{{value}}};
200
+ {{/enumVars}}
201
+ {{/allowableValues}}
202
+ {{/isEnum}}
203
+ {{/vars}}
204
+
205
+ {{#vars}}
206
+ {{#isEnum}}
207
+ /**
208
+ * Gets allowable values of the enum
209
+ *
210
+ * @return string[]
211
+ */
212
+ public function {{getter}}AllowableValues()
213
+ {
214
+ return [
215
+ {{#allowableValues}}{{#enumVars}}self::{{enumName}}_{{{name}}},{{#unless @last}}
216
+ {{/unless}}{{/enumVars}}{{/allowableValues}}
217
+ ];
218
+ }
219
+
220
+ {{/isEnum}}
221
+ {{/vars}}
222
+ {{^parentSchema}}
223
+ /**
224
+ * Associative array for storing property values
225
+ *
226
+ * @var mixed[]
227
+ */
228
+ protected $container = [];
229
+ {{/parentSchema}}
230
+
231
+ /**
232
+ * Constructor
233
+ *
234
+ * @param mixed[]|null $data Associated array of property values
235
+ * initializing the model
236
+ */
237
+ public function __construct(?array $data = null)
238
+ {
239
+ {{#parentSchema}}
240
+ parent::__construct($data);
241
+
242
+ {{/parentSchema}}
243
+ {{#vars}}
244
+ $this->setIfExists('{{name}}', $data ?? [], {{#if defaultValue}}{{{defaultValue}}}{{/if}}{{#unless defaultValue}}null{{/unless}});
245
+ {{/vars}}
246
+ {{#discriminator}}
247
+
248
+ // Initialize discriminator property with the model name.
249
+ $this->container['{{discriminatorName}}'] = static::$openAPIModelName;
250
+ {{/discriminator}}
251
+ }
252
+
253
+ /**
254
+ * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
255
+ * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
256
+ * $this->openAPINullablesSetToNull array
257
+ *
258
+ * @param string $variableName
259
+ * @param array $fields
260
+ * @param mixed $defaultValue
261
+ */
262
+ private function setIfExists(string $variableName, array $fields, $defaultValue): void
263
+ {
264
+ if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
265
+ $this->openAPINullablesSetToNull[] = $variableName;
266
+ }
267
+
268
+ $this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
269
+ }
270
+
271
+ /**
272
+ * Show all the invalid properties with reasons.
273
+ *
274
+ * @return array invalid properties with reasons
275
+ */
276
+ public function listInvalidProperties()
277
+ {
278
+ {{#parentSchema}}
279
+ $invalidProperties = parent::listInvalidProperties();
280
+ {{/parentSchema}}
281
+ {{^parentSchema}}
282
+ $invalidProperties = [];
283
+ {{/parentSchema}}
284
+
285
+ {{#vars}}
286
+ {{#required}}
287
+ if ($this->container['{{name}}'] === null{{#isNullable}} && !$this->isNullableSetToNull('{{name}}'){{/isNullable}}) {
288
+ $invalidProperties[] = "'{{name}}' can't be null";
289
+ }
290
+ {{/required}}
291
+ {{#isEnum}}
292
+ {{^isContainer}}
293
+ $allowedValues = $this->{{getter}}AllowableValues();
294
+ if (!is_null($this->container['{{name}}']) && !in_array($this->container['{{name}}'], $allowedValues, true)) {
295
+ $invalidProperties[] = sprintf(
296
+ "invalid value '%s' for '{{name}}', must be one of '%s'",
297
+ $this->container['{{name}}'],
298
+ implode("', '", $allowedValues)
299
+ );
300
+ }
301
+
302
+ {{/isContainer}}
303
+ {{/isEnum}}
304
+ {{#hasValidation}}
305
+ {{#if maxLength}}
306
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(mb_strlen($this->container['{{name}}']) > {{maxLength}})) {
307
+ $invalidProperties[] = "invalid value for '{{name}}', the character length must be smaller than or equal to {{{maxLength}}}.";
308
+ }
309
+
310
+ {{/if}}
311
+ {{#if minLength}}
312
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(mb_strlen($this->container['{{name}}']) < {{minLength}})) {
313
+ $invalidProperties[] = "invalid value for '{{name}}', the character length must be bigger than or equal to {{{minLength}}}.";
314
+ }
315
+
316
+ {{/if}}
317
+ {{#if maximum}}
318
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) {
319
+ $invalidProperties[] = "invalid value for '{{name}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.";
320
+ }
321
+
322
+ {{/if}}
323
+ {{#if minimum}}
324
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}($this->container['{{name}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) {
325
+ $invalidProperties[] = "invalid value for '{{name}}', must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.";
326
+ }
327
+
328
+ {{/if}}
329
+ {{#if pattern}}
330
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}!preg_match("{{{pattern}}}", $this->container['{{name}}'])) {
331
+ $invalidProperties[] = "invalid value for '{{name}}', must be conform to the pattern {{{pattern}}}.";
332
+ }
333
+
334
+ {{/if}}
335
+ {{#maxItems}}
336
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(count($this->container['{{name}}']) > {{maxItems}})) {
337
+ $invalidProperties[] = "invalid value for '{{name}}', number of items must be less than or equal to {{{maxItems}}}.";
338
+ }
339
+
340
+ {{/maxItems}}
341
+ {{#minItems}}
342
+ if ({{^required}}!is_null($this->container['{{name}}']) && {{/required}}(count($this->container['{{name}}']) < {{minItems}})) {
343
+ $invalidProperties[] = "invalid value for '{{name}}', number of items must be greater than or equal to {{{minItems}}}.";
344
+ }
345
+
346
+ {{/minItems}}
347
+ {{/hasValidation}}
348
+ {{/vars}}
349
+ return $invalidProperties;
350
+ }
351
+
352
+ /**
353
+ * Validate all the properties in the model
354
+ * return true if all passed
355
+ *
356
+ * @return bool True if all properties are valid
357
+ */
358
+ public function valid()
359
+ {
360
+ return count($this->listInvalidProperties()) === 0;
361
+ }
362
+
363
+ {{#vars}}
364
+
365
+ /**
366
+ * Gets {{name}}
367
+ *
368
+ * @return {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}}
369
+ {{#deprecated}}
370
+ * @deprecated
371
+ {{/deprecated}}
372
+ */
373
+ public function {{getter}}()
374
+ {
375
+ return $this->container['{{name}}'];
376
+ }
377
+
378
+ /**
379
+ * Sets {{name}}
380
+ *
381
+ * @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{name}}{{#if description}} {{{description}}}{{/if}}{{#unless description}} {{{name}}}{{/unless}}
382
+ *
383
+ * @return self
384
+ {{#deprecated}}
385
+ * @deprecated
386
+ {{/deprecated}}
387
+ */
388
+ public function {{setter}}(${{name}})
389
+ {
390
+ {{#isNullable}}
391
+ if (is_null(${{name}})) {
392
+ array_push($this->openAPINullablesSetToNull, '{{name}}');
393
+ } else {
394
+ $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
395
+ $index = array_search('{{name}}', $nullablesSetToNull);
396
+ if ($index !== FALSE) {
397
+ unset($nullablesSetToNull[$index]);
398
+ $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
399
+ }
400
+ }
401
+ {{/isNullable}}
402
+ {{^isNullable}}
403
+ if (is_null(${{name}})) {
404
+ throw new \InvalidArgumentException('non-nullable {{name}} cannot be null');
405
+ }
406
+ {{/isNullable}}
407
+ {{#isEnum}}
408
+ $allowedValues = $this->{{getter}}AllowableValues();
409
+ {{^isContainer}}
410
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}!in_array(${{{name}}}, $allowedValues, true)) {
411
+ {{#enumUnknownDefaultCase}}
412
+ ${{name}} = {{#allowableValues}}{{#enumVars}}{{#if @last}}self::{{enumName}}_{{{name}}};{{/if}}{{/enumVars}}{{/allowableValues}}
413
+ {{/enumUnknownDefaultCase}}
414
+ {{^enumUnknownDefaultCase}}
415
+ throw new \InvalidArgumentException(
416
+ sprintf(
417
+ "Invalid value '%s' for '{{name}}', must be one of '%s'",
418
+ ${{{name}}},
419
+ implode("', '", $allowedValues)
420
+ )
421
+ );
422
+ {{/enumUnknownDefaultCase}}
423
+ }
424
+ {{/isContainer}}
425
+ {{#isContainer}}
426
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}array_diff(${{{name}}}, $allowedValues)) {
427
+ throw new \InvalidArgumentException(
428
+ sprintf(
429
+ "Invalid value for '{{name}}', must be one of '%s'",
430
+ implode("', '", $allowedValues)
431
+ )
432
+ );
433
+ }
434
+ {{/isContainer}}
435
+ {{/isEnum}}
436
+ {{#hasValidation}}
437
+ {{#if maxLength}}
438
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(mb_strlen(${{name}}) > {{maxLength}})) {
439
+ throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
440
+ }{{/if}}
441
+ {{#if minLength}}
442
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(mb_strlen(${{name}}) < {{minLength}})) {
443
+ throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
444
+ }
445
+ {{/if}}
446
+ {{#if maximum}}
447
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(${{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}})) {
448
+ throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.');
449
+ }
450
+ {{/if}}
451
+ {{#if minimum}}
452
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(${{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}})) {
453
+ throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.');
454
+ }
455
+ {{/if}}
456
+ {{#if pattern}}
457
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(!preg_match("{{{pattern}}}", ObjectSerializer::toString(${{name}})))) {
458
+ throw new \InvalidArgumentException("invalid value for \${{name}} when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.");
459
+ }
460
+ {{/if}}
461
+ {{#maxItems}}
462
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(count(${{name}}) > {{maxItems}})) {
463
+ throw new \InvalidArgumentException('invalid value for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.');
464
+ }{{/maxItems}}
465
+ {{#minItems}}
466
+ if ({{#isNullable}}!is_null(${{name}}) && {{/isNullable}}(count(${{name}}) < {{minItems}})) {
467
+ throw new \InvalidArgumentException('invalid length for ${{name}} when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.');
468
+ }
469
+ {{/minItems}}
470
+ {{/hasValidation}}
471
+ $this->container['{{name}}'] = ${{name}};
472
+
473
+ return $this;
474
+ }
475
+ {{/vars}}
476
+ /**
477
+ * Returns true if offset exists. False otherwise.
478
+ *
479
+ * @param integer|string $offset Offset
480
+ *
481
+ * @return boolean
482
+ */
483
+ public function offsetExists(mixed $offset): bool
484
+ {
485
+ return isset($this->container[$offset]);
486
+ }
487
+
488
+ /**
489
+ * Gets offset.
490
+ *
491
+ * @param integer|string $offset Offset
492
+ *
493
+ * @return mixed|null
494
+ */
495
+ #[\ReturnTypeWillChange]
496
+ public function offsetGet(mixed $offset)
497
+ {
498
+ return $this->container[$offset] ?? null;
499
+ }
500
+
501
+ /**
502
+ * Sets value based on offset.
503
+ *
504
+ * @param int|null $offset Offset
505
+ * @param mixed $value Value to be set
506
+ *
507
+ * @return void
508
+ */
509
+ public function offsetSet($offset, $value): void
510
+ {
511
+ if (is_null($offset)) {
512
+ $this->container[] = $value;
513
+ } else {
514
+ $this->container[$offset] = $value;
515
+ }
516
+ }
517
+
518
+ /**
519
+ * Unsets offset.
520
+ *
521
+ * @param integer|string $offset Offset
522
+ *
523
+ * @return void
524
+ */
525
+ public function offsetUnset(mixed $offset): void
526
+ {
527
+ unset($this->container[$offset]);
528
+ }
529
+
530
+ /**
531
+ * Serializes the object to a value that can be serialized natively by json_encode().
532
+ * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
533
+ *
534
+ * @return mixed Returns data which can be serialized by json_encode(), which is a value
535
+ * of any type other than a resource.
536
+ */
537
+ #[\ReturnTypeWillChange]
538
+ public function jsonSerialize()
539
+ {
540
+ return ObjectSerializer::sanitizeForSerialization($this);
541
+ }
542
+
543
+ /**
544
+ * Gets the string presentation of the object
545
+ *
546
+ * @return string
547
+ */
548
+ public function __toString()
549
+ {
550
+ return json_encode(
551
+ ObjectSerializer::sanitizeForSerialization($this),
552
+ JSON_PRETTY_PRINT
553
+ );
554
+ }
555
+
556
+ /**
557
+ * Gets a header-safe presentation of the object
558
+ *
559
+ * @return string
560
+ */
561
+ public function toHeaderValue()
562
+ {
563
+ return json_encode(ObjectSerializer::sanitizeForSerialization($this));
564
+ }
565
+ }
@@ -0,0 +1,88 @@
1
+ <?php
2
+ {{#models}}
3
+ {{#model}}
4
+ /**
5
+ * {{classname}}Test
6
+ *
7
+ * PHP version 8.1
8
+ *
9
+ * @category Class
10
+ * @package {{invokerPackage}}
11
+ * @author OpenAPI Generator team
12
+ * @link https://openapi-generator.tech
13
+ */
14
+
15
+ {{>partial_header}}
16
+
17
+ /**
18
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19
+ * https://openapi-generator.tech
20
+ * Please update the test case below to test the model.
21
+ */
22
+
23
+ namespace {{invokerPackage}}\Test\Model;
24
+
25
+ use PHPUnit\Framework\TestCase;
26
+
27
+ /**
28
+ * {{classname}}Test Class Doc Comment
29
+ *
30
+ * @category Class
31
+ * @description {{description}}{{#unless description}}{{classname}}{{/unless}}
32
+ * @package {{invokerPackage}}
33
+ * @author OpenAPI Generator team
34
+ * @link https://openapi-generator.tech
35
+ */
36
+ class {{classname}}Test extends TestCase
37
+ {
38
+
39
+ /**
40
+ * Setup before running any test case
41
+ */
42
+ public static function setUpBeforeClass(): void
43
+ {
44
+ }
45
+
46
+ /**
47
+ * Setup before running each test case
48
+ */
49
+ public function setUp(): void
50
+ {
51
+ }
52
+
53
+ /**
54
+ * Clean up after running each test case
55
+ */
56
+ public function tearDown(): void
57
+ {
58
+ }
59
+
60
+ /**
61
+ * Clean up after running all test cases
62
+ */
63
+ public static function tearDownAfterClass(): void
64
+ {
65
+ }
66
+
67
+ /**
68
+ * Test "{{classname}}"
69
+ */
70
+ public function test{{classname}}()
71
+ {
72
+ // TODO: implement
73
+ self::markTestIncomplete('Not implemented');
74
+ }
75
+ {{#vars}}
76
+
77
+ /**
78
+ * Test attribute "{{name}}"
79
+ */
80
+ public function testProperty{{nameInPascalCase}}()
81
+ {
82
+ // TODO: implement
83
+ self::markTestIncomplete('Not implemented');
84
+ }
85
+ {{/vars}}
86
+ }
87
+ {{/model}}
88
+ {{/models}}
@@ -0,0 +1,18 @@
1
+ /**
2
+ {{#if appName}}
3
+ * {{{appName}}}
4
+ *
5
+ {{/if}}
6
+ {{#if appDescription}}
7
+ * {{{appDescription}}}
8
+ *
9
+ {{/if}}
10
+ {{#if version}}
11
+ * The version of the OpenAPI document: {{{version}}}
12
+ {{/if}}
13
+ {{#if infoEmail}}
14
+ * Contact: {{{infoEmail}}}
15
+ {{/if}}
16
+ * Generated by: https://openapi-generator.tech
17
+ * Generator version: {{{generatorVersion}}}
18
+ */
@@ -0,0 +1,23 @@
1
+ {{#hasAuthMethods}}{{#authMethods}}
2
+ {{#isBasic}}
3
+ {{#isBasicBasic}}
4
+ // Configure HTTP basic authorization: {{{name}}}
5
+ $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()
6
+ ->setUsername('YOUR_USERNAME')
7
+ ->setPassword('YOUR_PASSWORD');
8
+ {{/isBasicBasic}}
9
+ {{#isBasicBearer}}
10
+ // Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authorization: {{{name}}}
11
+ $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
12
+ {{/isBasicBearer}}
13
+ {{/isBasic}}
14
+ {{#isApiKey}}
15
+ // Configure API key authorization: {{{name}}}
16
+ $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
17
+ // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
18
+ // $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');
19
+ {{/isApiKey}}
20
+ {{#isOAuth}}
21
+ // Configure OAuth2 access token for authorization: {{{name}}}
22
+ $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
23
+ {{/isOAuth}}{{/authMethods}}{{/hasAuthMethods}}