@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,236 @@
1
+ # Go API client for {{packageName}}
2
+
3
+ {{#if appDescriptionWithNewLines}}
4
+ {{{appDescriptionWithNewLines}}}
5
+ {{/if}}
6
+
7
+ ## Overview
8
+ This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
9
+
10
+ - API version: {{appVersion}}
11
+ - Package version: {{packageVersion}}
12
+ {{^hideGenerationTimestamp}}
13
+ - Build date: {{generatedDate}}
14
+ {{/hideGenerationTimestamp}}
15
+ - Generator version: {{generatorVersion}}
16
+ - Build package: {{generatorClass}}
17
+ {{#if infoUrl}}
18
+ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
19
+ {{/if}}
20
+
21
+ ## Installation
22
+
23
+ Install the following dependencies:
24
+
25
+ ```sh
26
+ go get github.com/stretchr/testify/assert
27
+ {{#hasOAuthMethods}}
28
+ go get golang.org/x/oauth2
29
+ {{/hasOAuthMethods}}
30
+ go get golang.org/x/net/context
31
+ ```
32
+
33
+ Put the package under your project folder and add the following in import:
34
+
35
+ ```go
36
+ import {{packageName}} "{{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}"
37
+ ```
38
+
39
+ To use a proxy, set the environment variable `HTTP_PROXY`:
40
+
41
+ ```go
42
+ os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
43
+ ```
44
+
45
+ ## Configuration of Server URL
46
+
47
+ Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
48
+
49
+ ### Select Server Configuration
50
+
51
+ For using other server than the one defined on index 0 set context value `{{packageName}}.ContextServerIndex` of type `int`.
52
+
53
+ ```go
54
+ ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerIndex, 1)
55
+ ```
56
+
57
+ ### Templated Server URL
58
+
59
+ Templated server URL is formatted using default variables from configuration or from context value `{{packageName}}.ContextServerVariables` of type `map[string]string`.
60
+
61
+ ```go
62
+ ctx := context.WithValue(context.Background(), {{packageName}}.ContextServerVariables, map[string]string{
63
+ "basePath": "v2",
64
+ })
65
+ ```
66
+
67
+ Note, enum values are always validated and all unused variables are silently ignored.
68
+
69
+ ### URLs Configuration per Operation
70
+
71
+ Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
72
+ An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
73
+ Similar rules for overriding default operation server index and variables applies by using `{{packageName}}.ContextOperationServerIndices` and `{{packageName}}.ContextOperationServerVariables` context maps.
74
+
75
+ ```go
76
+ ctx := context.WithValue(context.Background(), {{packageName}}.ContextOperationServerIndices, map[string]int{
77
+ "{classname}Service.{nickname}": 2,
78
+ })
79
+ ctx = context.WithValue(context.Background(), {{packageName}}.ContextOperationServerVariables, map[string]map[string]string{
80
+ "{classname}Service.{nickname}": {
81
+ "port": "8443",
82
+ },
83
+ })
84
+ ```
85
+
86
+ ## Documentation for API Endpoints
87
+
88
+ All URIs are relative to *{{basePath}}*
89
+
90
+ Class | Method | HTTP request | Description
91
+ ------------ | ------------- | ------------- | -------------
92
+ {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
93
+ {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
94
+
95
+ ## Documentation For Models
96
+
97
+ {{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
98
+ {{/model}}{{/models}}
99
+
100
+ ## Documentation For Authorization
101
+
102
+ {{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
103
+ {{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
104
+ {{#authMethods}}
105
+ ### {{{name}}}
106
+
107
+ {{#isApiKey}}
108
+ - **Type**: API key
109
+ - **API key parameter name**: {{{keyParamName}}}
110
+ - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
111
+
112
+ Note, each API key must be added to a map of `map[string]APIKey` where the key is: {{name}} and passed in as the auth context for each request.
113
+
114
+ Example
115
+
116
+ ```go
117
+ auth := context.WithValue(
118
+ context.Background(),
119
+ {{packageName}}.ContextAPIKeys,
120
+ map[string]{{packageName}}.APIKey{
121
+ "{{name}}": {Key: "API_KEY_STRING"},
122
+ },
123
+ )
124
+ r, err := client.Service.Operation(auth, args)
125
+ ```
126
+
127
+ {{/isApiKey}}
128
+ {{#isBasic}}
129
+ {{#isBasicBearer}}
130
+ - **Type**: HTTP Bearer token authentication
131
+
132
+ Example
133
+
134
+ ```go
135
+ auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "BEARER_TOKEN_STRING")
136
+ r, err := client.Service.Operation(auth, args)
137
+ ```
138
+
139
+ {{/isBasicBearer}}
140
+ {{#isBasicBasic}}
141
+ - **Type**: HTTP basic authentication
142
+
143
+ Example
144
+
145
+ ```go
146
+ auth := context.WithValue(context.Background(), {{packageName}}.ContextBasicAuth, {{packageName}}.BasicAuth{
147
+ UserName: "username",
148
+ Password: "password",
149
+ })
150
+ r, err := client.Service.Operation(auth, args)
151
+ ```
152
+
153
+ {{/isBasicBasic}}
154
+ {{#isHttpSignature}}
155
+ - **Type**: HTTP signature authentication
156
+
157
+ Example
158
+
159
+ ```go
160
+ authConfig := {{packageName}}.HttpSignatureAuth{
161
+ KeyId: "my-key-id",
162
+ PrivateKeyPath: "rsa.pem",
163
+ Passphrase: "my-passphrase",
164
+ SigningScheme: {{packageName}}.HttpSigningSchemeHs2019,
165
+ SignedHeaders: []string{
166
+ {{packageName}}.HttpSignatureParameterRequestTarget, // The special (request-target) parameter expresses the HTTP request target.
167
+ {{packageName}}.HttpSignatureParameterCreated, // Time when request was signed, formatted as a Unix timestamp integer value.
168
+ "Host", // The Host request header specifies the domain name of the server, and optionally the TCP port number.
169
+ "Date", // The date and time at which the message was originated.
170
+ "Content-Type", // The Media type of the body of the request.
171
+ "Digest", // A cryptographic digest of the request body.
172
+ },
173
+ SigningAlgorithm: {{packageName}}.HttpSigningAlgorithmRsaPSS,
174
+ SignatureMaxValidity: 5 * time.Minute,
175
+ }
176
+ var authCtx context.Context
177
+ var err error
178
+ if authCtx, err = authConfig.ContextWithValue(context.Background()); err != nil {
179
+ // Process error
180
+ }
181
+ r, err = client.Service.Operation(auth, args)
182
+
183
+ ```
184
+ {{/isHttpSignature}}
185
+ {{/isBasic}}
186
+ {{#isOAuth}}
187
+
188
+ - **Type**: OAuth
189
+ - **Flow**: {{{flow}}}
190
+ - **Authorization URL**: {{{authorizationUrl}}}
191
+ - **Scopes**: {{^scopes}}N/A{{/scopes}}
192
+ {{#scopes}} - **{{{scope}}}**: {{{description}}}
193
+ {{/scopes}}
194
+
195
+ Example
196
+
197
+ ```go
198
+ auth := context.WithValue(context.Background(), {{packageName}}.ContextAccessToken, "ACCESSTOKENSTRING")
199
+ r, err := client.Service.Operation(auth, args)
200
+ ```
201
+
202
+ Or via OAuth2 module to automatically refresh tokens and perform user authentication.
203
+
204
+ ```go
205
+ import "golang.org/x/oauth2"
206
+
207
+ /* Perform OAuth2 round trip request and obtain a token */
208
+
209
+ tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
210
+ auth := context.WithValue(oauth2.NoContext, {{packageName}}.ContextOAuth2, tokenSource)
211
+ r, err := client.Service.Operation(auth, args)
212
+ ```
213
+
214
+ {{/isOAuth}}
215
+ {{/authMethods}}
216
+
217
+ ## Documentation for Utility Methods
218
+
219
+ Due to the fact that model structure members are all pointers, this package contains
220
+ a number of utility functions to easily obtain pointers to values of basic types.
221
+ Each of these functions takes a value of the given basic type and returns a pointer to it:
222
+
223
+ * `PtrBool`
224
+ * `PtrInt`
225
+ * `PtrInt32`
226
+ * `PtrInt64`
227
+ * `PtrFloat`
228
+ * `PtrFloat32`
229
+ * `PtrFloat64`
230
+ * `PtrString`
231
+ * `PtrTime`
232
+
233
+ ## Author
234
+
235
+ {{#apiInfo}}{{#apis}}{{#if @last}}{{infoEmail}}
236
+ {{/if}}{{/apis}}{{/apiInfo}}
@@ -0,0 +1,452 @@
1
+ {{>partial_header}}
2
+ package {{packageName}}
3
+
4
+ {{#operations}}
5
+ import (
6
+ "bytes"
7
+ "context"
8
+ "io"
9
+ "net/http"
10
+ "net/url"
11
+ {{#imports}} "{{import}}"
12
+ {{/imports}}
13
+ )
14
+
15
+ {{#generateInterfaces}}
16
+
17
+ type {{classname}} interface {
18
+ {{#operation}}
19
+
20
+ /*
21
+ {{operationId}} {{{summary}}}{{#unless summary}}Method for {{operationId}}{{/unless}}
22
+ {{#if notes}}
23
+
24
+ {{{unescapedNotes}}}
25
+ {{/if}}
26
+
27
+ @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().{{#pathParams}}
28
+ @param {{paramName}}{{#if description}} {{{description}}}{{/if}}{{/pathParams}}
29
+ @return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request
30
+ {{#isDeprecated}}
31
+
32
+ Deprecated
33
+ {{/isDeprecated}}
34
+ */
35
+ {{{nickname}}}(ctx context.Context{{#pathParams}}, {{paramName}} {{{dataType}}}{{/pathParams}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request
36
+
37
+ // {{nickname}}Execute executes the request{{#if returnType}}
38
+ // @return {{{returnType}}}{{/if}}
39
+ {{#isDeprecated}}
40
+ // Deprecated
41
+ {{/isDeprecated}}
42
+ {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#if returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{returnType}}}, {{/if}}*http.Response, error)
43
+ {{/operation}}
44
+ }
45
+ {{/generateInterfaces}}
46
+
47
+ // {{classname}}Service {{classname}} service
48
+ type {{classname}}Service service
49
+ {{#operation}}
50
+
51
+ type {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request struct {
52
+ ctx context.Context{{#generateInterfaces}}
53
+ ApiService {{classname}}
54
+ {{/generateInterfaces}}{{^generateInterfaces}}
55
+ ApiService *{{classname}}Service
56
+ {{/generateInterfaces}}
57
+ {{#allParams}}
58
+ {{paramName}} {{^isPathParam}}{{^isFile}}*{{/isFile}}{{/isPathParam}}{{{dataType}}}
59
+ {{/allParams}}
60
+ }
61
+
62
+ {{#allParams}}
63
+ {{^isPathParam}}
64
+ {{#if description}}
65
+ // {{description}}
66
+ {{/if}}
67
+ {{#isDeprecated}}
68
+ // Deprecated
69
+ {{/isDeprecated}}
70
+ func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) {{vendorExtensions.x-export-param-name}}({{paramName}} {{{dataType}}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request {
71
+ r.{{paramName}} = {{^isFile}}&{{/isFile}}{{paramName}}
72
+ return r
73
+ }
74
+
75
+ {{/isPathParam}}
76
+ {{/allParams}}
77
+ func (r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) Execute() ({{#if returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{returnType}}}, {{/if}}*http.Response, error) {
78
+ return r.ApiService.{{nickname}}Execute(r)
79
+ }
80
+
81
+ /*
82
+ {{operationId}} {{{summary}}}{{#unless summary}}Method for {{operationId}}{{/unless}}
83
+ {{#if notes}}
84
+
85
+ {{{unescapedNotes}}}
86
+ {{/if}}
87
+
88
+ @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().{{#pathParams}}
89
+ @param {{paramName}}{{#if description}} {{{description}}}{{/if}}{{/pathParams}}
90
+ @return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request
91
+ {{#isDeprecated}}
92
+
93
+ Deprecated
94
+ {{/isDeprecated}}
95
+ */
96
+ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#pathParams}}, {{paramName}} {{{dataType}}}{{/pathParams}}) {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request {
97
+ return {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request{
98
+ ApiService: a,
99
+ ctx: ctx,
100
+ {{#pathParams}}
101
+ {{paramName}}: {{paramName}},
102
+ {{/pathParams}}
103
+ }
104
+ }
105
+
106
+ // Execute executes the request{{#if returnType}}
107
+ // @return {{{returnType}}}{{/if}}
108
+ {{#isDeprecated}}
109
+ // Deprecated
110
+ {{/isDeprecated}}
111
+ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&classname}}{{/structPrefix}}{{^structPrefix}}Api{{/structPrefix}}{{operationId}}Request) ({{#if returnType}}{{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{returnType}}}, {{/if}}*http.Response, error) {
112
+ var (
113
+ localVarHTTPMethod = http.Method{{httpMethod}}
114
+ localVarPostBody interface{}
115
+ formFiles []formFile
116
+ {{#if returnType}}
117
+ localVarReturnValue {{^isArray}}{{^returnTypeIsPrimitive}}{{^isResponseFile}}*{{/isResponseFile}}{{/returnTypeIsPrimitive}}{{/isArray}}{{{returnType}}}
118
+ {{/if}}
119
+ )
120
+
121
+ localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "{{{classname}}}Service.{{{nickname}}}")
122
+ if err != nil {
123
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, &GenericOpenAPIError{error: err.Error()}
124
+ }
125
+
126
+ localVarPath := localBasePath + "{{{path}}}"{{#pathParams}}
127
+ localVarPath = strings.Replace(localVarPath, "{"+"{{{baseName}}}"+"}", url.PathEscape(parameterValueToString(r.{{paramName}}, "{{paramName}}")), -1){{/pathParams}}
128
+
129
+ localVarHeaderParams := make(map[string]string)
130
+ localVarQueryParams := url.Values{}
131
+ localVarFormParams := url.Values{}
132
+ {{#allParams}}
133
+ {{#required}}
134
+ {{^isPathParam}}
135
+ if r.{{paramName}} == nil {
136
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} is required and must be specified")
137
+ }
138
+ {{/isPathParam}}
139
+ {{#minItems}}
140
+ if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minItems}} {
141
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must have at least {{minItems}} elements")
142
+ }
143
+ {{/minItems}}
144
+ {{#maxItems}}
145
+ if len({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxItems}} {
146
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must have less than {{maxItems}} elements")
147
+ }
148
+ {{/maxItems}}
149
+ {{#if minLength}}
150
+ if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) < {{minLength}} {
151
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must have at least {{minLength}} elements")
152
+ }
153
+ {{/if}}
154
+ {{#if maxLength}}
155
+ if strlen({{^isPathParam}}*{{/isPathParam}}r.{{paramName}}) > {{maxLength}} {
156
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must have less than {{maxLength}} elements")
157
+ }
158
+ {{/if}}
159
+ {{#if minimum}}
160
+ {{#isString}}
161
+ {{paramName}}Txt, err := atoi({{^isPathParam}}*{{/isPathParam}}r.{{paramName}})
162
+ if {{paramName}}Txt < {{minimum}} {
163
+ {{/isString}}
164
+ {{^isString}}
165
+ if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} < {{minimum}} {
166
+ {{/isString}}
167
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must be greater than {{minimum}}")
168
+ }
169
+ {{/if}}
170
+ {{#if maximum}}
171
+ {{#isString}}
172
+ {{paramName}}Txt, err := atoi({{^isPathParam}}*{{/isPathParam}}r.{{paramName}})
173
+ if {{paramName}}Txt > {{maximum}} {
174
+ {{/isString}}
175
+ {{^isString}}
176
+ if {{^isPathParam}}*{{/isPathParam}}r.{{paramName}} > {{maximum}} {
177
+ {{/isString}}
178
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, reportError("{{paramName}} must be less than {{maximum}}")
179
+ }
180
+ {{/if}}
181
+ {{/required}}
182
+ {{/allParams}}
183
+
184
+ {{#queryParams}}
185
+ {{#required}}
186
+ {{#isCollectionFormatMulti}}
187
+ {
188
+ t := *r.{{paramName}}
189
+ if reflect.TypeOf(t).Kind() == reflect.Slice {
190
+ s := reflect.ValueOf(t)
191
+ for i := 0; i < s.Len(); i++ {
192
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", s.Index(i).Interface(), "{{style}}", "{{collectionFormat}}")
193
+ }
194
+ } else {
195
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", t, "{{style}}", "{{collectionFormat}}")
196
+ }
197
+ }
198
+ {{/isCollectionFormatMulti}}
199
+ {{^isCollectionFormatMulti}}
200
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
201
+ {{/isCollectionFormatMulti}}
202
+ {{/required}}
203
+ {{^required}}
204
+ if r.{{paramName}} != nil {
205
+ {{#isCollectionFormatMulti}}
206
+ t := *r.{{paramName}}
207
+ if reflect.TypeOf(t).Kind() == reflect.Slice {
208
+ s := reflect.ValueOf(t)
209
+ for i := 0; i < s.Len(); i++ {
210
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", s.Index(i).Interface(), "{{style}}", "{{collectionFormat}}")
211
+ }
212
+ } else {
213
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", t, "{{style}}", "{{collectionFormat}}")
214
+ }
215
+ {{/isCollectionFormatMulti}}
216
+ {{^isCollectionFormatMulti}}
217
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
218
+ {{/isCollectionFormatMulti}}
219
+ {{#if defaultValue}} } else {
220
+ {{#isArray}}
221
+ var defaultValue {{{dataType}}} = {{{dataType}}}{{{defaultValue}}}
222
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
223
+ r.{{paramName}} = &defaultValue
224
+ {{/isArray}}
225
+ {{^isArray}}
226
+ var defaultValue {{{dataType}}} = {{{defaultValue}}}
227
+ parameterAddToHeaderOrQuery(localVarQueryParams, "{{{baseName}}}", defaultValue, "{{style}}", "{{collectionFormat}}")
228
+ r.{{paramName}} = &defaultValue
229
+ {{/isArray}}
230
+ {{/if}} }
231
+ {{/required}}
232
+ {{/queryParams}}
233
+ // to determine the Content-Type header
234
+
235
+ localVarHTTPContentTypes := []string{ {{#consumes}}"{{{mediaType}}}"{{#unless @last}}, {{/unless}}{{/consumes}} }
236
+
237
+
238
+ // set Content-Type header
239
+ localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
240
+ if localVarHTTPContentType != "" {
241
+ localVarHeaderParams["Content-Type"] = localVarHTTPContentType
242
+ }
243
+
244
+ // to determine the Accept header
245
+
246
+ localVarHTTPHeaderAccepts := []string{ {{#produces}}"{{{mediaType}}}"{{#unless @last}}, {{/unless}}{{/produces}} }
247
+
248
+
249
+ // set Accept header
250
+ localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
251
+ if localVarHTTPHeaderAccept != "" {
252
+ localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
253
+ }
254
+ {{#headerParams}}
255
+ {{#required}}
256
+ parameterAddToHeaderOrQuery(localVarHeaderParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
257
+ {{/required}}
258
+ {{^required}}
259
+ if r.{{paramName}} != nil {
260
+ parameterAddToHeaderOrQuery(localVarHeaderParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
261
+ }
262
+ {{/required}}
263
+ {{/headerParams}}
264
+ {{#formParams}}
265
+ {{#isFile}}
266
+ {{#isArray}}
267
+ var {{paramName}}LocalVarFormFileName string
268
+ var {{paramName}}LocalVarFileName string
269
+ var {{paramName}}LocalVarFileBytes []byte
270
+
271
+ {{paramName}}LocalVarFormFileName = "{{{baseName}}}"
272
+ {{paramName}}LocalVarFile := r.{{paramName}}
273
+
274
+ if {{paramName}}LocalVarFile != nil {
275
+ // loop through the array to prepare multiple files upload
276
+ for _, {{paramName}}LocalVarFileValue := range {{paramName}}LocalVarFile {
277
+ fbs, _ := io.ReadAll({{paramName}}LocalVarFileValue)
278
+
279
+ {{paramName}}LocalVarFileBytes = fbs
280
+ {{paramName}}LocalVarFileName = {{paramName}}LocalVarFileValue.Name()
281
+ {{paramName}}LocalVarFileValue.Close()
282
+ formFiles = append(formFiles, formFile{fileBytes: {{paramName}}LocalVarFileBytes, fileName: {{paramName}}LocalVarFileName, formFileName: {{paramName}}LocalVarFormFileName})
283
+ }
284
+ }
285
+ {{/isArray}}
286
+ {{^isArray}}
287
+ var {{paramName}}LocalVarFormFileName string
288
+ var {{paramName}}LocalVarFileName string
289
+ var {{paramName}}LocalVarFileBytes []byte
290
+
291
+ {{paramName}}LocalVarFormFileName = "{{{baseName}}}"
292
+ {{paramName}}LocalVarFile := r.{{paramName}}
293
+
294
+ if {{paramName}}LocalVarFile != nil {
295
+ fbs, _ := io.ReadAll({{paramName}}LocalVarFile)
296
+
297
+ {{paramName}}LocalVarFileBytes = fbs
298
+ {{paramName}}LocalVarFileName = {{paramName}}LocalVarFile.Name()
299
+ {{paramName}}LocalVarFile.Close()
300
+ formFiles = append(formFiles, formFile{fileBytes: {{paramName}}LocalVarFileBytes, fileName: {{paramName}}LocalVarFileName, formFileName: {{paramName}}LocalVarFormFileName})
301
+ }
302
+ {{/isArray}}
303
+ {{/isFile}}
304
+ {{^isFile}}
305
+ {{#required}}
306
+ parameterAddToHeaderOrQuery(localVarFormParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
307
+ {{/required}}
308
+ {{^required}}
309
+ {{#isModel}}
310
+ if r.{{paramName}} != nil {
311
+ paramJson, err := parameterToJson(*r.{{paramName}})
312
+ if err != nil {
313
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, err
314
+ }
315
+ localVarFormParams.Add("{{{baseName}}}", paramJson)
316
+ }
317
+ {{/isModel}}
318
+ {{^isModel}}
319
+ if r.{{paramName}} != nil {
320
+ parameterAddToHeaderOrQuery(localVarFormParams, "{{{baseName}}}", r.{{paramName}}, "{{style}}", "{{collectionFormat}}")
321
+ }
322
+ {{/isModel}}
323
+ {{/required}}
324
+ {{/isFile}}
325
+ {{/formParams}}
326
+ {{#bodyParams}}
327
+ // body params
328
+ localVarPostBody = r.{{paramName}}
329
+ {{/bodyParams}}
330
+ {{#authMethods}}
331
+ {{#isApiKey}}
332
+ {{^isKeyInCookie}}
333
+ if r.ctx != nil {
334
+ // API Key Authentication
335
+ if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
336
+ {{#vendorExtensions.x-auth-id-alias}}
337
+ if apiKey, ok := auth["{{.}}"]; ok {
338
+ var key string
339
+ if prefix, ok := auth["{{name}}"]; ok && prefix.Prefix != "" {
340
+ key = prefix.Prefix + " " + apiKey.Key
341
+ } else {
342
+ key = apiKey.Key
343
+ }
344
+ {{/vendorExtensions.x-auth-id-alias}}
345
+ {{^vendorExtensions.x-auth-id-alias}}
346
+ if apiKey, ok := auth["{{name}}"]; ok {
347
+ var key string
348
+ if apiKey.Prefix != "" {
349
+ key = apiKey.Prefix + " " + apiKey.Key
350
+ } else {
351
+ key = apiKey.Key
352
+ }
353
+ {{/vendorExtensions.x-auth-id-alias}}
354
+ {{#isKeyInHeader}}
355
+ localVarHeaderParams["{{keyParamName}}"] = key
356
+ {{/isKeyInHeader}}
357
+ {{#isKeyInQuery}}
358
+ localVarQueryParams.Add("{{keyParamName}}", key)
359
+ {{/isKeyInQuery}}
360
+ }
361
+ }
362
+ }
363
+ {{/isKeyInCookie}}
364
+ {{/isApiKey}}
365
+ {{/authMethods}}
366
+ req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
367
+ if err != nil {
368
+ return {{#if returnType}}localVarReturnValue, {{/if}}nil, err
369
+ }
370
+
371
+ localVarHTTPResponse, err := a.client.callAPI(req)
372
+ if err != nil || localVarHTTPResponse == nil {
373
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, err
374
+ }
375
+
376
+ localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
377
+ localVarHTTPResponse.Body.Close()
378
+ localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
379
+ if err != nil {
380
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, err
381
+ }
382
+
383
+ {{#withCustomMiddlewareFunction}}
384
+ if a.client.cfg.ResponseMiddleware != nil {
385
+ err = a.client.cfg.ResponseMiddleware(localVarHTTPResponse, localVarBody)
386
+ if err != nil {
387
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, err
388
+ }
389
+ }
390
+
391
+ {{/withCustomMiddlewareFunction}}
392
+ if localVarHTTPResponse.StatusCode >= 300 {
393
+ newErr := &GenericOpenAPIError{
394
+ body: localVarBody,
395
+ error: localVarHTTPResponse.Status,
396
+ }
397
+ {{#responses}}
398
+ {{#dataType}}
399
+ {{^../is1xx}}
400
+ {{^../is2xx}}
401
+ {{#../range}}
402
+ {{#../is3xx}}
403
+ if localVarHTTPResponse.StatusCode >= 300 && localVarHTTPResponse.StatusCode < 400 {
404
+ {{/../is3xx}}
405
+ {{#../is4xx}}
406
+ if localVarHTTPResponse.StatusCode >= 400 && localVarHTTPResponse.StatusCode < 500 {
407
+ {{/../is4xx}}
408
+ {{#../is5xx}}
409
+ if localVarHTTPResponse.StatusCode >= 500 {
410
+ {{/../is5xx}}
411
+ {{/../range}}
412
+ {{^../range}}
413
+ {{^../wildcard}}
414
+ if localVarHTTPResponse.StatusCode == {{{../code}}} {
415
+ {{/../wildcard}}
416
+ {{/../range}}
417
+ var v {{{.}}}
418
+ err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
419
+ if err != nil {
420
+ newErr.error = err.Error()
421
+ return {{#if ../../returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, newErr
422
+ }
423
+ newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
424
+ newErr.model = v
425
+ {{#unless @last}}
426
+ return {{#if ../../returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, newErr
427
+ {{/unless}}
428
+ {{^../wildcard}}
429
+ }
430
+ {{/../wildcard}}
431
+ {{/../is2xx}}
432
+ {{/../is1xx}}
433
+ {{/dataType}}
434
+ {{/responses}}
435
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, newErr
436
+ }
437
+
438
+ {{#if returnType}}
439
+ err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
440
+ if err != nil {
441
+ newErr := &GenericOpenAPIError{
442
+ body: localVarBody,
443
+ error: err.Error(),
444
+ }
445
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, newErr
446
+ }
447
+
448
+ {{/if}}
449
+ return {{#if returnType}}localVarReturnValue, {{/if}}localVarHTTPResponse, nil
450
+ }
451
+ {{/operation}}
452
+ {{/operations}}