@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,332 @@
1
+ {{>partial_header}}
2
+ package {{packageName}}
3
+
4
+ import (
5
+ "context"
6
+ "fmt"
7
+ "net/http"
8
+ "strings"
9
+ )
10
+
11
+ // contextKeys are used to identify the type of value in the context.
12
+ // Since these are string, it is possible to get a short description of the
13
+ // context key for logging and debugging using key.String().
14
+
15
+ type contextKey string
16
+
17
+ func (c contextKey) String() string {
18
+ return "auth " + string(c)
19
+ }
20
+
21
+ var (
22
+ {{#hasOAuthMethods}}
23
+ // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
24
+ ContextOAuth2 = contextKey("token")
25
+
26
+ {{/hasOAuthMethods}}
27
+ {{#hasHttpBasicMethods}}
28
+ // ContextBasicAuth takes BasicAuth as authentication for the request.
29
+ ContextBasicAuth = contextKey("basic")
30
+
31
+ {{/hasHttpBasicMethods}}
32
+ {{#hasHttpBearerMethods}}
33
+ // ContextAccessToken takes a string oauth2 access token as authentication for the request.
34
+ ContextAccessToken = contextKey("accesstoken")
35
+
36
+ {{/hasHttpBearerMethods}}
37
+ {{#hasApiKeyMethods}}
38
+ // ContextAPIKeys takes a string apikey as authentication for the request
39
+ ContextAPIKeys = contextKey("apiKeys")
40
+
41
+ {{/hasApiKeyMethods}}
42
+ {{#withAWSV4Signature}}
43
+ // ContextAWSv4 takes an Access Key and a Secret Key for signing AWS Signature v4
44
+ ContextAWSv4 = contextKey("awsv4")
45
+
46
+ {{/withAWSV4Signature}}
47
+ {{#hasHttpSignatureMethods}}
48
+ // ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
49
+ ContextHttpSignatureAuth = contextKey("httpsignature")
50
+
51
+ {{/hasHttpSignatureMethods}}
52
+ // ContextServerIndex uses a server configuration from the index.
53
+ ContextServerIndex = contextKey("serverIndex")
54
+
55
+ // ContextOperationServerIndices uses a server configuration from the index mapping.
56
+ ContextOperationServerIndices = contextKey("serverOperationIndices")
57
+
58
+ // ContextServerVariables overrides a server configuration variables.
59
+ ContextServerVariables = contextKey("serverVariables")
60
+
61
+ // ContextOperationServerVariables overrides a server configuration variables using operation specific values.
62
+ ContextOperationServerVariables = contextKey("serverOperationVariables")
63
+ )
64
+
65
+ // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
66
+ type BasicAuth struct {
67
+ UserName string `json:"userName,omitempty"`
68
+ Password string `json:"password,omitempty"`
69
+ }
70
+
71
+ // APIKey provides API key based authentication to a request passed via context using ContextAPIKey
72
+ type APIKey struct {
73
+ Key string
74
+ Prefix string
75
+ }
76
+
77
+ {{#withAWSV4Signature}}
78
+ // AWSv4 provides AWS Signature to a request passed via context using ContextAWSv4
79
+ // https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
80
+ type AWSv4 struct {
81
+ AccessKey string
82
+ SecretKey string
83
+ SessionToken string
84
+ Region string
85
+ Service string
86
+ }
87
+
88
+ {{/withAWSV4Signature}}
89
+ // ServerVariable stores the information about a server variable
90
+ type ServerVariable struct {
91
+ Description string
92
+ DefaultValue string
93
+ EnumValues []string
94
+ }
95
+
96
+ // ServerConfiguration stores the information about a server
97
+ type ServerConfiguration struct {
98
+ URL string
99
+ Description string
100
+ Variables map[string]ServerVariable
101
+ }
102
+
103
+ // ServerConfigurations stores multiple ServerConfiguration items
104
+ type ServerConfigurations []ServerConfiguration
105
+
106
+ {{#withCustomMiddlewareFunction}}
107
+ // MiddlewareFunction provides way to implement custom middleware in the prepareRequest
108
+ type MiddlewareFunction func(*http.Request)
109
+
110
+ // MiddlewareFunctionWithError provides way to implement custom middleware with errors in the prepareRequest
111
+ type MiddlewareFunctionWithError func(*http.Request) error
112
+
113
+ // ResponseMiddlewareFunction provides way to implement custom middleware with errors after the response is received
114
+ type ResponseMiddlewareFunction func(*http.Response, []byte) error
115
+
116
+ {{/withCustomMiddlewareFunction}}
117
+ // Configuration stores the configuration of the API client
118
+ type Configuration struct {
119
+ Host string `json:"host,omitempty"`
120
+ Scheme string `json:"scheme,omitempty"`
121
+ DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
122
+ UserAgent string `json:"userAgent,omitempty"`
123
+ Debug bool `json:"debug,omitempty"`
124
+ Servers ServerConfigurations
125
+ OperationServers map[string]ServerConfigurations
126
+ HTTPClient *http.Client
127
+ {{#withCustomMiddlewareFunction}}
128
+ Middleware MiddlewareFunction
129
+ MiddlewareWithError MiddlewareFunctionWithError
130
+ ResponseMiddleware ResponseMiddlewareFunction
131
+ {{/withCustomMiddlewareFunction}}
132
+ }
133
+
134
+ // NewConfiguration returns a new Configuration object
135
+ func NewConfiguration() *Configuration {
136
+ cfg := &Configuration{
137
+ DefaultHeader: make(map[string]string),
138
+ UserAgent: "{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/go{{/httpUserAgent}}",
139
+ Debug: false,
140
+ {{#servers}}
141
+ {{#if @first}}
142
+ Servers: ServerConfigurations{
143
+ {{/if}}
144
+ {
145
+ URL: "{{{url}}}",
146
+ Description: "{{{description}}}{{#unless description}}No description provided{{/unless}}",
147
+ {{#variables}}
148
+ {{#if @first}}
149
+ Variables: map[string]ServerVariable{
150
+ {{/if}}
151
+ "{{{name}}}": ServerVariable{
152
+ Description: "{{{description}}}{{#unless description}}No description provided{{/unless}}",
153
+ DefaultValue: "{{{defaultValue}}}",
154
+ {{#enumValues}}
155
+ {{#if @first}}
156
+ EnumValues: []string{
157
+ {{/if}}
158
+ "{{{.}}}",
159
+ {{#if @last}}
160
+ },
161
+ {{/if}}
162
+ {{/enumValues}}
163
+ },
164
+ {{#if @last}}
165
+ },
166
+ {{/if}}
167
+ {{/variables}}
168
+ },
169
+ {{#if @last}}
170
+ },
171
+ {{/if}}
172
+ {{/servers}}
173
+ {{#apiInfo}}
174
+ OperationServers: map[string]ServerConfigurations{
175
+ {{#apis}}
176
+ {{#operations}}
177
+ {{#operation}}
178
+ {{#servers}}
179
+ {{#if @first}}
180
+ "{{{classname}}}Service.{{{nickname}}}": {
181
+ {{/if}}
182
+ {
183
+ URL: "{{{url}}}",
184
+ Description: "{{{description}}}{{#unless description}}No description provided{{/unless}}",
185
+ {{#variables}}
186
+ {{#if @first}}
187
+ Variables: map[string]ServerVariable{
188
+ {{/if}}
189
+ "{{{name}}}": ServerVariable{
190
+ Description: "{{{description}}}{{#unless description}}No description provided{{/unless}}",
191
+ DefaultValue: "{{{defaultValue}}}",
192
+ {{#enumValues}}
193
+ {{#if @first}}
194
+ EnumValues: []string{
195
+ {{/if}}
196
+ "{{{.}}}",
197
+ {{#if @last}}
198
+ },
199
+ {{/if}}
200
+ {{/enumValues}}
201
+ },
202
+ {{#if @last}}
203
+ },
204
+ {{/if}}
205
+ {{/variables}}
206
+ },
207
+ {{#if @last}}
208
+ },
209
+ {{/if}}
210
+ {{/servers}}
211
+ {{/operation}}
212
+ {{/operations}}
213
+ {{/apis}}
214
+ },
215
+ {{/apiInfo}}
216
+ }
217
+ return cfg
218
+ }
219
+
220
+ // AddDefaultHeader adds a new HTTP header to the default header in the request
221
+ func (c *Configuration) AddDefaultHeader(key string, value string) {
222
+ c.DefaultHeader[key] = value
223
+ }
224
+
225
+ // URL formats template on a index using given variables
226
+ func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
227
+ if index < 0 || len(sc) <= index {
228
+ return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
229
+ }
230
+ server := sc[index]
231
+ url := server.URL
232
+
233
+ // go through variables and replace placeholders
234
+ for name, variable := range server.Variables {
235
+ if value, ok := variables[name]; ok {
236
+ found := bool(len(variable.EnumValues) == 0)
237
+ for _, enumValue := range variable.EnumValues {
238
+ if value == enumValue {
239
+ found = true
240
+ }
241
+ }
242
+ if !found {
243
+ return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
244
+ }
245
+ url = strings.Replace(url, "{"+name+"}", value, -1)
246
+ } else {
247
+ url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1)
248
+ }
249
+ }
250
+ return url, nil
251
+ }
252
+
253
+ // ServerURL returns URL based on server settings
254
+ func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) {
255
+ return c.Servers.URL(index, variables)
256
+ }
257
+
258
+ func getServerIndex(ctx context.Context) (int, error) {
259
+ si := ctx.Value(ContextServerIndex)
260
+ if si != nil {
261
+ if index, ok := si.(int); ok {
262
+ return index, nil
263
+ }
264
+ return 0, reportError("Invalid type %T should be int", si)
265
+ }
266
+ return 0, nil
267
+ }
268
+
269
+ func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) {
270
+ osi := ctx.Value(ContextOperationServerIndices)
271
+ if osi != nil {
272
+ if operationIndices, ok := osi.(map[string]int); !ok {
273
+ return 0, reportError("Invalid type %T should be map[string]int", osi)
274
+ } else {
275
+ index, ok := operationIndices[endpoint]
276
+ if ok {
277
+ return index, nil
278
+ }
279
+ }
280
+ }
281
+ return getServerIndex(ctx)
282
+ }
283
+
284
+ func getServerVariables(ctx context.Context) (map[string]string, error) {
285
+ sv := ctx.Value(ContextServerVariables)
286
+ if sv != nil {
287
+ if variables, ok := sv.(map[string]string); ok {
288
+ return variables, nil
289
+ }
290
+ return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv)
291
+ }
292
+ return nil, nil
293
+ }
294
+
295
+ func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) {
296
+ osv := ctx.Value(ContextOperationServerVariables)
297
+ if osv != nil {
298
+ if operationVariables, ok := osv.(map[string]map[string]string); !ok {
299
+ return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv)
300
+ } else {
301
+ variables, ok := operationVariables[endpoint]
302
+ if ok {
303
+ return variables, nil
304
+ }
305
+ }
306
+ }
307
+ return getServerVariables(ctx)
308
+ }
309
+
310
+ // ServerURLWithContext returns a new server URL given an endpoint
311
+ func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) {
312
+ sc, ok := c.OperationServers[endpoint]
313
+ if !ok {
314
+ sc = c.Servers
315
+ }
316
+
317
+ if ctx == nil {
318
+ return sc.URL(0, nil)
319
+ }
320
+
321
+ index, err := getServerOperationIndex(ctx, endpoint)
322
+ if err != nil {
323
+ return "", err
324
+ }
325
+
326
+ variables, err := getServerOperationVariables(ctx, endpoint)
327
+ if err != nil {
328
+ return "", err
329
+ }
330
+
331
+ return sc.URL(index, variables)
332
+ }
@@ -0,0 +1,57 @@
1
+ #!/bin/sh
2
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
+ #
4
+ # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
+
6
+ git_user_id=$1
7
+ git_repo_id=$2
8
+ release_note=$3
9
+ git_host=$4
10
+
11
+ if [ "$git_host" = "" ]; then
12
+ git_host="{{{gitHost}}}"
13
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
+ fi
15
+
16
+ if [ "$git_user_id" = "" ]; then
17
+ git_user_id="{{{gitUserId}}}"
18
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
+ fi
20
+
21
+ if [ "$git_repo_id" = "" ]; then
22
+ git_repo_id="{{{gitRepoId}}}"
23
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
+ fi
25
+
26
+ if [ "$release_note" = "" ]; then
27
+ release_note="{{{releaseNote}}}"
28
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
+ fi
30
+
31
+ # Initialize the local directory as a Git repository
32
+ git init
33
+
34
+ # Adds the files in the local repository and stages them for commit.
35
+ git add .
36
+
37
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
+ git commit -m "$release_note"
39
+
40
+ # Sets the new remote
41
+ git_remote=$(git remote)
42
+ if [ "$git_remote" = "" ]; then # git remote not defined
43
+
44
+ if [ "$GIT_TOKEN" = "" ]; then
45
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
+ else
48
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
+ fi
50
+
51
+ fi
52
+
53
+ git pull origin master
54
+
55
+ # Pushes (Forces) the changes in the local repository up to the remote repository
56
+ echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
+ git push origin master 2>&1 | grep -v 'To https'
@@ -0,0 +1,24 @@
1
+ # Compiled Object files, Static and Dynamic libs (Shared Objects)
2
+ *.o
3
+ *.a
4
+ *.so
5
+
6
+ # Folders
7
+ _obj
8
+ _test
9
+
10
+ # Architecture specific extensions/prefixes
11
+ *.[568vq]
12
+ [568vq].out
13
+
14
+ *.cgo1.go
15
+ *.cgo2.c
16
+ _cgo_defun.c
17
+ _cgo_gotypes.go
18
+ _cgo_export.*
19
+
20
+ _testmain.go
21
+
22
+ *.exe
23
+ *.test
24
+ *.prof
@@ -0,0 +1,16 @@
1
+ module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
2
+
3
+ go 1.23
4
+
5
+ require (
6
+ {{#hasOAuthMethods}}
7
+ github.com/stretchr/testify v1.[10].0
8
+ golang.org/x/oauth2 v0.[27].0
9
+ {{/hasOAuthMethods}}
10
+ {{#withAWSV4Signature}}
11
+ github.com/aws/aws-sdk-go-v2 v1.[37].0
12
+ {{/withAWSV4Signature}}
13
+ {{#importValidator}}
14
+ gopkg.in/validator.v2 v2.[0].1
15
+ {{/importValidator}}
16
+ )
@@ -0,0 +1,19 @@
1
+ cloud.google.com/go v0.[34].0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2
+ github.com/golang/protobuf v1.[2].0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
3
+ github.com/golang/protobuf v1.[2].0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
4
+ golang.org/x/net v0.[0].0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
5
+ golang.org/x/net v0.[0].0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
6
+ golang.org/x/net v0.[0].0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
7
+ {{#hasOAuthMethods}}
8
+ golang.org/x/oauth2 v0.[27].0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
9
+ golang.org/x/oauth2 v0.[27].0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
10
+ {{/hasOAuthMethods}}
11
+ golang.org/x/sync v0.[0].0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
12
+ golang.org/x/sync v0.[0].0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
13
+ golang.org/x/text v0.[3].0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
14
+ google.golang.org/appengine v1.[4].0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
15
+ google.golang.org/appengine v1.[4].0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
16
+ {{#importValidator}}
17
+ gopkg.in/validator.v2 v2.[0].1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY=
18
+ gopkg.in/validator.v2 v2.[0].1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8=
19
+ {{/importValidator}}
@@ -0,0 +1,21 @@
1
+ {{>partial_header}}
2
+ package {{packageName}}
3
+
4
+ {{#models}}
5
+ import (
6
+ "encoding/json"
7
+ {{#imports}}
8
+ "{{import}}"
9
+ {{/imports}}
10
+ )
11
+
12
+ {{#model}}
13
+ {{#isEnum}}
14
+ {{>model_enum}}
15
+
16
+ {{/isEnum}}
17
+ {{^isEnum}}
18
+ {{#oneOf}}{{#if @first}}{{>model_oneof}}{{/if}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#if @first}}{{>model_anyof}}{{/if}}{{/anyOf}}{{^anyOf}}{{>model_simple}}{{/anyOf}}{{/oneOf}}
19
+ {{/isEnum}}
20
+ {{/model}}
21
+ {{/models}}
@@ -0,0 +1,93 @@
1
+ {{#discriminator}}
2
+ // checks if the {{classname}} type satisfies the MappedNullable interface at compile time
3
+ var _ MappedNullable = &{{classname}}{}
4
+ {{/discriminator}}
5
+
6
+ // {{classname}} {{{description}}}{{#unless description}}struct for {{{classname}}}{{/unless}}
7
+ type {{classname}} struct {
8
+ {{#anyOf}}
9
+ {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} *{{{.}}}
10
+ {{/anyOf}}
11
+ }
12
+
13
+ // Unmarshal JSON data into any of the pointers in the struct
14
+ func (dst *{{classname}}) UnmarshalJSON(data []byte) error {
15
+ var err error
16
+ {{#isNullable}}
17
+ // this object is nullable so check if the payload is null or empty string
18
+ if string(data) == "" || string(data) == "{}" {
19
+ return nil
20
+ }
21
+
22
+ {{/isNullable}}
23
+ {{#discriminator}}
24
+ {{#mappedModels}}
25
+ {{#if @first}}
26
+ // use discriminator value to speed up the lookup
27
+ var jsonDict map[string]interface{}
28
+ err = json.Unmarshal(data, &jsonDict)
29
+ if err != nil {
30
+ return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
31
+ }
32
+
33
+ {{/if}}
34
+ // check if the discriminator value is '{{{mappingName}}}'
35
+ if jsonDict["{{{propertyBaseName}}}"] == "{{{mappingName}}}" {
36
+ // try to unmarshal JSON data into {{{modelName}}}
37
+ err = json.Unmarshal(data, &dst.{{{modelName}}});
38
+ if err == nil {
39
+ json{{{modelName}}}, _ := json.Marshal(dst.{{{modelName}}})
40
+ if string(json{{{modelName}}}) == "{}" { // empty struct
41
+ dst.{{{modelName}}} = nil
42
+ } else {
43
+ return nil // data stored in dst.{{{modelName}}}, return on the first match
44
+ }
45
+ } else {
46
+ dst.{{{modelName}}} = nil
47
+ }
48
+ }
49
+
50
+ {{/mappedModels}}
51
+ {{/discriminator}}
52
+ {{#anyOf}}
53
+ // try to unmarshal JSON data into {{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}
54
+ err = json.Unmarshal(data, &dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}});
55
+ if err == nil {
56
+ json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, _ := json.Marshal(dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}})
57
+ if string(json{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}) == "{}" { // empty struct
58
+ dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil
59
+ } else {
60
+ return nil // data stored in dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}, return on the first match
61
+ }
62
+ } else {
63
+ dst.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} = nil
64
+ }
65
+
66
+ {{/anyOf}}
67
+ return fmt.Errorf("data failed to match schemas in anyOf({{classname}})")
68
+ }
69
+
70
+ // Marshal data from the first non-nil pointers in the struct to JSON
71
+ func (src {{classname}}) MarshalJSON() ([]byte, error) {
72
+ {{#anyOf}}
73
+ if src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil {
74
+ return json.Marshal(&src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}})
75
+ }
76
+
77
+ {{/anyOf}}
78
+ return nil, nil // no data in anyOf schemas
79
+ }
80
+
81
+ {{#discriminator}}
82
+ func (src {{classname}}) ToMap() (map[string]interface{}, error) {
83
+ {{#anyOf}}
84
+ if src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}} != nil {
85
+ return src.{{#lambda.type-to-name}}{{{.}}}{{/lambda.type-to-name}}.ToMap()
86
+ }
87
+
88
+ {{/anyOf}}
89
+ return nil, nil // no data in anyOf schemas
90
+ }
91
+ {{/discriminator}}
92
+
93
+ {{>nullable_model}}
@@ -0,0 +1,97 @@
1
+ {{#models}}{{#model}}# {{classname}}
2
+
3
+ {{^isEnum}}
4
+ ## Properties
5
+
6
+ Name | Type | Description | Notes
7
+ ------------ | ------------- | ------------- | -------------
8
+ {{#vendorExtensions.x-is-one-of-interface}}
9
+ **{{classname}}Interface** | **interface { {{#discriminator}}{{propertyGetter}}() {{propertyType}}{{/discriminator}} }** | An interface that can hold any of the proper implementing types |
10
+ {{/vendorExtensions.x-is-one-of-interface}}
11
+ {{^vendorExtensions.x-is-one-of-interface}}
12
+ {{#vars}}**{{name}}** | {{^required}}Pointer to {{/required}}{{#isContainer}}{{#isArray}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**[]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{dataType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isArray}}{{#isMap}}{{#items}}{{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**map[string]{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}{{/items}}{{/isMap}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}[{{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}{{^isDateTime}}]({{^baseType}}{{dataType}}{{/baseType}}{{baseType}}.md){{/isDateTime}}{{/isFile}}{{/isPrimitiveType}}{{/isContainer}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#if defaultValue}}[default to {{{defaultValue}}}]{{/if}}
13
+ {{/vars}}
14
+ {{/vendorExtensions.x-is-one-of-interface}}
15
+
16
+ ## Methods
17
+
18
+ {{^vendorExtensions.x-is-one-of-interface}}
19
+ ### New{{classname}}
20
+
21
+ `func New{{classname}}({{#vars}}{{#required}}{{nameInCamelCase}} {{dataType}}, {{/required}}{{/vars}}) *{{classname}}`
22
+
23
+ New{{classname}} instantiates a new {{classname}} object
24
+ This constructor will assign default values to properties that have it defined,
25
+ and makes sure properties required by API are set, but the set of arguments
26
+ will change when the set of required properties is changed
27
+
28
+ ### New{{classname}}WithDefaults
29
+
30
+ `func New{{classname}}WithDefaults() *{{classname}}`
31
+
32
+ New{{classname}}WithDefaults instantiates a new {{classname}} object
33
+ This constructor will only assign default values to properties that have it defined,
34
+ but it doesn't guarantee that properties required by API are set
35
+
36
+ {{#vars}}
37
+ ### Get{{name}}
38
+
39
+ `func (o *{{classname}}) Get{{name}}() {{vendorExtensions.x-go-base-type}}`
40
+
41
+ Get{{name}} returns the {{name}} field if non-nil, zero value otherwise.
42
+
43
+ ### Get{{name}}Ok
44
+
45
+ `func (o *{{classname}}) Get{{name}}Ok() (*{{vendorExtensions.x-go-base-type}}, bool)`
46
+
47
+ Get{{name}}Ok returns a tuple with the {{name}} field if it's non-nil, zero value otherwise
48
+ and a boolean to check if the value has been set.
49
+
50
+ ### Set{{name}}
51
+
52
+ `func (o *{{classname}}) Set{{name}}(v {{vendorExtensions.x-go-base-type}})`
53
+
54
+ Set{{name}} sets {{name}} field to given value.
55
+
56
+ {{^required}}
57
+ ### Has{{name}}
58
+
59
+ `func (o *{{classname}}) Has{{name}}() bool`
60
+
61
+ Has{{name}} returns a boolean if a field has been set.
62
+ {{/required}}
63
+
64
+ {{#isNullable}}
65
+ ### Set{{name}}Nil
66
+
67
+ `func (o *{{classname}}) Set{{name}}Nil(b bool)`
68
+
69
+ Set{{name}}Nil sets the value for {{name}} to be an explicit nil
70
+
71
+ ### Unset{{name}}
72
+ `func (o *{{classname}}) Unset{{name}}()`
73
+
74
+ Unset{{name}} ensures that no value is present for {{name}}, not even an explicit nil
75
+ {{/isNullable}}
76
+ {{/vars}}
77
+ {{#vendorExtensions.x-implements}}
78
+
79
+ ### As{{{.}}}
80
+
81
+ `func (s *{{classname}}) As{{{.}}}() {{{.}}}`
82
+
83
+ Convenience method to wrap this instance of {{classname}} in {{{.}}}
84
+ {{/vendorExtensions.x-implements}}
85
+ {{/vendorExtensions.x-is-one-of-interface}}
86
+ {{/isEnum}}
87
+ {{#isEnum}}
88
+ ## Enum
89
+
90
+ {{#allowableValues}}{{#enumVars}}
91
+ * `{{name}}` (value: `{{{value}}}`)
92
+ {{/enumVars}}{{/allowableValues}}
93
+ {{/isEnum}}
94
+
95
+ [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
96
+
97
+ {{/model}}{{/models}}