@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 kattebak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # @kattebak/openapi-generator-ts
2
+
3
+ A TypeScript port of the excellent [OpenAPI Generator](https://openapi-generator.tech/) project.
4
+
5
+ ## Acknowledgments
6
+
7
+ This project stands on the shoulders of giants. The original [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) is a remarkable open-source project that has generated API clients, server stubs, and documentation for countless developers worldwide. We are deeply grateful to the OpenAPI Generator community for their years of work building and maintaining such a comprehensive and well-designed tool.
8
+
9
+ ## Motivation
10
+
11
+ While the original OpenAPI Generator is feature-complete and battle-tested, it requires a Java Virtual Machine (JVM) to run. This can be inconvenient in certain scenarios:
12
+
13
+ - **CI/CD pipelines** where adding a JVM dependency increases container image sizes and build times
14
+ - **Node.js-only environments** where maintaining a Java installation adds operational complexity
15
+ - **Quick local generation** where startup time matters
16
+
17
+ This TypeScript port provides a native Node.js alternative that:
18
+
19
+ - Eliminates the JVM dependency entirely
20
+ - Offers faster startup times for small to medium specs
21
+ - Integrates seamlessly into JavaScript/TypeScript toolchains
22
+ - Uses the same Mustache-compatible templates as the original
23
+
24
+ **Note:** This is not a replacement for the original. If you need the full feature set, extensive generator library, or battle-tested stability, use the original [OpenAPI Generator](https://openapi-generator.tech/). This port focuses on common use cases with a subset of generators.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @kattebak/openapi-generator-ts
30
+ ```
31
+
32
+ Or run directly with npx:
33
+
34
+ ```bash
35
+ npx @kattebak/openapi-generator-ts generate -i api.yaml -g typescript-fetch -o ./generated
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### CLI
41
+
42
+ ```bash
43
+ # List available generators
44
+ openapi-generator list
45
+
46
+ # Validate an OpenAPI specification
47
+ openapi-generator validate -i openapi.yaml
48
+
49
+ # Generate client code
50
+ openapi-generator generate -i openapi.yaml -g typescript-fetch -o ./output
51
+
52
+ # Generate with additional properties
53
+ openapi-generator generate -i openapi.yaml -g python -o ./output \
54
+ --additional-properties packageName=my_api,packageVersion=1.0.0
55
+ ```
56
+
57
+ ### Programmatic API
58
+
59
+ ```typescript
60
+ import { generate, parseSpec } from '@kattebak/openapi-generator-ts';
61
+
62
+ // Parse and validate a spec
63
+ const { document } = await parseSpec('./openapi.yaml');
64
+
65
+ // Generate code
66
+ await generate({
67
+ inputSpec: './openapi.yaml',
68
+ generatorName: 'typescript-fetch',
69
+ outputDir: './generated',
70
+ additionalProperties: {
71
+ npmName: '@myorg/api-client',
72
+ npmVersion: '1.0.0',
73
+ },
74
+ });
75
+ ```
76
+
77
+ ## Available Generators
78
+
79
+ | Generator | Language | Description |
80
+ |-----------|----------|-------------|
81
+ | `typescript-fetch` | TypeScript | Client using the Fetch API |
82
+ | `python` | Python | Python client with urllib3 |
83
+ | `go` | Go | Go client with net/http |
84
+ | `php` | PHP | PHP client (guzzle or psr-18) |
85
+
86
+ ## Configuration
87
+
88
+ ### Generator Options
89
+
90
+ Each generator supports additional properties that can be passed via `--additional-properties` or the programmatic API:
91
+
92
+ **typescript-fetch:**
93
+ - `npmName` - NPM package name
94
+ - `npmVersion` - NPM package version
95
+ - `supportsES6` - Generate ES6 code (default: true)
96
+
97
+ **python:**
98
+ - `packageName` - Python package name
99
+ - `packageVersion` - Package version
100
+ - `packageUrl` - Package URL for setup.py
101
+
102
+ **go:**
103
+ - `packageName` - Go package name
104
+ - `packageVersion` - Package version
105
+ - `isGoSubmodule` - Generate as Go submodule
106
+
107
+ **php:**
108
+ - `packageName` - Composer package name
109
+ - `invokerPackage` - Root namespace
110
+ - `composerVendorName` - Composer vendor name
111
+
112
+ ## Templates
113
+
114
+ This generator uses Handlebars templates that are largely compatible with the original Mustache templates. Custom templates can be provided via the `--template-dir` option.
115
+
116
+ ### Syncing Templates from Original
117
+
118
+ Templates are synced from the original OpenAPI Generator repository. The sync script does a shallow clone and automatically converts Mustache syntax to Handlebars-compatible format:
119
+
120
+ ```bash
121
+ # Sync templates for all generators
122
+ npm run sync-templates
123
+
124
+ # Sync specific generators only
125
+ ./scripts/sync-templates.sh -g typescript-fetch,python
126
+
127
+ # Clean existing templates and re-sync
128
+ npm run sync-templates:clean
129
+
130
+ # Preview what would be synced (dry run)
131
+ ./scripts/sync-templates.sh --dry-run
132
+ ```
133
+
134
+ The sync script handles:
135
+ - Shallow cloning of the original repository (cached in `.template-cache/`)
136
+ - Removing Mustache delimiter changes (`{{=<% %>=}}`)
137
+ - Converting lambda syntax (`{{#lambda.func}}` to `{{#func}}`)
138
+
139
+ ## Comparing Output to Original
140
+
141
+ To verify this port generates compatible output, you can compare against the original Java OpenAPI Generator:
142
+
143
+ ```bash
144
+ # Generate with original (using Docker, no Java needed)
145
+ docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli generate \
146
+ -i /local/samples/petstore.yaml \
147
+ -g typescript-fetch \
148
+ -o /local/tmp/original-output
149
+
150
+ # Generate with this port
151
+ cd samples && make typescript-fetch
152
+
153
+ # Compare
154
+ diff -r tmp/original-output samples/build/typescript-fetch
155
+ ```
156
+
157
+ For detailed comparison methodology and debugging tips, see [AGENTS.md](./AGENTS.md#comparing-output-against-original-java-generator).
158
+
159
+ ## Requirements
160
+
161
+ - Node.js >= 22.0.0
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ # Install dependencies
167
+ npm install
168
+
169
+ # Sync templates from original OpenAPI Generator
170
+ npm run sync-templates
171
+
172
+ # Build
173
+ npm run build
174
+
175
+ # Run tests
176
+ npm test
177
+
178
+ # Type check
179
+ npm run typecheck
180
+ ```
181
+
182
+ ## License
183
+
184
+ Apache-2.0 - Same as the original OpenAPI Generator.
185
+
186
+ ## See Also
187
+
188
+ - [OpenAPI Generator](https://openapi-generator.tech/) - The original Java implementation
189
+ - [OpenAPI Specification](https://spec.openapis.org/oas/latest.html) - The OpenAPI Specification
@@ -0,0 +1,23 @@
1
+ export interface GenerateOptions {
2
+ inputSpec: string;
3
+ generatorName: string;
4
+ outputDir: string;
5
+ templateDir?: string;
6
+ library?: string;
7
+ packageName?: string;
8
+ apiPackage?: string;
9
+ modelPackage?: string;
10
+ generateModels?: boolean;
11
+ generateApis?: boolean;
12
+ generateSupportingFiles?: boolean;
13
+ skipOverwrite?: boolean;
14
+ minimalUpdate?: boolean;
15
+ dryRun?: boolean;
16
+ additionalProperties?: Record<string, string>;
17
+ typeMappings?: Record<string, string>;
18
+ importMappings?: Record<string, string>;
19
+ verbose?: boolean;
20
+ debug?: boolean;
21
+ }
22
+ export declare function generateCommand(options: GenerateOptions): Promise<void>;
23
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAmI7E"}
@@ -0,0 +1,116 @@
1
+ import { createDefaultConfig } from "../../core/config.js";
2
+ import { createGenerator } from "../../core/generator.js";
3
+ import { getGenerator, getGeneratorAdditionalProperties, hasGenerator, listGenerators, } from "../../generators/index.js";
4
+ export async function generateCommand(options) {
5
+ const startTime = Date.now();
6
+ // Check if generator exists
7
+ if (!hasGenerator(options.generatorName)) {
8
+ console.error(`Unknown generator: ${options.generatorName}`);
9
+ console.log("\nAvailable generators:");
10
+ for (const gen of listGenerators()) {
11
+ console.log(` - ${gen}`);
12
+ }
13
+ process.exit(1);
14
+ }
15
+ // Get generator metadata
16
+ const metadata = getGenerator(options.generatorName);
17
+ if (!metadata) {
18
+ console.error(`Could not load generator: ${options.generatorName}`);
19
+ process.exit(1);
20
+ }
21
+ // Create config
22
+ const config = createDefaultConfig({
23
+ inputSpec: options.inputSpec,
24
+ generatorName: options.generatorName,
25
+ outputDir: options.outputDir,
26
+ templateDir: options.templateDir,
27
+ library: options.library,
28
+ packageName: options.packageName,
29
+ apiPackage: options.apiPackage,
30
+ modelPackage: options.modelPackage,
31
+ generateModels: options.generateModels,
32
+ generateApis: options.generateApis,
33
+ generateSupportingFiles: options.generateSupportingFiles,
34
+ skipOverwrite: options.skipOverwrite,
35
+ minimalUpdate: options.minimalUpdate,
36
+ dryRun: options.dryRun,
37
+ additionalProperties: options.additionalProperties,
38
+ typeMappings: options.typeMappings,
39
+ importMappings: options.importMappings,
40
+ verbose: options.verbose,
41
+ debug: options.debug,
42
+ validateSpec: true,
43
+ });
44
+ // Get generator specific additional properties and merge them
45
+ const generatorProps = getGeneratorAdditionalProperties(options.generatorName, config);
46
+ // Merge generator properties into additionalProperties
47
+ config.additionalProperties = {
48
+ ...generatorProps,
49
+ ...config.additionalProperties,
50
+ };
51
+ // Update top-level config properties if provided by generator defaults
52
+ if (generatorProps.packageName && !config.packageName) {
53
+ config.packageName = generatorProps.packageName;
54
+ }
55
+ if (generatorProps.apiPackage && !config.apiPackage) {
56
+ config.apiPackage = generatorProps.apiPackage;
57
+ }
58
+ if (generatorProps.modelPackage && !config.modelPackage) {
59
+ config.modelPackage = generatorProps.modelPackage;
60
+ }
61
+ if (options.verbose) {
62
+ console.log("OpenAPI Generator");
63
+ console.log("=================");
64
+ console.log(`Generator: ${options.generatorName}`);
65
+ console.log(`Input: ${options.inputSpec}`);
66
+ console.log(`Output: ${options.outputDir}`);
67
+ if (options.templateDir) {
68
+ console.log(`Templates: ${options.templateDir}`);
69
+ }
70
+ if (options.library) {
71
+ console.log(`Library: ${options.library}`);
72
+ }
73
+ console.log("");
74
+ }
75
+ // Create and run generator
76
+ const generator = createGenerator(config, metadata);
77
+ try {
78
+ const result = await generator.generate();
79
+ const elapsed = Date.now() - startTime;
80
+ // Summary
81
+ const writtenFiles = result.files.filter((f) => !f.skipped);
82
+ const skippedFiles = result.files.filter((f) => f.skipped);
83
+ if (options.verbose || options.dryRun) {
84
+ console.log("");
85
+ console.log("Generation Summary");
86
+ console.log("------------------");
87
+ console.log(`Models: ${result.models.size}`);
88
+ console.log(`API Tags: ${result.operations.size}`);
89
+ console.log(`Files written: ${writtenFiles.length}`);
90
+ console.log(`Files skipped: ${skippedFiles.length}`);
91
+ console.log(`Time: ${elapsed}ms`);
92
+ if (result.warnings.length > 0) {
93
+ console.log("");
94
+ console.log("Warnings:");
95
+ for (const warning of result.warnings) {
96
+ console.log(` - ${warning}`);
97
+ }
98
+ }
99
+ }
100
+ else {
101
+ console.log(`Generated ${writtenFiles.length} files in ${options.outputDir} (${elapsed}ms)`);
102
+ }
103
+ if (options.dryRun) {
104
+ console.log("");
105
+ console.log("(Dry run - no files were actually written)");
106
+ }
107
+ }
108
+ catch (error) {
109
+ console.error("Generation failed:", error instanceof Error ? error.message : error);
110
+ if (options.debug) {
111
+ console.error(error);
112
+ }
113
+ process.exit(1);
114
+ }
115
+ }
116
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":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CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAC9C,CAAC;QACF,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function listCommand(): void;
2
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,IAAI,IAAI,CAuBlC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * List command handler
3
+ */
4
+ import { getGenerator, listGenerators } from "../../generators/index.js";
5
+ export function listCommand() {
6
+ console.log("Available generators:");
7
+ console.log("");
8
+ const generators = listGenerators();
9
+ for (const name of generators) {
10
+ const metadata = getGenerator(name);
11
+ if (metadata) {
12
+ console.log(` ${name}`);
13
+ if (metadata.description) {
14
+ console.log(` ${metadata.description}`);
15
+ }
16
+ console.log(` Type: ${metadata.type}`);
17
+ console.log(` Language: ${metadata.language}`);
18
+ if (metadata.libraries && metadata.libraries.length > 0) {
19
+ console.log(` Libraries: ${metadata.libraries.join(", ")}`);
20
+ }
21
+ console.log("");
22
+ }
23
+ }
24
+ console.log(`Total: ${generators.length} generators available`);
25
+ }
26
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEzE,MAAM,UAAU,WAAW;IAC1B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,MAAM,UAAU,GAAG,cAAc,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACzB,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;gBAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;YAC5C,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,iBAAiB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YAClD,IAAI,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACzD,OAAO,CAAC,GAAG,CAAC,kBAAkB,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;IACF,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,UAAU,UAAU,CAAC,MAAM,uBAAuB,CAAC,CAAC;AACjE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface ValidateOptions {
2
+ inputSpec: string;
3
+ strict?: boolean;
4
+ }
5
+ export declare function validateCommand(options: ValidateOptions): Promise<void>;
6
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/validate.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoF7E"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Validate command handler
3
+ */
4
+ import { getInfo, getPaths, getSchemas, parseSpec, } from "../../parser/openapi-parser.js";
5
+ export async function validateCommand(options) {
6
+ console.log(`Validating: ${options.inputSpec}`);
7
+ console.log("");
8
+ try {
9
+ const spec = await parseSpec(options.inputSpec, {
10
+ validate: true,
11
+ dereference: false, // Don't dereference for validation
12
+ });
13
+ const info = getInfo(spec.document);
14
+ const schemas = getSchemas(spec.document);
15
+ const paths = getPaths(spec.document);
16
+ console.log("Validation successful!");
17
+ console.log("");
18
+ console.log("Specification Details:");
19
+ console.log(` Title: ${info.title}`);
20
+ console.log(` Version: ${info.version}`);
21
+ console.log(` OpenAPI Version: ${spec.version}`);
22
+ if (info.description) {
23
+ console.log(` Description: ${info.description.substring(0, 100)}...`);
24
+ }
25
+ console.log("");
26
+ console.log("Statistics:");
27
+ console.log(` Schemas: ${Object.keys(schemas).length}`);
28
+ console.log(` Paths: ${Object.keys(paths).length}`);
29
+ // Count operations
30
+ let operationCount = 0;
31
+ const methods = [
32
+ "get",
33
+ "post",
34
+ "put",
35
+ "delete",
36
+ "patch",
37
+ "options",
38
+ "head",
39
+ "trace",
40
+ ];
41
+ for (const pathItem of Object.values(paths)) {
42
+ if (!pathItem)
43
+ continue;
44
+ for (const method of methods) {
45
+ if (pathItem[method]) {
46
+ operationCount++;
47
+ }
48
+ }
49
+ }
50
+ console.log(` Operations: ${operationCount}`);
51
+ if (options.strict) {
52
+ // Additional strict checks could go here
53
+ console.log("");
54
+ console.log("Strict validation passed.");
55
+ }
56
+ }
57
+ catch (error) {
58
+ console.error("Validation failed!");
59
+ console.error("");
60
+ if (error instanceof Error) {
61
+ console.error("Error:", error.message);
62
+ // Try to provide more context for common errors
63
+ if (error.message.includes("$ref")) {
64
+ console.error("");
65
+ console.error("Hint: This appears to be a reference error. Check that all $ref");
66
+ console.error(" references point to valid schema definitions.");
67
+ }
68
+ if (error.message.includes("required")) {
69
+ console.error("");
70
+ console.error("Hint: A required field is missing. Check the OpenAPI specification");
71
+ console.error(' for required fields like "info", "paths", etc.');
72
+ }
73
+ }
74
+ else {
75
+ console.error("Error:", error);
76
+ }
77
+ process.exit(1);
78
+ }
79
+ }
80
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/cli/commands/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACN,OAAO,EACP,QAAQ,EACR,UAAU,EACV,SAAS,GACT,MAAM,gCAAgC,CAAC;AAOxC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAwB;IAC7D,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE;YAC/C,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,KAAK,EAAE,mCAAmC;SACvD,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAA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AAC,CAAC;QAC1C,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAElB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAEvC,gDAAgD;YAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,OAAO,CAAC,KAAK,CACZ,iEAAiE,CACjE,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;YACtE,CAAC;YAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBACxC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,OAAO,CAAC,KAAK,CACZ,oEAAoE,CACpE,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACvE,CAAC;QACF,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC"}
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Mustache to Handlebars Template Converter
4
+ *
5
+ * Converts OpenAPI Generator Mustache templates to Handlebars-compatible format.
6
+ *
7
+ * Handlebars is largely compatible with Mustache, but there are a few key differences:
8
+ *
9
+ * 1. Delimiter changes ({{=<% %>=}}) are NOT supported in Handlebars
10
+ * - These are converted to helper calls or removed
11
+ *
12
+ * 2. The {{#lambda.xxx}}...{{/lambda.xxx}} pattern becomes {{#xxx}}...{{/xxx}}
13
+ * - Lambda helpers are registered in the engine adapter
14
+ *
15
+ * 3. Array index access like foo.0.bar needs bracket notation: foo.[0].bar
16
+ * - Handlebars requires this for numeric keys
17
+ *
18
+ * Most other Mustache syntax works identically in Handlebars:
19
+ * - {{var}} - escaped output
20
+ * - {{{var}}} - unescaped output
21
+ * - {{#section}}...{{/section}} - block sections
22
+ * - {{^inverted}}...{{/inverted}} - inverted sections
23
+ * - {{>partial}} - partials
24
+ * - {{!comment}} - comments
25
+ */
26
+ /**
27
+ * Convert a Mustache template to Handlebars-compatible format
28
+ * Uses simple regex-based transformations for reliability
29
+ */
30
+ export declare function convertTemplate(content: string): string;
31
+ //# sourceMappingURL=convert-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-template.d.ts","sourceRoot":"","sources":["../../src/cli/convert-template.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAyMvD"}