swagger-typescript-api 11.0.0 → 11.0.2
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/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -290,7 +290,14 @@ const main = async () => {
|
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
292
|
case "generate-templates": {
|
|
293
|
-
await generateTemplates(
|
|
293
|
+
await generateTemplates({
|
|
294
|
+
cleanOutput: options.cleanOutput,
|
|
295
|
+
output: options.output,
|
|
296
|
+
httpClientType: options.httpClient,
|
|
297
|
+
modular: options.modular,
|
|
298
|
+
silent: options.silent,
|
|
299
|
+
rewrite: options.rewrite,
|
|
300
|
+
});
|
|
294
301
|
break;
|
|
295
302
|
}
|
|
296
303
|
default: {
|
package/package.json
CHANGED
|
@@ -56,16 +56,40 @@ class TemplatesGenProcess {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
templates.forEach((template) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const templateName = this.fileSystem.cropExtension(template.name);
|
|
60
|
+
const templateEjsPath = path.resolve(outputPath, `${templateName}.ejs`);
|
|
61
|
+
const templateEtaPath = path.resolve(outputPath, `${templateName}.eta`);
|
|
62
|
+
const templateEjsPathExist = this.fileSystem.pathIsExist(templateEjsPath);
|
|
63
|
+
const templateEtaPathExist = this.fileSystem.pathIsExist(templateEtaPath);
|
|
64
|
+
|
|
65
|
+
const templateNotExist = !templateEjsPathExist && !templateEtaPathExist;
|
|
66
|
+
|
|
67
|
+
if (templateNotExist) {
|
|
61
68
|
this.fileSystem.createFile({
|
|
62
69
|
path: outputPath,
|
|
63
70
|
fileName: template.name,
|
|
64
71
|
content: template.content,
|
|
65
72
|
withPrefix: false,
|
|
66
73
|
});
|
|
74
|
+
} else if (this.config.rewrite) {
|
|
75
|
+
if (templateEjsPathExist) {
|
|
76
|
+
this.fileSystem.createFile({
|
|
77
|
+
path: outputPath,
|
|
78
|
+
fileName: `${templateName}.ejs`,
|
|
79
|
+
content: template.content,
|
|
80
|
+
withPrefix: false,
|
|
81
|
+
});
|
|
82
|
+
} else if (templateEtaPathExist) {
|
|
83
|
+
this.fileSystem.createFile({
|
|
84
|
+
path: outputPath,
|
|
85
|
+
fileName: `${templateName}.eta`,
|
|
86
|
+
content: template.content,
|
|
87
|
+
withPrefix: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
67
90
|
}
|
|
68
91
|
});
|
|
92
|
+
|
|
69
93
|
this.logger.success(`source templates has been successfully created in "${outputPath}"`);
|
|
70
94
|
}
|
|
71
95
|
|
|
@@ -83,23 +107,26 @@ class TemplatesGenProcess {
|
|
|
83
107
|
const apiTemplatesPath = this.config.modular ? this.paths.moduleApiTemplates : this.paths.defaultApiTemplates;
|
|
84
108
|
const apiTemplates = this.getTemplateNamesFromDir(apiTemplatesPath);
|
|
85
109
|
|
|
86
|
-
for (const fileName of baseTemplates) {
|
|
87
|
-
outputFiles.push({
|
|
88
|
-
name: fileName,
|
|
89
|
-
content: this.fixTemplateContent(this.getTemplateContent(`${this.paths.baseTemplates}/${fileName}`)),
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
110
|
const usingHttpClientTemplate = httpClientTemplates.find((template) =>
|
|
94
111
|
template.startsWith(`${this.config.httpClientType}-`),
|
|
95
112
|
);
|
|
96
113
|
|
|
114
|
+
let httpClientTemplateContent = "";
|
|
115
|
+
|
|
97
116
|
if (usingHttpClientTemplate) {
|
|
117
|
+
httpClientTemplateContent = this.fixTemplateContent(
|
|
118
|
+
this.getTemplateContent(`${this.paths.httpClientTemplates}/${usingHttpClientTemplate}`),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const fileName of baseTemplates) {
|
|
123
|
+
const templateContent =
|
|
124
|
+
(fileName === "http-client.ejs" && httpClientTemplateContent) ||
|
|
125
|
+
this.fixTemplateContent(this.getTemplateContent(`${this.paths.baseTemplates}/${fileName}`));
|
|
126
|
+
|
|
98
127
|
outputFiles.push({
|
|
99
|
-
name:
|
|
100
|
-
content:
|
|
101
|
-
this.getTemplateContent(`${this.paths.httpClientTemplates}/${usingHttpClientTemplate}`),
|
|
102
|
-
),
|
|
128
|
+
name: fileName,
|
|
129
|
+
content: templateContent,
|
|
103
130
|
});
|
|
104
131
|
}
|
|
105
132
|
|