@midwayjs/swagger 3.9.0 → 3.9.8
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.
|
@@ -159,7 +159,7 @@ export interface TagObject {
|
|
|
159
159
|
}
|
|
160
160
|
export declare type ExamplesObject = Record<string, ExampleObject | ReferenceObject>;
|
|
161
161
|
export interface ReferenceObject {
|
|
162
|
-
$ref: string;
|
|
162
|
+
$ref: string | (() => string);
|
|
163
163
|
}
|
|
164
164
|
export interface SchemaObject {
|
|
165
165
|
nullable?: boolean;
|
package/dist/swaggerExplorer.js
CHANGED
|
@@ -216,9 +216,25 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
216
216
|
}
|
|
217
217
|
if (core_1.Types.isClass(currentType)) {
|
|
218
218
|
this.parseClzz(currentType);
|
|
219
|
-
p.
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
if (p.in === 'query') {
|
|
220
|
+
// 如果@Query()装饰的 是一个对象,则把该对象的子属性作为多个@Query参数
|
|
221
|
+
const schema = this.documentBuilder.getSchema(currentType.name);
|
|
222
|
+
Object.keys(schema.properties).forEach(pName => {
|
|
223
|
+
const ppt = schema.properties[pName];
|
|
224
|
+
const pp = {
|
|
225
|
+
name: pName,
|
|
226
|
+
in: p.in,
|
|
227
|
+
};
|
|
228
|
+
this.parseFromParamsToP({ metadata: ppt }, pp);
|
|
229
|
+
parameters.push(pp);
|
|
230
|
+
});
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
p.schema = {
|
|
235
|
+
$ref: '#/components/schemas/' + currentType.name,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
222
238
|
}
|
|
223
239
|
else {
|
|
224
240
|
p.schema = {
|
|
@@ -489,7 +505,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
489
505
|
*/
|
|
490
506
|
parseClzz(clzz) {
|
|
491
507
|
if (this.documentBuilder.getSchema(clzz.name)) {
|
|
492
|
-
return;
|
|
508
|
+
return this.documentBuilder.getSchema(clzz.name);
|
|
493
509
|
}
|
|
494
510
|
this.parseExtraModel(clzz);
|
|
495
511
|
const props = (0, core_1.getClassExtendedMetadata)(core_1.INJECT_CUSTOM_PROPERTY, clzz);
|
|
@@ -499,7 +515,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
499
515
|
};
|
|
500
516
|
if (props) {
|
|
501
517
|
Object.keys(props).forEach(key => {
|
|
502
|
-
var _a, _b;
|
|
518
|
+
var _a, _b, _c;
|
|
503
519
|
const metadata = props[key].metadata;
|
|
504
520
|
if (typeof (metadata === null || metadata === void 0 ? void 0 : metadata.required) !== undefined) {
|
|
505
521
|
if (metadata === null || metadata === void 0 ? void 0 : metadata.required) {
|
|
@@ -533,7 +549,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
533
549
|
return;
|
|
534
550
|
}
|
|
535
551
|
let isArray = false;
|
|
536
|
-
let currentType = metadata === null || metadata === void 0 ? void 0 : metadata.type;
|
|
552
|
+
let currentType = parseTypeSchema(metadata === null || metadata === void 0 ? void 0 : metadata.type);
|
|
537
553
|
metadata === null || metadata === void 0 ? true : delete metadata.type;
|
|
538
554
|
if (currentType === 'array') {
|
|
539
555
|
isArray = true;
|
|
@@ -561,6 +577,9 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
561
577
|
if (isArray) {
|
|
562
578
|
// 没有配置类型则认为自己配置了 items 内容
|
|
563
579
|
if (!currentType) {
|
|
580
|
+
if ((_c = metadata === null || metadata === void 0 ? void 0 : metadata.items) === null || _c === void 0 ? void 0 : _c['$ref']) {
|
|
581
|
+
metadata.items['$ref'] = parseTypeSchema(metadata.items['$ref']);
|
|
582
|
+
}
|
|
564
583
|
tt.properties[key] = {
|
|
565
584
|
type: 'array',
|
|
566
585
|
items: metadata === null || metadata === void 0 ? void 0 : metadata.items,
|
|
@@ -736,4 +755,10 @@ function getNotEmptyValue(...args) {
|
|
|
736
755
|
}
|
|
737
756
|
}
|
|
738
757
|
}
|
|
758
|
+
function parseTypeSchema(ref) {
|
|
759
|
+
if (typeof ref === 'function' && !core_1.Types.isClass(ref)) {
|
|
760
|
+
ref = ref();
|
|
761
|
+
}
|
|
762
|
+
return ref;
|
|
763
|
+
}
|
|
739
764
|
//# sourceMappingURL=swaggerExplorer.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/swagger",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.8",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"type": "git",
|
|
28
28
|
"url": "https://github.com/midwayjs/midway.git"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "19ca43f7cefa3698bec2c7c2d04c4dd8bfdff781"
|
|
31
31
|
}
|