api-core-lib 12.0.43 → 12.0.44
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/dist/cli.cjs +8 -22
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -70,7 +70,11 @@ function parseSpecToModules(spec) {
|
|
|
70
70
|
}
|
|
71
71
|
let inputType = "undefined";
|
|
72
72
|
if (requestBody) {
|
|
73
|
-
|
|
73
|
+
if (requestBody.$ref) {
|
|
74
|
+
inputType = refToTypeName(requestBody.$ref);
|
|
75
|
+
} else if (requestBody.type === "object") {
|
|
76
|
+
inputType = "any";
|
|
77
|
+
}
|
|
74
78
|
} else if ((endpoint.parameters || []).some((p) => p.in === "query")) {
|
|
75
79
|
inputType = "QueryOptions";
|
|
76
80
|
}
|
|
@@ -120,8 +124,7 @@ async function runGenerator(options) {
|
|
|
120
124
|
console.log("\n" + import_chalk.default.blue("Step 3: Generating organized TypeScript types..."));
|
|
121
125
|
const typesOutputPath = import_path.default.join(options.output, "types");
|
|
122
126
|
ignoreFilePath = import_path.default.join(process.cwd(), `.openapi-generator-ignore-${Date.now()}`);
|
|
123
|
-
const ignoreContent =
|
|
124
|
-
# Main generator metadata
|
|
127
|
+
const ignoreContent = `# Main generator metadata
|
|
125
128
|
.openapi-generator/
|
|
126
129
|
# Documentation files
|
|
127
130
|
docs/
|
|
@@ -130,8 +133,7 @@ docs/
|
|
|
130
133
|
git_push.sh
|
|
131
134
|
# NPM helper files
|
|
132
135
|
.npmignore
|
|
133
|
-
README.md
|
|
134
|
-
`;
|
|
136
|
+
README.md`;
|
|
135
137
|
import_fs.default.writeFileSync(ignoreFilePath, ignoreContent);
|
|
136
138
|
console.log(import_chalk.default.gray("\u2713 Created temporary .openapi-generator-ignore file."));
|
|
137
139
|
const generatorCommand = [
|
|
@@ -140,15 +142,7 @@ README.md
|
|
|
140
142
|
`-g typescript-axios`,
|
|
141
143
|
`-o "${typesOutputPath}"`,
|
|
142
144
|
`--ignore-file-override "${ignoreFilePath}"`,
|
|
143
|
-
// ==========================================================
|
|
144
|
-
// ## البداية: التعديل النهائي والنهج الصحيح ##
|
|
145
|
-
// ==========================================================
|
|
146
|
-
// [إصلاح] هذا هو النهج الصحيح لتوليد النماذج فقط.
|
|
147
|
-
// نحن نحدد بالضبط ما نريد توليده (Models) وما لا نريده (APIs, Supporting Files).
|
|
148
145
|
"--global-property models,apis=false,supportingFiles=false",
|
|
149
|
-
// ==========================================================
|
|
150
|
-
// ## النهاية: التعديل النهائي والنهج الصحيح ##
|
|
151
|
-
// ==========================================================
|
|
152
146
|
`--additional-properties=supportsES6=true,useSingleRequestParameter=true,withInterfaces=true,modelPropertyNaming=original`
|
|
153
147
|
].join(" ");
|
|
154
148
|
console.log(import_chalk.default.gray(`Executing command: npx @openapitools/openapi-generator-cli...`));
|
|
@@ -182,18 +176,10 @@ ${actionsTypeParts.join("\n")}
|
|
|
182
176
|
const actionsValueDefinition = `{
|
|
183
177
|
${actionsValueParts.join(",\n")}
|
|
184
178
|
}`;
|
|
185
|
-
const fileContent =
|
|
186
|
-
* This file is auto-generated by api-core-lib.
|
|
187
|
-
* Do not edit this file directly.
|
|
188
|
-
* @module ${moduleName}
|
|
189
|
-
*/
|
|
190
|
-
|
|
179
|
+
const fileContent = `
|
|
191
180
|
import type { ApiModuleConfig, ActionConfigModule, QueryOptions } from 'api-core-lib';
|
|
192
181
|
import type { ${[...allModelTypes].join(", ")} } from '../types';
|
|
193
182
|
|
|
194
|
-
/**
|
|
195
|
-
* Defines the configuration for the ${moduleName} API module.
|
|
196
|
-
*/
|
|
197
183
|
export const ${moduleName}Module: ApiModuleConfig<${actionsTypeDefinition}> = {
|
|
198
184
|
baseEndpoint: '${moduleData.baseEndpoint}',
|
|
199
185
|
actions: ${actionsValueDefinition},
|