@midwayjs/swagger 3.12.4 → 3.12.7
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/swaggerExplorer.js +14 -10
- package/package.json +4 -4
package/dist/swaggerExplorer.js
CHANGED
|
@@ -611,19 +611,26 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
611
611
|
* @param clzz
|
|
612
612
|
*/
|
|
613
613
|
parseClzz(clzz) {
|
|
614
|
+
var _a, _b, _c;
|
|
614
615
|
if (this.documentBuilder.getSchema(clzz.name)) {
|
|
615
616
|
return this.documentBuilder.getSchema(clzz.name);
|
|
616
617
|
}
|
|
618
|
+
// 解析 ApiExtraModel
|
|
617
619
|
this.parseExtraModel(clzz);
|
|
620
|
+
// 解析类上的 ApiProperty
|
|
618
621
|
const props = (0, core_1.getClassExtendedMetadata)(core_1.INJECT_CUSTOM_PROPERTY, clzz);
|
|
619
622
|
const tt = {
|
|
620
623
|
type: 'object',
|
|
621
624
|
properties: {},
|
|
622
625
|
};
|
|
626
|
+
// 先添加到 schema,防止递归循环
|
|
627
|
+
this.documentBuilder.addSchema({
|
|
628
|
+
[clzz.name]: tt,
|
|
629
|
+
});
|
|
623
630
|
if (props) {
|
|
624
|
-
Object.keys(props)
|
|
625
|
-
|
|
626
|
-
|
|
631
|
+
for (const key of Object.keys(props)) {
|
|
632
|
+
const metadata = {};
|
|
633
|
+
Object.assign(metadata, props[key].metadata);
|
|
627
634
|
if (typeof (metadata === null || metadata === void 0 ? void 0 : metadata.required) !== undefined) {
|
|
628
635
|
if (metadata === null || metadata === void 0 ? void 0 : metadata.required) {
|
|
629
636
|
if (!tt.required) {
|
|
@@ -642,7 +649,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
642
649
|
if (metadata === null || metadata === void 0 ? void 0 : metadata.description) {
|
|
643
650
|
tt.properties[key].description = metadata === null || metadata === void 0 ? void 0 : metadata.description;
|
|
644
651
|
}
|
|
645
|
-
|
|
652
|
+
continue;
|
|
646
653
|
}
|
|
647
654
|
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.items) === null || _a === void 0 ? void 0 : _a.enum) {
|
|
648
655
|
tt.properties[key] = {
|
|
@@ -653,7 +660,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
653
660
|
if (metadata === null || metadata === void 0 ? void 0 : metadata.description) {
|
|
654
661
|
tt.properties[key].description = metadata === null || metadata === void 0 ? void 0 : metadata.description;
|
|
655
662
|
}
|
|
656
|
-
|
|
663
|
+
continue;
|
|
657
664
|
}
|
|
658
665
|
let isArray = false;
|
|
659
666
|
let currentType = parseTypeSchema(metadata === null || metadata === void 0 ? void 0 : metadata.type);
|
|
@@ -671,7 +678,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
671
678
|
tt.properties[key].oneOf.push(this.parseSubPropertyType(meta));
|
|
672
679
|
});
|
|
673
680
|
metadata === null || metadata === void 0 ? true : delete metadata.oneOf;
|
|
674
|
-
|
|
681
|
+
continue;
|
|
675
682
|
}
|
|
676
683
|
if (core_1.Types.isClass(currentType)) {
|
|
677
684
|
this.parseClzz(currentType);
|
|
@@ -728,11 +735,8 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
728
735
|
}
|
|
729
736
|
}
|
|
730
737
|
Object.assign(tt.properties[key], metadata);
|
|
731
|
-
}
|
|
738
|
+
}
|
|
732
739
|
}
|
|
733
|
-
this.documentBuilder.addSchema({
|
|
734
|
-
[clzz.name]: tt,
|
|
735
|
-
});
|
|
736
740
|
// just for test
|
|
737
741
|
return tt;
|
|
738
742
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/swagger",
|
|
3
|
-
"version": "3.12.
|
|
4
|
-
"main": "dist/index",
|
|
3
|
+
"version": "3.12.7",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@midwayjs/core": "^3.12.3",
|
|
13
13
|
"@midwayjs/koa": "^3.12.3",
|
|
14
14
|
"@midwayjs/mock": "^3.12.3",
|
|
15
|
-
"@midwayjs/validate": "^3.12.
|
|
15
|
+
"@midwayjs/validate": "^3.12.7",
|
|
16
16
|
"swagger-ui-dist": "4.19.1"
|
|
17
17
|
},
|
|
18
18
|
"author": "Kurten Chan <chinkurten@gmail.com>",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"type": "git",
|
|
28
28
|
"url": "https://github.com/midwayjs/midway.git"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "b6dd29791ad4118f53806023b73eb629e948d415"
|
|
31
31
|
}
|