@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,572 @@
1
+ // checks if the {{classname}} type satisfies the MappedNullable interface at compile time
2
+ var _ MappedNullable = &{{classname}}{}
3
+
4
+ // {{classname}} {{{description}}}{{#unless description}}struct for {{{classname}}}{{/unless}}
5
+ type {{classname}} struct {
6
+ {{#parentModel.name}}
7
+ {{^isArray}}
8
+ {{{parentModel.classname}}}
9
+ {{/isArray}}
10
+ {{#isArray}}
11
+ Items {{{parentModel.classname}}}
12
+ {{/isArray}}
13
+ {{/parentModel.name}}
14
+ {{#vars}}
15
+ {{#unless @first}}
16
+ {{/unless}}
17
+ {{#if description}}
18
+ // {{{description}}}
19
+ {{/if}}
20
+ {{#deprecated}}
21
+ // Deprecated
22
+ {{/deprecated}}
23
+ {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}}{{{vendorExtensions.x-go-datatag}}}
24
+ {{/vars}}
25
+ {{#isAdditionalPropertiesTrue}}
26
+ AdditionalProperties map[string]interface{}
27
+ {{/isAdditionalPropertiesTrue}}
28
+ }
29
+
30
+ {{#isAdditionalPropertiesTrue}}
31
+ type _{{{classname}}} {{{classname}}}
32
+
33
+ {{/isAdditionalPropertiesTrue}}
34
+ {{^isAdditionalPropertiesTrue}}
35
+ {{#hasRequired}}
36
+ type _{{{classname}}} {{{classname}}}
37
+
38
+ {{/hasRequired}}
39
+ {{/isAdditionalPropertiesTrue}}
40
+ // New{{classname}} instantiates a new {{classname}} object
41
+ // This constructor will assign default values to properties that have it defined,
42
+ // and makes sure properties required by API are set, but the set of arguments
43
+ // will change when the set of required properties is changed
44
+ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{#unless @last}}, {{/unless}}{{/requiredVars}}) *{{classname}} {
45
+ this := {{classname}}{}
46
+ {{#allVars}}
47
+ {{#required}}
48
+ this.{{name}} = {{nameInCamelCase}}
49
+ {{/required}}
50
+ {{^required}}
51
+ {{#if defaultValue}}
52
+ {{^vendorExtensions.x-golang-is-container}}
53
+ {{^isReadOnly}}
54
+ {{#isNullable}}
55
+ var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{defaultValue}}}
56
+ this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
57
+ {{/isNullable}}
58
+ {{^isNullable}}
59
+ var {{nameInCamelCase}} {{{dataType}}} = {{{defaultValue}}}
60
+ this.{{name}} = &{{nameInCamelCase}}
61
+ {{/isNullable}}
62
+ {{/isReadOnly}}
63
+ {{/vendorExtensions.x-golang-is-container}}
64
+ {{/if}}
65
+ {{/required}}
66
+ {{/allVars}}
67
+ return &this
68
+ }
69
+
70
+ // New{{classname}}WithDefaults instantiates a new {{classname}} object
71
+ // This constructor will only assign default values to properties that have it defined,
72
+ // but it doesn't guarantee that properties required by API are set
73
+ func New{{classname}}WithDefaults() *{{classname}} {
74
+ this := {{classname}}{}
75
+ {{#vars}}
76
+ {{#if defaultValue}}
77
+ {{^vendorExtensions.x-golang-is-container}}
78
+ {{^isReadOnly}}
79
+ {{#isNullable}}
80
+ {{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}}
81
+ var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{defaultValue}}}
82
+ this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}})
83
+ {{/isNullable}}
84
+ {{^isNullable}}
85
+ var {{nameInCamelCase}} {{{dataType}}} = {{{defaultValue}}}
86
+ this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}}
87
+ {{/isNullable}}
88
+ {{/isReadOnly}}
89
+ {{/vendorExtensions.x-golang-is-container}}
90
+ {{/if}}
91
+ {{/vars}}
92
+ return &this
93
+ }
94
+
95
+ {{#vars}}
96
+ {{#required}}
97
+ // Get{{name}} returns the {{name}} field value
98
+ {{#isNullable}}
99
+ // If the value is explicit nil, the zero value for {{vendorExtensions.x-go-base-type}} will be returned
100
+ {{/isNullable}}
101
+ {{#deprecated}}
102
+ // Deprecated
103
+ {{/deprecated}}
104
+ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
105
+ if o == nil{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || o.{{name}}.Get() == nil{{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
106
+ var ret {{vendorExtensions.x-go-base-type}}
107
+ return ret
108
+ }
109
+
110
+ {{#isNullable}}
111
+ {{#vendorExtensions.x-golang-is-container}}
112
+ return o.{{name}}
113
+ {{/vendorExtensions.x-golang-is-container}}
114
+ {{^vendorExtensions.x-golang-is-container}}
115
+ return *o.{{name}}.Get()
116
+ {{/vendorExtensions.x-golang-is-container}}
117
+ {{/isNullable}}
118
+ {{^isNullable}}
119
+ return o.{{name}}
120
+ {{/isNullable}}
121
+ }
122
+
123
+ // Get{{name}}Ok returns a tuple with the {{name}} field value
124
+ // and a boolean to check if the value has been set.
125
+ {{#isNullable}}
126
+ // NOTE: If the value is an explicit nil, `nil, true` will be returned
127
+ {{/isNullable}}
128
+ {{#deprecated}}
129
+ // Deprecated
130
+ {{/deprecated}}
131
+ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
132
+ if o == nil{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
133
+ {{^isFreeFormObject}}
134
+ return nil, false
135
+ {{/isFreeFormObject}}
136
+ {{#isFreeFormObject}}
137
+ return {{vendorExtensions.x-go-base-type}}{}, false
138
+ {{/isFreeFormObject}}
139
+ }
140
+ {{#isNullable}}
141
+ {{#vendorExtensions.x-golang-is-container}}
142
+ return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true
143
+ {{/vendorExtensions.x-golang-is-container}}
144
+ {{^vendorExtensions.x-golang-is-container}}
145
+ return o.{{name}}.Get(), o.{{name}}.IsSet()
146
+ {{/vendorExtensions.x-golang-is-container}}
147
+ {{/isNullable}}
148
+ {{^isNullable}}
149
+ return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true
150
+ {{/isNullable}}
151
+ }
152
+
153
+ // Set{{name}} sets field value
154
+ {{#deprecated}}
155
+ // Deprecated
156
+ {{/deprecated}}
157
+ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
158
+ {{#isNullable}}
159
+ {{#vendorExtensions.x-golang-is-container}}
160
+ o.{{name}} = v
161
+ {{/vendorExtensions.x-golang-is-container}}
162
+ {{^vendorExtensions.x-golang-is-container}}
163
+ o.{{name}}.Set(&v)
164
+ {{/vendorExtensions.x-golang-is-container}}
165
+ {{/isNullable}}
166
+ {{^isNullable}}
167
+ o.{{name}} = v
168
+ {{/isNullable}}
169
+ }
170
+
171
+ {{#useDefaultValuesForRequiredVars}}
172
+ {{^isReadOnly}}
173
+ {{#if defaultValue}}
174
+ // GetDefault{{{nameInPascalCase}}} returns the default value {{{defaultValue}}} of the {{{name}}} field.
175
+ func (o *{{classname}}) GetDefault{{nameInPascalCase}}() interface{} {
176
+ return {{{defaultValue}}}
177
+ }
178
+ {{/if}}
179
+ {{/isReadOnly}}
180
+
181
+ {{/useDefaultValuesForRequiredVars}}
182
+ {{/required}}
183
+ {{^required}}
184
+ // Get{{name}} returns the {{name}} field value if set, zero value otherwise{{#isNullable}} (both if not set or set to explicit null){{/isNullable}}.
185
+ {{#deprecated}}
186
+ // Deprecated
187
+ {{/deprecated}}
188
+ func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}} {
189
+ if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{^vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}.Get()){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
190
+ var ret {{vendorExtensions.x-go-base-type}}
191
+ return ret
192
+ }
193
+ {{#isNullable}}
194
+ {{#vendorExtensions.x-golang-is-container}}
195
+ return o.{{name}}
196
+ {{/vendorExtensions.x-golang-is-container}}
197
+ {{^vendorExtensions.x-golang-is-container}}
198
+ return *o.{{name}}.Get()
199
+ {{/vendorExtensions.x-golang-is-container}}
200
+ {{/isNullable}}
201
+ {{^isNullable}}
202
+ return {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}o.{{name}}
203
+ {{/isNullable}}
204
+ }
205
+
206
+ // Get{{name}}Ok returns a tuple with the {{name}} field value if set, nil otherwise
207
+ // and a boolean to check if the value has been set.
208
+ {{#isNullable}}
209
+ // NOTE: If the value is an explicit nil, `nil, true` will be returned
210
+ {{/isNullable}}
211
+ {{#deprecated}}
212
+ // Deprecated
213
+ {{/deprecated}}
214
+ func (o *{{classname}}) Get{{name}}Ok() ({{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{vendorExtensions.x-go-base-type}}, bool) {
215
+ if o == nil{{^isNullable}} || IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}} || IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
216
+ {{^isFreeFormObject}}
217
+ return nil, false
218
+ {{/isFreeFormObject}}
219
+ {{#isFreeFormObject}}
220
+ return {{vendorExtensions.x-go-base-type}}{}, false
221
+ {{/isFreeFormObject}}
222
+ }
223
+ {{#isNullable}}
224
+ {{#vendorExtensions.x-golang-is-container}}
225
+ return {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}o.{{name}}, true
226
+ {{/vendorExtensions.x-golang-is-container}}
227
+ {{^vendorExtensions.x-golang-is-container}}
228
+ return o.{{name}}.Get(), o.{{name}}.IsSet()
229
+ {{/vendorExtensions.x-golang-is-container}}
230
+ {{/isNullable}}
231
+ {{^isNullable}}
232
+ return o.{{name}}, true
233
+ {{/isNullable}}
234
+ }
235
+
236
+ // Has{{name}} returns a boolean if a field has been set.
237
+ func (o *{{classname}}) Has{{name}}() bool {
238
+ if o != nil && {{^isNullable}}!IsNil(o.{{name}}){{/isNullable}}{{#isNullable}}{{#vendorExtensions.x-golang-is-container}}!IsNil(o.{{name}}){{/vendorExtensions.x-golang-is-container}}{{^vendorExtensions.x-golang-is-container}}o.{{name}}.IsSet(){{/vendorExtensions.x-golang-is-container}}{{/isNullable}} {
239
+ return true
240
+ }
241
+
242
+ return false
243
+ }
244
+
245
+ // Set{{name}} gets a reference to the given {{dataType}} and assigns it to the {{name}} field.
246
+ {{#deprecated}}
247
+ // Deprecated
248
+ {{/deprecated}}
249
+ func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}}) {
250
+ {{#isNullable}}
251
+ {{#vendorExtensions.x-golang-is-container}}
252
+ o.{{name}} = v
253
+ {{/vendorExtensions.x-golang-is-container}}
254
+ {{^vendorExtensions.x-golang-is-container}}
255
+ o.{{name}}.Set({{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v)
256
+ {{/vendorExtensions.x-golang-is-container}}
257
+ {{/isNullable}}
258
+ {{^isNullable}}
259
+ o.{{name}} = {{^isArray}}{{^isFreeFormObject}}&{{/isFreeFormObject}}{{/isArray}}v
260
+ {{/isNullable}}
261
+ }
262
+ {{#isNullable}}
263
+ {{^vendorExtensions.x-golang-is-container}}
264
+ // Set{{name}}Nil sets the value for {{name}} to be an explicit nil
265
+ func (o *{{classname}}) Set{{name}}Nil() {
266
+ o.{{name}}.Set(nil)
267
+ }
268
+
269
+ // Unset{{name}} ensures that no value is present for {{name}}, not even an explicit nil
270
+ func (o *{{classname}}) Unset{{name}}() {
271
+ o.{{name}}.Unset()
272
+ }
273
+ {{/vendorExtensions.x-golang-is-container}}
274
+ {{/isNullable}}
275
+
276
+ {{/required}}
277
+ {{/vars}}
278
+ {{#vendorExtensions.x-go-generate-marshal-json}}
279
+ func (o {{classname}}) MarshalJSON() ([]byte, error) {
280
+ toSerialize,err := o.ToMap()
281
+ if err != nil {
282
+ return []byte{}, err
283
+ }
284
+ return json.Marshal(toSerialize)
285
+ }
286
+
287
+ {{/vendorExtensions.x-go-generate-marshal-json}}
288
+ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
289
+ toSerialize := {{#isArray}}make([]interface{}, len(o.Items)){{/isArray}}{{^isArray}}map[string]interface{}{}{{/isArray}}
290
+ {{#parent}}
291
+ {{^isMap}}
292
+ {{^isArray}}
293
+ serialized{{parent}}, err{{parent}} := json.Marshal(o.{{parent}})
294
+ if err{{parent}} != nil {
295
+ return map[string]interface{}{}, err{{parent}}
296
+ }
297
+ err{{parent}} = json.Unmarshal([]byte(serialized{{parent}}), &toSerialize)
298
+ if err{{parent}} != nil {
299
+ return map[string]interface{}{}, err{{parent}}
300
+ }
301
+ {{/isArray}}
302
+ {{/isMap}}
303
+ {{#isArray}}
304
+ for i, item := range o.Items {
305
+ toSerialize[i] = item
306
+ }
307
+ {{/isArray}}
308
+ {{/parent}}
309
+ {{#vars}}
310
+ {{! if argument is nullable, only serialize it if it is set}}
311
+ {{#isNullable}}
312
+ {{#vendorExtensions.x-golang-is-container}}
313
+ {{! support for container fields is not ideal at this point because of lack of Nullable* types}}
314
+ if o.{{name}} != nil {
315
+ toSerialize["{{{baseName}}}"] = o.{{name}}
316
+ }
317
+ {{/vendorExtensions.x-golang-is-container}}
318
+ {{^vendorExtensions.x-golang-is-container}}
319
+ {{#required}}
320
+ toSerialize["{{{baseName}}}"] = o.{{name}}.Get()
321
+ {{/required}}
322
+ {{^required}}
323
+ if o.{{name}}.IsSet() {
324
+ toSerialize["{{{baseName}}}"] = o.{{name}}.Get()
325
+ }
326
+ {{/required}}
327
+ {{/vendorExtensions.x-golang-is-container}}
328
+ {{/isNullable}}
329
+ {{! if argument is not nullable, don't set it if it is nil}}
330
+ {{^isNullable}}
331
+ {{#required}}
332
+ {{#useDefaultValuesForRequiredVars}}
333
+ {{^isReadOnly}}
334
+ {{#if defaultValue}}
335
+ if _, exists := toSerialize["{{{baseName}}}"]; !exists {
336
+ toSerialize["{{{baseName}}}"] = o.GetDefault{{nameInPascalCase}}()
337
+ }
338
+ {{/if}}
339
+ {{/isReadOnly}}
340
+ {{/useDefaultValuesForRequiredVars}}
341
+ toSerialize["{{{baseName}}}"] = o.{{name}}
342
+ {{/required}}
343
+ {{^required}}
344
+ if !IsNil(o.{{name}}) {
345
+ toSerialize["{{{baseName}}}"] = o.{{name}}
346
+ }
347
+ {{/required}}
348
+ {{/isNullable}}
349
+ {{/vars}}
350
+ {{#isAdditionalPropertiesTrue}}
351
+
352
+ for key, value := range o.AdditionalProperties {
353
+ toSerialize[key] = value
354
+ }
355
+
356
+ {{/isAdditionalPropertiesTrue}}
357
+ return toSerialize, nil
358
+ }
359
+
360
+ {{#vendorExtensions.x-go-generate-unmarshal-json}}
361
+ {{#isAdditionalPropertiesTrue}}
362
+ func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) {
363
+ {{/isAdditionalPropertiesTrue}}
364
+ {{^isAdditionalPropertiesTrue}}
365
+ {{#hasRequired}}
366
+ func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) {
367
+ {{/hasRequired}}
368
+ {{/isAdditionalPropertiesTrue}}
369
+ {{#hasRequired}}
370
+ // This validates that all required properties are included in the JSON object
371
+ // by unmarshalling the object into a generic map with string keys and checking
372
+ // that every required field exists as a key in the generic map.
373
+ requiredProperties := []string{
374
+ {{#requiredVars}}
375
+ "{{baseName}}",
376
+ {{/requiredVars}}
377
+ }
378
+
379
+ {{#useDefaultValuesForRequiredVars}}
380
+ // defaultValueFuncMap captures the default values for required properties.
381
+ // These values are used when required properties are missing from the payload.
382
+ defaultValueFuncMap := map[string]func() interface{} {
383
+ {{#requiredVars}}
384
+ {{#if defaultValue}}
385
+ {{^isReadOnly}}
386
+ "{{baseName}}": o.GetDefault{{nameInPascalCase}},
387
+ {{/isReadOnly}}
388
+ {{/if}}
389
+ {{/requiredVars}}
390
+ }
391
+ var defaultValueApplied bool
392
+ {{/useDefaultValuesForRequiredVars}}
393
+ allProperties := make(map[string]interface{})
394
+
395
+ err = json.Unmarshal(data, &allProperties)
396
+
397
+ if err != nil {
398
+ return err;
399
+ }
400
+
401
+ for _, requiredProperty := range(requiredProperties) {
402
+ {{#useDefaultValuesForRequiredVars}}
403
+ if value, exists := allProperties[requiredProperty]; !exists || value == "" {
404
+ if _, ok := defaultValueFuncMap[requiredProperty]; ok {
405
+ allProperties[requiredProperty] = defaultValueFuncMap[requiredProperty]()
406
+ defaultValueApplied = true
407
+ }
408
+ }
409
+ if value, exists := allProperties[requiredProperty]; !exists || value == ""{
410
+ {{/useDefaultValuesForRequiredVars}}
411
+ {{^useDefaultValuesForRequiredVars}}
412
+ if _, exists := allProperties[requiredProperty]; !exists {
413
+ {{/useDefaultValuesForRequiredVars}}
414
+ return fmt.Errorf("no value given for required property %v", requiredProperty)
415
+ }
416
+ }
417
+
418
+ {{#useDefaultValuesForRequiredVars}}
419
+ if defaultValueApplied {
420
+ data, err = json.Marshal(allProperties)
421
+ if err != nil{
422
+ return err
423
+ }
424
+ }
425
+ {{/useDefaultValuesForRequiredVars}}
426
+ {{/hasRequired}}
427
+ {{#isAdditionalPropertiesTrue}}
428
+ {{#parent}}
429
+ {{^isMap}}
430
+ type {{classname}}WithoutEmbeddedStruct struct {
431
+ {{#vars}}
432
+ {{#unless @first}}
433
+ {{/unless}}
434
+ {{#if description}}
435
+ // {{{description}}}
436
+ {{/if}}
437
+ {{#deprecated}}
438
+ // Deprecated
439
+ {{/deprecated}}
440
+ {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}}{{{vendorExtensions.x-go-datatag}}}
441
+ {{/vars}}
442
+ }
443
+
444
+ var{{{classname}}}WithoutEmbeddedStruct := {{{classname}}}WithoutEmbeddedStruct{}
445
+
446
+ err = json.Unmarshal(data, &var{{{classname}}}WithoutEmbeddedStruct)
447
+ if err == nil {
448
+ var{{{classname}}} := _{{{classname}}}{}
449
+ {{#vars}}
450
+ var{{{classname}}}.{{{name}}} = var{{{classname}}}WithoutEmbeddedStruct.{{{name}}}
451
+ {{/vars}}
452
+ *o = {{{classname}}}(var{{{classname}}})
453
+ } else {
454
+ return err
455
+ }
456
+
457
+ var{{{classname}}} := _{{{classname}}}{}
458
+
459
+ err = json.Unmarshal(data, &var{{{classname}}})
460
+ if err == nil {
461
+ o.{{{parent}}} = var{{{classname}}}.{{{parent}}}
462
+ } else {
463
+ return err
464
+ }
465
+
466
+ additionalProperties := make(map[string]interface{})
467
+
468
+ if err = json.Unmarshal(data, &additionalProperties); err == nil {
469
+ {{#vars}}
470
+ delete(additionalProperties, "{{{baseName}}}")
471
+ {{/vars}}
472
+
473
+ // remove fields from embedded structs
474
+ reflect{{{parent}}} := reflect.ValueOf(o.{{{parent}}})
475
+ for i := 0; i < reflect{{{parent}}}.Type().NumField(); i++ {
476
+ t := reflect{{{parent}}}.Type().Field(i)
477
+
478
+ if jsonTag := t.Tag.Get("json"); jsonTag != "" {
479
+ fieldName := ""
480
+ if commaIdx := strings.Index(jsonTag, ","); commaIdx > 0 {
481
+ fieldName = jsonTag[:commaIdx]
482
+ } else {
483
+ fieldName = jsonTag
484
+ }
485
+ if fieldName != "AdditionalProperties" {
486
+ delete(additionalProperties, fieldName)
487
+ }
488
+ }
489
+ }
490
+
491
+ o.AdditionalProperties = additionalProperties
492
+ }
493
+
494
+ return err
495
+ {{/isMap}}
496
+ {{#isMap}}
497
+ var{{{classname}}} := _{{{classname}}}{}
498
+
499
+ err = json.Unmarshal(data, &var{{{classname}}})
500
+
501
+ if err != nil {
502
+ return err
503
+ }
504
+
505
+ *o = {{{classname}}}(var{{{classname}}})
506
+
507
+ additionalProperties := make(map[string]interface{})
508
+
509
+ if err = json.Unmarshal(data, &additionalProperties); err == nil {
510
+ {{#vars}}
511
+ delete(additionalProperties, "{{{baseName}}}")
512
+ {{/vars}}
513
+ o.AdditionalProperties = additionalProperties
514
+ }
515
+
516
+ return err
517
+ {{/isMap}}
518
+ {{/parent}}
519
+ {{^parent}}
520
+ var{{{classname}}} := _{{{classname}}}{}
521
+
522
+ err = json.Unmarshal(data, &var{{{classname}}})
523
+
524
+ if err != nil {
525
+ return err
526
+ }
527
+
528
+ *o = {{{classname}}}(var{{{classname}}})
529
+
530
+ additionalProperties := make(map[string]interface{})
531
+
532
+ if err = json.Unmarshal(data, &additionalProperties); err == nil {
533
+ {{#vars}}
534
+ delete(additionalProperties, "{{{baseName}}}")
535
+ {{/vars}}
536
+ o.AdditionalProperties = additionalProperties
537
+ }
538
+
539
+ return err
540
+ {{/parent}}
541
+ {{/isAdditionalPropertiesTrue}}
542
+ {{#isAdditionalPropertiesTrue}}
543
+ }
544
+
545
+ {{/isAdditionalPropertiesTrue}}
546
+ {{^isAdditionalPropertiesTrue}}
547
+ {{#hasRequired}}
548
+ var{{{classname}}} := _{{{classname}}}{}
549
+
550
+ decoder := json.NewDecoder(bytes.NewReader(data))
551
+ decoder.DisallowUnknownFields()
552
+ err = decoder.Decode(&var{{{classname}}})
553
+
554
+ if err != nil {
555
+ return err
556
+ }
557
+
558
+ *o = {{{classname}}}(var{{{classname}}})
559
+
560
+ return err
561
+ }
562
+
563
+ {{/hasRequired}}
564
+ {{/isAdditionalPropertiesTrue}}
565
+ {{#isArray}}
566
+ func (o *{{{classname}}}) UnmarshalJSON(data []byte) (err error) {
567
+ return json.Unmarshal(data, &o.Items)
568
+ }
569
+
570
+ {{/isArray}}
571
+ {{/vendorExtensions.x-go-generate-unmarshal-json}}
572
+ {{>nullable_model}}
@@ -0,0 +1,35 @@
1
+ type Nullable{{{classname}}} struct {
2
+ value {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{{classname}}}
3
+ isSet bool
4
+ }
5
+
6
+ func (v Nullable{{classname}}) Get() {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}} {
7
+ return v.value
8
+ }
9
+
10
+ func (v *Nullable{{classname}}) Set(val {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}}) {
11
+ v.value = val
12
+ v.isSet = true
13
+ }
14
+
15
+ func (v Nullable{{classname}}) IsSet() bool {
16
+ return v.isSet
17
+ }
18
+
19
+ func (v *Nullable{{classname}}) Unset() {
20
+ v.value = nil
21
+ v.isSet = false
22
+ }
23
+
24
+ func NewNullable{{classname}}(val {{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{classname}}) *Nullable{{classname}} {
25
+ return &Nullable{{classname}}{value: val, isSet: true}
26
+ }
27
+
28
+ func (v Nullable{{{classname}}}) MarshalJSON() ([]byte, error) {
29
+ return json.Marshal(v.value)
30
+ }
31
+
32
+ func (v *Nullable{{{classname}}}) UnmarshalJSON(src []byte) error {
33
+ v.isSet = true
34
+ return json.Unmarshal(src, &v.value)
35
+ }
@@ -0,0 +1 @@
1
+ {{{openapi-yaml}}}
@@ -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
+ API version: {{{version}}}
12
+ {{/if}}
13
+ {{#if infoEmail}}
14
+ Contact: {{{infoEmail}}}
15
+ {{/if}}
16
+ */
17
+
18
+ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
@@ -0,0 +1,38 @@
1
+ {{>partial_header}}
2
+ package {{packageName}}
3
+
4
+ import (
5
+ "net/http"
6
+ )
7
+
8
+ // APIResponse stores the API response returned by the server.
9
+ type APIResponse struct {
10
+ *http.Response `json:"-"`
11
+ Message string `json:"message,omitempty"`
12
+ // Operation is the name of the OpenAPI operation.
13
+ Operation string `json:"operation,omitempty"`
14
+ // RequestURL is the request URL. This value is always available, even if the
15
+ // embedded *http.Response is nil.
16
+ RequestURL string `json:"url,omitempty"`
17
+ // Method is the HTTP method used for the request. This value is always
18
+ // available, even if the embedded *http.Response is nil.
19
+ Method string `json:"method,omitempty"`
20
+ // Payload holds the contents of the response body (which may be nil or empty).
21
+ // This is provided here as the raw response.Body() reader will have already
22
+ // been drained.
23
+ Payload []byte `json:"-"`
24
+ }
25
+
26
+ // NewAPIResponse returns a new APIResponse object.
27
+ func NewAPIResponse(r *http.Response) *APIResponse {
28
+
29
+ response := &APIResponse{Response: r}
30
+ return response
31
+ }
32
+
33
+ // NewAPIResponseWithError returns a new APIResponse object with the provided error message.
34
+ func NewAPIResponseWithError(errorMessage string) *APIResponse {
35
+
36
+ response := &APIResponse{Message: errorMessage}
37
+ return response
38
+ }