@devlearning/swagger-generator 0.0.35 → 0.0.37
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/.vscode/launch.json +1 -2
- package/autogeneration/output/api.autogenerated.ts +34 -1209
- package/autogeneration/output/model.autogenerated.ts +4 -1391
- package/dist/generator.js +21 -16
- package/package.json +3 -2
- package/src/generator.ts +22 -15
package/dist/generator.js
CHANGED
|
@@ -88,25 +88,30 @@ ${API_POST}`, { flag: 'w' });
|
|
|
88
88
|
// });
|
|
89
89
|
console.debug(`Start autogeneration Models`);
|
|
90
90
|
let models = ``;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
`
|
|
91
|
+
if (this._swagger.components != null
|
|
92
|
+
&& this._swagger.components != undefined
|
|
93
|
+
&& this._swagger.components.schemas != null
|
|
94
|
+
&& this._swagger.components.schemas != undefined) {
|
|
95
|
+
for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
|
|
96
|
+
const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
|
|
97
|
+
if (modelName == 'ActivatedVoucherSnackListResponse') {
|
|
98
|
+
console.debug("ActivatedVoucherSnackListResponse");
|
|
99
|
+
}
|
|
100
|
+
if (usedTypes.indexOf(modelName) < 0) {
|
|
101
|
+
console.debug(`\tModel SKIP - ${modelName}`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
;
|
|
105
|
+
const swaggerCopmponent = this._swagger.components.schemas[modelName];
|
|
106
|
+
console.debug(`\tModel - ${modelName}`);
|
|
107
|
+
let type = swaggerCopmponent.type == 'integer' ? 'enum' : 'class';
|
|
108
|
+
let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
|
|
109
|
+
models +=
|
|
110
|
+
`
|
|
107
111
|
export ${type} ${modelName} {${content}
|
|
108
112
|
}
|
|
109
113
|
`;
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
116
|
usedMultiPart.forEach(apiName => {
|
|
112
117
|
const swaggerMethod = this._swagger.paths[apiName];
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devlearning/swagger-generator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"dev": "ts-node --esm ./src/index.ts http://localhost:
|
|
8
|
+
"dev": "ts-node --esm ./src/index.ts http://localhost:7550/swagger/ApiGateway/swagger.json autogeneration/output",
|
|
9
|
+
"debug": "npx tsx src/index.ts http://localhost:7550/swagger/ApiGateway/swagger.json autogeneration/output",
|
|
9
10
|
"deploy": "npx tsc && npm publish"
|
|
10
11
|
},
|
|
11
12
|
"bin": {
|
package/src/generator.ts
CHANGED
|
@@ -113,30 +113,37 @@ ${API_POST}`,
|
|
|
113
113
|
|
|
114
114
|
console.debug(`Start autogeneration Models`);
|
|
115
115
|
let models = ``;
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
if (this._swagger.components != null
|
|
117
|
+
&& this._swagger.components != undefined
|
|
118
|
+
&& this._swagger.components.schemas != null
|
|
119
|
+
&& this._swagger.components.schemas != undefined) {
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
121
|
+
for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
|
|
122
|
+
const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
};
|
|
124
|
+
if (modelName == 'ActivatedVoucherSnackListResponse') {
|
|
125
|
+
console.debug("ActivatedVoucherSnackListResponse");
|
|
126
|
+
}
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
if (usedTypes.indexOf(modelName) < 0) {
|
|
129
|
+
console.debug(`\tModel SKIP - ${modelName}`);
|
|
130
|
+
continue
|
|
131
|
+
};
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
const swaggerCopmponent = this._swagger.components.schemas[modelName];
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
|
|
135
|
+
console.debug(`\tModel - ${modelName}`);
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
let type = swaggerCopmponent.type == 'integer' ? 'enum' : 'class';
|
|
138
|
+
let content = this.retrieveObjectContent(modelName, swaggerCopmponent);
|
|
139
|
+
|
|
140
|
+
models +=
|
|
141
|
+
`
|
|
137
142
|
export ${type} ${modelName} {${content}
|
|
138
143
|
}
|
|
139
144
|
`;
|
|
145
|
+
}
|
|
146
|
+
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
usedMultiPart.forEach(apiName => {
|