@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.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +116 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +26 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +6 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +80 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/convert-template.d.ts +31 -0
- package/dist/cli/convert-template.d.ts.map +1 -0
- package/dist/cli/convert-template.js +204 -0
- package/dist/cli/convert-template.js.map +1 -0
- package/dist/cli/convert-template.test.d.ts +2 -0
- package/dist/cli/convert-template.test.d.ts.map +1 -0
- package/dist/cli/convert-template.test.js +74 -0
- package/dist/cli/convert-template.test.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +246 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +252 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +31 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/generator.d.ts +99 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/generator.js +492 -0
- package/dist/core/generator.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generators/generators.test.d.ts +6 -0
- package/dist/generators/generators.test.d.ts.map +1 -0
- package/dist/generators/generators.test.js +247 -0
- package/dist/generators/generators.test.js.map +1 -0
- package/dist/generators/go.d.ts +10 -0
- package/dist/generators/go.d.ts.map +1 -0
- package/dist/generators/go.js +327 -0
- package/dist/generators/go.js.map +1 -0
- package/dist/generators/index.d.ts +29 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +58 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/php.d.ts +14 -0
- package/dist/generators/php.d.ts.map +1 -0
- package/dist/generators/php.js +241 -0
- package/dist/generators/php.js.map +1 -0
- package/dist/generators/python.d.ts +10 -0
- package/dist/generators/python.d.ts.map +1 -0
- package/dist/generators/python.js +273 -0
- package/dist/generators/python.js.map +1 -0
- package/dist/generators/typescript-fetch.d.ts +14 -0
- package/dist/generators/typescript-fetch.d.ts.map +1 -0
- package/dist/generators/typescript-fetch.js +217 -0
- package/dist/generators/typescript-fetch.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/models/codegen-model.d.ts +123 -0
- package/dist/models/codegen-model.d.ts.map +1 -0
- package/dist/models/codegen-model.js +64 -0
- package/dist/models/codegen-model.js.map +1 -0
- package/dist/models/codegen-model.test.d.ts +6 -0
- package/dist/models/codegen-model.test.d.ts.map +1 -0
- package/dist/models/codegen-model.test.js +143 -0
- package/dist/models/codegen-model.test.js.map +1 -0
- package/dist/models/codegen-operation.d.ts +95 -0
- package/dist/models/codegen-operation.d.ts.map +1 -0
- package/dist/models/codegen-operation.js +54 -0
- package/dist/models/codegen-operation.js.map +1 -0
- package/dist/models/codegen-parameter.d.ts +86 -0
- package/dist/models/codegen-parameter.d.ts.map +1 -0
- package/dist/models/codegen-parameter.js +47 -0
- package/dist/models/codegen-parameter.js.map +1 -0
- package/dist/models/codegen-property.d.ts +95 -0
- package/dist/models/codegen-property.d.ts.map +1 -0
- package/dist/models/codegen-property.js +47 -0
- package/dist/models/codegen-property.js.map +1 -0
- package/dist/models/codegen-response.d.ts +64 -0
- package/dist/models/codegen-response.d.ts.map +1 -0
- package/dist/models/codegen-response.js +42 -0
- package/dist/models/codegen-response.js.map +1 -0
- package/dist/models/codegen-security.d.ts +34 -0
- package/dist/models/codegen-security.d.ts.map +1 -0
- package/dist/models/codegen-security.js +18 -0
- package/dist/models/codegen-security.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +4 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/openapi-parser.d.ts +71 -0
- package/dist/parser/openapi-parser.d.ts.map +1 -0
- package/dist/parser/openapi-parser.js +195 -0
- package/dist/parser/openapi-parser.js.map +1 -0
- package/dist/parser/openapi-parser.test.d.ts +6 -0
- package/dist/parser/openapi-parser.test.d.ts.map +1 -0
- package/dist/parser/openapi-parser.test.js +238 -0
- package/dist/parser/openapi-parser.test.js.map +1 -0
- package/dist/parser/operation-transformer.d.ts +95 -0
- package/dist/parser/operation-transformer.d.ts.map +1 -0
- package/dist/parser/operation-transformer.js +634 -0
- package/dist/parser/operation-transformer.js.map +1 -0
- package/dist/parser/schema-transformer.d.ts +134 -0
- package/dist/parser/schema-transformer.d.ts.map +1 -0
- package/dist/parser/schema-transformer.js +557 -0
- package/dist/parser/schema-transformer.js.map +1 -0
- package/dist/template/engine-adapter.d.ts +55 -0
- package/dist/template/engine-adapter.d.ts.map +1 -0
- package/dist/template/engine-adapter.js +178 -0
- package/dist/template/engine-adapter.js.map +1 -0
- package/dist/template/engine-adapter.test.d.ts +6 -0
- package/dist/template/engine-adapter.test.d.ts.map +1 -0
- package/dist/template/engine-adapter.test.js +186 -0
- package/dist/template/engine-adapter.test.js.map +1 -0
- package/dist/template/index.d.ts +5 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js +5 -0
- package/dist/template/index.js.map +1 -0
- package/dist/template/lambdas/indent-lambdas.d.ts +40 -0
- package/dist/template/lambdas/indent-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/indent-lambdas.js +98 -0
- package/dist/template/lambdas/indent-lambdas.js.map +1 -0
- package/dist/template/lambdas/index.d.ts +44 -0
- package/dist/template/lambdas/index.d.ts.map +1 -0
- package/dist/template/lambdas/index.js +79 -0
- package/dist/template/lambdas/index.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.d.ts +78 -0
- package/dist/template/lambdas/string-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.js +148 -0
- package/dist/template/lambdas/string-lambdas.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts +6 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.js +158 -0
- package/dist/template/lambdas/string-lambdas.test.js.map +1 -0
- package/dist/template/template-locator.d.ts +72 -0
- package/dist/template/template-locator.d.ts.map +1 -0
- package/dist/template/template-locator.js +173 -0
- package/dist/template/template-locator.js.map +1 -0
- package/dist/template/template-manager.d.ts +65 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +185 -0
- package/dist/template/template-manager.js.map +1 -0
- package/package.json +67 -0
- package/templates/go/.travis.yml +8 -0
- package/templates/go/README.mustache +236 -0
- package/templates/go/api.mustache +452 -0
- package/templates/go/api_doc.mustache +92 -0
- package/templates/go/api_test.mustache +59 -0
- package/templates/go/client.mustache +761 -0
- package/templates/go/configuration.mustache +332 -0
- package/templates/go/git_push.sh.mustache +57 -0
- package/templates/go/gitignore.mustache +24 -0
- package/templates/go/go.mod.mustache +16 -0
- package/templates/go/go.sum.mustache +19 -0
- package/templates/go/model.mustache +21 -0
- package/templates/go/model_anyof.mustache +93 -0
- package/templates/go/model_doc.mustache +97 -0
- package/templates/go/model_enum.mustache +101 -0
- package/templates/go/model_oneof.mustache +160 -0
- package/templates/go/model_simple.mustache +572 -0
- package/templates/go/nullable_model.mustache +35 -0
- package/templates/go/openapi.mustache +1 -0
- package/templates/go/partial_header.mustache +18 -0
- package/templates/go/response.mustache +38 -0
- package/templates/go/signing.mustache +453 -0
- package/templates/go/utils.mustache +352 -0
- package/templates/php/.php-cs-fixer.dist.php +29 -0
- package/templates/php/.travis.yml +8 -0
- package/templates/php/ApiException.mustache +111 -0
- package/templates/php/Configuration.mustache +606 -0
- package/templates/php/FormDataProcessor.mustache +238 -0
- package/templates/php/HeaderSelector.mustache +265 -0
- package/templates/php/ModelInterface.mustache +103 -0
- package/templates/php/ObjectSerializer.mustache +591 -0
- package/templates/php/README.mustache +151 -0
- package/templates/php/api.mustache +891 -0
- package/templates/php/api_doc.mustache +105 -0
- package/templates/php/api_test.mustache +80 -0
- package/templates/php/composer.mustache +44 -0
- package/templates/php/git_push.sh.mustache +57 -0
- package/templates/php/gitignore +15 -0
- package/templates/php/libraries/psr-18/ApiException.mustache +114 -0
- package/templates/php/libraries/psr-18/DebugPlugin.mustache +93 -0
- package/templates/php/libraries/psr-18/README.mustache +161 -0
- package/templates/php/libraries/psr-18/api.mustache +833 -0
- package/templates/php/libraries/psr-18/api_doc.mustache +79 -0
- package/templates/php/libraries/psr-18/composer.mustache +56 -0
- package/templates/php/model.mustache +47 -0
- package/templates/php/model_doc.mustache +10 -0
- package/templates/php/model_enum.mustache +33 -0
- package/templates/php/model_generic.mustache +565 -0
- package/templates/php/model_test.mustache +88 -0
- package/templates/php/partial_header.mustache +18 -0
- package/templates/php/php_doc_auth_partial.mustache +23 -0
- package/templates/php/phpunit.xml.mustache +18 -0
- package/templates/python/README.mustache +60 -0
- package/templates/python/README_onlypackage.mustache +50 -0
- package/templates/python/__init__.mustache +1 -0
- package/templates/python/__init__api.mustache +19 -0
- package/templates/python/__init__model.mustache +22 -0
- package/templates/python/__init__package.mustache +49 -0
- package/templates/python/api.mustache +244 -0
- package/templates/python/api_client.mustache +822 -0
- package/templates/python/api_doc.mustache +81 -0
- package/templates/python/api_doc_example.mustache +38 -0
- package/templates/python/api_response.mustache +21 -0
- package/templates/python/api_test.mustache +48 -0
- package/templates/python/asyncio/rest.mustache +209 -0
- package/templates/python/common_README.mustache +85 -0
- package/templates/python/configuration.mustache +806 -0
- package/templates/python/exceptions.mustache +210 -0
- package/templates/python/exports_api.mustache +3 -0
- package/templates/python/exports_model.mustache +3 -0
- package/templates/python/exports_package.mustache +20 -0
- package/templates/python/git_push.sh.mustache +57 -0
- package/templates/python/github-workflow.mustache +35 -0
- package/templates/python/gitignore.mustache +66 -0
- package/templates/python/gitlab-ci.mustache +31 -0
- package/templates/python/httpx/rest.mustache +190 -0
- package/templates/python/model.mustache +16 -0
- package/templates/python/model_anyof.mustache +182 -0
- package/templates/python/model_doc.mustache +40 -0
- package/templates/python/model_enum.mustache +36 -0
- package/templates/python/model_generic.mustache +403 -0
- package/templates/python/model_oneof.mustache +209 -0
- package/templates/python/model_test.mustache +60 -0
- package/templates/python/partial_api.mustache +52 -0
- package/templates/python/partial_api_args.mustache +18 -0
- package/templates/python/partial_header.mustache +19 -0
- package/templates/python/py.typed.mustache +1 -0
- package/templates/python/pyproject.mustache +172 -0
- package/templates/python/python_doc_auth_partial.mustache +108 -0
- package/templates/python/requirements.mustache +23 -0
- package/templates/python/rest.mustache +254 -0
- package/templates/python/setup.mustache +60 -0
- package/templates/python/setup_cfg.mustache +2 -0
- package/templates/python/signing.mustache +422 -0
- package/templates/python/test-requirements.mustache +6 -0
- package/templates/python/tornado/rest.mustache +148 -0
- package/templates/python/tox.mustache +9 -0
- package/templates/python/travis.mustache +17 -0
- package/templates/typescript-fetch/ApiEntitiesRecord.mustache +26 -0
- package/templates/typescript-fetch/ApiEntitiesReducer.mustache +21 -0
- package/templates/typescript-fetch/ApiEntitiesSelectors.mustache +5 -0
- package/templates/typescript-fetch/README.mustache +127 -0
- package/templates/typescript-fetch/allSagas.mustache +19 -0
- package/templates/typescript-fetch/api_doc.mustache +63 -0
- package/templates/typescript-fetch/api_example.mustache +44 -0
- package/templates/typescript-fetch/apis.index.mustache +16 -0
- package/templates/typescript-fetch/apis.mustache +483 -0
- package/templates/typescript-fetch/apisAssignQueryParam.mustache +12 -0
- package/templates/typescript-fetch/gitignore +4 -0
- package/templates/typescript-fetch/index.mustache +17 -0
- package/templates/typescript-fetch/licenseInfo.mustache +11 -0
- package/templates/typescript-fetch/modelEnum.mustache +28 -0
- package/templates/typescript-fetch/modelEnumInterfaces.mustache +37 -0
- package/templates/typescript-fetch/modelGeneric.mustache +261 -0
- package/templates/typescript-fetch/modelGenericInterfaces.mustache +50 -0
- package/templates/typescript-fetch/modelOneOf.mustache +255 -0
- package/templates/typescript-fetch/modelOneOfInterfaces.mustache +6 -0
- package/templates/typescript-fetch/model_doc.mustache +41 -0
- package/templates/typescript-fetch/models.index.mustache +32 -0
- package/templates/typescript-fetch/models.mustache +24 -0
- package/templates/typescript-fetch/npmignore.mustache +1 -0
- package/templates/typescript-fetch/package.mustache +43 -0
- package/templates/typescript-fetch/recordGeneric.mustache +295 -0
- package/templates/typescript-fetch/records.mustache +17 -0
- package/templates/typescript-fetch/runtime.mustache +424 -0
- package/templates/typescript-fetch/runtimeSagasAndRecords.mustache +120 -0
- package/templates/typescript-fetch/sagaApiManager.mustache +28 -0
- package/templates/typescript-fetch/sagas.mustache +245 -0
- package/templates/typescript-fetch/sourceLibraryIndex.mustache +1 -0
- package/templates/typescript-fetch/tsconfig.esm.mustache +7 -0
- package/templates/typescript-fetch/tsconfig.mustache +25 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface CodegenConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Generator name/type
|
|
7
|
+
*/
|
|
8
|
+
generatorName: string;
|
|
9
|
+
/**
|
|
10
|
+
* Input OpenAPI spec file
|
|
11
|
+
*/
|
|
12
|
+
inputSpec: string;
|
|
13
|
+
/**
|
|
14
|
+
* Output directory
|
|
15
|
+
*/
|
|
16
|
+
outputDir: string;
|
|
17
|
+
/**
|
|
18
|
+
* Custom template directory
|
|
19
|
+
*/
|
|
20
|
+
templateDir?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Library variant to use
|
|
23
|
+
*/
|
|
24
|
+
library?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Package name for generated code
|
|
27
|
+
*/
|
|
28
|
+
packageName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* API package name
|
|
31
|
+
*/
|
|
32
|
+
apiPackage?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Model package name
|
|
35
|
+
*/
|
|
36
|
+
modelPackage?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Invoker package name
|
|
39
|
+
*/
|
|
40
|
+
invokerPackage?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Additional properties to pass to templates
|
|
43
|
+
*/
|
|
44
|
+
additionalProperties?: Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Global properties
|
|
47
|
+
*/
|
|
48
|
+
globalProperties?: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Type mappings (OpenAPI type -> target type)
|
|
51
|
+
*/
|
|
52
|
+
typeMappings?: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Import mappings (model name -> import path)
|
|
55
|
+
*/
|
|
56
|
+
importMappings?: Record<string, string>;
|
|
57
|
+
/**
|
|
58
|
+
* Name mappings (OpenAPI name -> target name)
|
|
59
|
+
*/
|
|
60
|
+
nameMappings?: Record<string, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Reserved words that should not be used as names
|
|
63
|
+
*/
|
|
64
|
+
reservedWordsMappings?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Skip generating these files
|
|
67
|
+
*/
|
|
68
|
+
skipFiles?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Only generate these files
|
|
71
|
+
*/
|
|
72
|
+
files?: Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Skip overwriting existing files
|
|
75
|
+
*/
|
|
76
|
+
skipOverwrite?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Only write files if content changed
|
|
79
|
+
*/
|
|
80
|
+
minimalUpdate?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Don't write files, just show what would be generated
|
|
83
|
+
*/
|
|
84
|
+
dryRun?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Generate models
|
|
87
|
+
*/
|
|
88
|
+
generateModels?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Generate APIs
|
|
91
|
+
*/
|
|
92
|
+
generateApis?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Generate supporting files
|
|
95
|
+
*/
|
|
96
|
+
generateSupportingFiles?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Validate spec before generation
|
|
99
|
+
*/
|
|
100
|
+
validateSpec?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Strict spec mode
|
|
103
|
+
*/
|
|
104
|
+
strictSpec?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Enable verbose output
|
|
107
|
+
*/
|
|
108
|
+
verbose?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Enable debug mode
|
|
111
|
+
*/
|
|
112
|
+
debug?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface SupportingFileConfig {
|
|
115
|
+
/**
|
|
116
|
+
* Template file name
|
|
117
|
+
*/
|
|
118
|
+
templateFile: string;
|
|
119
|
+
/**
|
|
120
|
+
* Destination folder (relative to output dir)
|
|
121
|
+
*/
|
|
122
|
+
folder: string;
|
|
123
|
+
/**
|
|
124
|
+
* Destination file name
|
|
125
|
+
*/
|
|
126
|
+
destinationFilename: string;
|
|
127
|
+
/**
|
|
128
|
+
* Condition to check before generating
|
|
129
|
+
*/
|
|
130
|
+
condition?: (config: CodegenConfig) => boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface GeneratorMetadata {
|
|
133
|
+
/**
|
|
134
|
+
* Generator name
|
|
135
|
+
*/
|
|
136
|
+
name: string;
|
|
137
|
+
/**
|
|
138
|
+
* Generator description
|
|
139
|
+
*/
|
|
140
|
+
description?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Generator type (client, server, documentation, etc.)
|
|
143
|
+
*/
|
|
144
|
+
type: "client" | "server" | "documentation" | "config" | "schema" | "other";
|
|
145
|
+
/**
|
|
146
|
+
* Target language
|
|
147
|
+
*/
|
|
148
|
+
language: string;
|
|
149
|
+
/**
|
|
150
|
+
* Available libraries/variants
|
|
151
|
+
*/
|
|
152
|
+
libraries?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* Default library
|
|
155
|
+
*/
|
|
156
|
+
defaultLibrary?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Embedded template directory name
|
|
159
|
+
*/
|
|
160
|
+
embeddedTemplateDir: string;
|
|
161
|
+
/**
|
|
162
|
+
* File extension for models
|
|
163
|
+
*/
|
|
164
|
+
modelFileExtension: string;
|
|
165
|
+
/**
|
|
166
|
+
* File extension for APIs
|
|
167
|
+
*/
|
|
168
|
+
apiFileExtension: string;
|
|
169
|
+
/**
|
|
170
|
+
* Model template name
|
|
171
|
+
*/
|
|
172
|
+
modelTemplateFile: string;
|
|
173
|
+
/**
|
|
174
|
+
* API template name
|
|
175
|
+
*/
|
|
176
|
+
apiTemplateFile: string;
|
|
177
|
+
/**
|
|
178
|
+
* Template file for model documentation
|
|
179
|
+
*/
|
|
180
|
+
modelDocTemplateFile?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Template file for API documentation
|
|
183
|
+
*/
|
|
184
|
+
apiDocTemplateFile?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Default API package/folder (defaults to "api")
|
|
187
|
+
*/
|
|
188
|
+
defaultApiPackage?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Default model package/folder (defaults to "models")
|
|
191
|
+
*/
|
|
192
|
+
defaultModelPackage?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Supporting files to generate
|
|
195
|
+
*/
|
|
196
|
+
supportingFiles: SupportingFileConfig[];
|
|
197
|
+
/**
|
|
198
|
+
* Reserved words in the target language
|
|
199
|
+
*/
|
|
200
|
+
reservedWords: Set<string>;
|
|
201
|
+
/**
|
|
202
|
+
* Default type mappings
|
|
203
|
+
*/
|
|
204
|
+
defaultTypeMappings: Record<string, string>;
|
|
205
|
+
/**
|
|
206
|
+
* Default import mappings
|
|
207
|
+
*/
|
|
208
|
+
defaultImportMappings: Record<string, string>;
|
|
209
|
+
/**
|
|
210
|
+
* API name suffix (e.g., "Api" for TypeScript, "API" for Go)
|
|
211
|
+
*/
|
|
212
|
+
apiNameSuffix?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Convert API tag to class name (e.g., "pets" -> "PetsApi" or "PetsAPI")
|
|
215
|
+
*/
|
|
216
|
+
toApiClassName?: (tag: string, suffix: string) => string;
|
|
217
|
+
/**
|
|
218
|
+
* Convert model name to file name (e.g., "Pet" -> "Pet.ts" or "model_pet.go")
|
|
219
|
+
*/
|
|
220
|
+
toModelFilename?: (modelName: string) => string;
|
|
221
|
+
/**
|
|
222
|
+
* Convert API class name to file name (e.g., "PetsApi" -> "PetsApi.ts" or "api_pets.go")
|
|
223
|
+
*/
|
|
224
|
+
toApiFilename?: (className: string) => string;
|
|
225
|
+
/**
|
|
226
|
+
* Convert operation ID for the target language (e.g., "getPet" -> "GetPet" for Go)
|
|
227
|
+
*/
|
|
228
|
+
toOperationId?: (name: string) => string;
|
|
229
|
+
/**
|
|
230
|
+
* Convert property name for the target language (e.g., "petId" -> "PetId" for Go)
|
|
231
|
+
*/
|
|
232
|
+
toVarName?: (name: string) => string;
|
|
233
|
+
/**
|
|
234
|
+
* Post-process a property for generator-specific transformations.
|
|
235
|
+
* For Go, this adds x-go-base-type and x-go-datatag vendor extensions.
|
|
236
|
+
*/
|
|
237
|
+
postProcessProperty?: (property: import("../models/index.js").CodegenProperty) => void;
|
|
238
|
+
/**
|
|
239
|
+
* Post-process a model for generator-specific transformations.
|
|
240
|
+
* For Go, this adds x-go-generate-marshal-json and x-go-generate-unmarshal-json.
|
|
241
|
+
*/
|
|
242
|
+
postProcessModel?: (model: import("../models/index.js").CodegenModel, config: CodegenConfig) => void;
|
|
243
|
+
/**
|
|
244
|
+
* Post-process an operation for generator-specific transformations.
|
|
245
|
+
*/
|
|
246
|
+
postProcessOperation?: (operation: import("../models/index.js").CodegenOperation, config: CodegenConfig) => void;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Create default config with sensible defaults
|
|
250
|
+
*/
|
|
251
|
+
export declare function createDefaultConfig(overrides?: Partial<CodegenConfig>): CodegenConfig;
|
|
252
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,aAAa;IAC7B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/C;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;OAEG;IACH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AC;IAEhD;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEzC;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAErC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CACrB,QAAQ,EAAE,OAAO,oBAAoB,EAAE,eAAe,KAClD,IAAI,CAAC;IAEV;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAClB,KAAK,EAAE,OAAO,oBAAoB,EAAE,YAAY,EAChD,MAAM,EAAE,aAAa,KACjB,IAAI,CAAC;IACV;;OAEG;IACH,oBAAoB,CAAC,EAAE,CACtB,SAAS,EAAE,OAAO,oBAAoB,EAAE,gBAAgB,EACxD,MAAM,EAAE,aAAa,KACjB,IAAI,CAAC;CACV;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,SAAS,GAAE,OAAO,CAAC,aAAa,CAAM,GACpC,aAAa,CAuBf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generator configuration
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create default config with sensible defaults
|
|
6
|
+
*/
|
|
7
|
+
export function createDefaultConfig(overrides = {}) {
|
|
8
|
+
return {
|
|
9
|
+
generatorName: "typescript",
|
|
10
|
+
inputSpec: "",
|
|
11
|
+
outputDir: "./generated",
|
|
12
|
+
generateModels: true,
|
|
13
|
+
generateApis: true,
|
|
14
|
+
generateSupportingFiles: true,
|
|
15
|
+
validateSpec: true,
|
|
16
|
+
strictSpec: false,
|
|
17
|
+
skipOverwrite: false,
|
|
18
|
+
minimalUpdate: true,
|
|
19
|
+
dryRun: false,
|
|
20
|
+
verbose: false,
|
|
21
|
+
debug: false,
|
|
22
|
+
additionalProperties: {},
|
|
23
|
+
globalProperties: {},
|
|
24
|
+
typeMappings: {},
|
|
25
|
+
importMappings: {},
|
|
26
|
+
nameMappings: {},
|
|
27
|
+
reservedWordsMappings: {},
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsTH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAClC,YAAoC,EAAE;IAEtC,OAAO;QACN,aAAa,EAAE,YAAY;QAC3B,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,aAAa;QACxB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,uBAAuB,EAAE,IAAI;QAC7B,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,KAAK;QACpB,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,oBAAoB,EAAE,EAAE;QACxB,gBAAgB,EAAE,EAAE;QACpB,YAAY,EAAE,EAAE;QAChB,cAAc,EAAE,EAAE;QAClB,YAAY,EAAE,EAAE;QAChB,qBAAqB,EAAE,EAAE;QACzB,GAAG,SAAS;KACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default Generator
|
|
3
|
+
* Main orchestrator for code generation
|
|
4
|
+
*/
|
|
5
|
+
import type { CodegenModel, CodegenOperation } from "../models/index.js";
|
|
6
|
+
import { type ParsedSpec } from "../parser/openapi-parser.js";
|
|
7
|
+
import { TemplateManager } from "../template/template-manager.js";
|
|
8
|
+
import type { CodegenConfig, GeneratorMetadata } from "./config.js";
|
|
9
|
+
import type { GeneratedFile } from "./types.js";
|
|
10
|
+
export interface GenerationResult {
|
|
11
|
+
/**
|
|
12
|
+
* Files that were generated
|
|
13
|
+
*/
|
|
14
|
+
files: GeneratedFile[];
|
|
15
|
+
/**
|
|
16
|
+
* Models that were processed
|
|
17
|
+
*/
|
|
18
|
+
models: Map<string, CodegenModel>;
|
|
19
|
+
/**
|
|
20
|
+
* Operations grouped by tag
|
|
21
|
+
*/
|
|
22
|
+
operations: Map<string, CodegenOperation[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Any warnings during generation
|
|
25
|
+
*/
|
|
26
|
+
warnings: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Any errors during generation
|
|
29
|
+
*/
|
|
30
|
+
errors: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface GeneratorContext {
|
|
33
|
+
config: CodegenConfig;
|
|
34
|
+
spec: ParsedSpec;
|
|
35
|
+
models: Map<string, CodegenModel>;
|
|
36
|
+
operations: Map<string, CodegenOperation[]>;
|
|
37
|
+
templateManager: TemplateManager;
|
|
38
|
+
globalProperties: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Default code generator
|
|
42
|
+
*/
|
|
43
|
+
export declare class DefaultGenerator {
|
|
44
|
+
private config;
|
|
45
|
+
private metadata;
|
|
46
|
+
private templateManager;
|
|
47
|
+
private schemaTransformer;
|
|
48
|
+
private operationTransformer;
|
|
49
|
+
private embeddedTemplatesDir;
|
|
50
|
+
constructor(config: CodegenConfig, metadata: GeneratorMetadata);
|
|
51
|
+
/**
|
|
52
|
+
* Find the embedded templates directory
|
|
53
|
+
*/
|
|
54
|
+
private findEmbeddedTemplatesDir;
|
|
55
|
+
/**
|
|
56
|
+
* Run the code generation process
|
|
57
|
+
*/
|
|
58
|
+
generate(): Promise<GenerationResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Generate model files
|
|
61
|
+
*/
|
|
62
|
+
private generateModels;
|
|
63
|
+
/**
|
|
64
|
+
* Generate API files
|
|
65
|
+
*/
|
|
66
|
+
private generateApis;
|
|
67
|
+
/**
|
|
68
|
+
* Generate supporting files
|
|
69
|
+
*/
|
|
70
|
+
private generateSupportingFiles;
|
|
71
|
+
/**
|
|
72
|
+
* Derive a package name from the API title
|
|
73
|
+
* This is used when packageName is not explicitly set
|
|
74
|
+
*/
|
|
75
|
+
private derivePackageName;
|
|
76
|
+
/**
|
|
77
|
+
* Interpolate simple template variables in folder paths
|
|
78
|
+
* Supports {{variableName}} syntax for path interpolation
|
|
79
|
+
*/
|
|
80
|
+
private interpolatePath;
|
|
81
|
+
/**
|
|
82
|
+
* Create global template data available to all templates
|
|
83
|
+
*/
|
|
84
|
+
private createGlobalTemplateData;
|
|
85
|
+
/**
|
|
86
|
+
* Convert tag to API class name
|
|
87
|
+
*/
|
|
88
|
+
private toApiClassName;
|
|
89
|
+
/**
|
|
90
|
+
* Collect imports from operations
|
|
91
|
+
* Returns array of { className, classname, classVarName } objects for template
|
|
92
|
+
*/
|
|
93
|
+
private collectImports;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a generator with the given config and metadata
|
|
97
|
+
*/
|
|
98
|
+
export declare function createGenerator(config: CodegenConfig, metadata: GeneratorMetadata): DefaultGenerator;
|
|
99
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAyBH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAON,KAAK,UAAU,EAEf,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACN,eAAe,EAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,KAAK,EAAE,aAAa,EA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