@midwayjs/swagger 3.9.3 → 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;
@@ -505,7 +505,7 @@ let SwaggerExplorer = class SwaggerExplorer {
505
505
  */
506
506
  parseClzz(clzz) {
507
507
  if (this.documentBuilder.getSchema(clzz.name)) {
508
- return;
508
+ return this.documentBuilder.getSchema(clzz.name);
509
509
  }
510
510
  this.parseExtraModel(clzz);
511
511
  const props = (0, core_1.getClassExtendedMetadata)(core_1.INJECT_CUSTOM_PROPERTY, clzz);
@@ -515,7 +515,7 @@ let SwaggerExplorer = class SwaggerExplorer {
515
515
  };
516
516
  if (props) {
517
517
  Object.keys(props).forEach(key => {
518
- var _a, _b;
518
+ var _a, _b, _c;
519
519
  const metadata = props[key].metadata;
520
520
  if (typeof (metadata === null || metadata === void 0 ? void 0 : metadata.required) !== undefined) {
521
521
  if (metadata === null || metadata === void 0 ? void 0 : metadata.required) {
@@ -549,7 +549,7 @@ let SwaggerExplorer = class SwaggerExplorer {
549
549
  return;
550
550
  }
551
551
  let isArray = false;
552
- let currentType = metadata === null || metadata === void 0 ? void 0 : metadata.type;
552
+ let currentType = parseTypeSchema(metadata === null || metadata === void 0 ? void 0 : metadata.type);
553
553
  metadata === null || metadata === void 0 ? true : delete metadata.type;
554
554
  if (currentType === 'array') {
555
555
  isArray = true;
@@ -577,6 +577,9 @@ let SwaggerExplorer = class SwaggerExplorer {
577
577
  if (isArray) {
578
578
  // 没有配置类型则认为自己配置了 items 内容
579
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
+ }
580
583
  tt.properties[key] = {
581
584
  type: 'array',
582
585
  items: metadata === null || metadata === void 0 ? void 0 : metadata.items,
@@ -752,4 +755,10 @@ function getNotEmptyValue(...args) {
752
755
  }
753
756
  }
754
757
  }
758
+ function parseTypeSchema(ref) {
759
+ if (typeof ref === 'function' && !core_1.Types.isClass(ref)) {
760
+ ref = ref();
761
+ }
762
+ return ref;
763
+ }
755
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",
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": "3cd5d856789433bcfab6bcdce87743035176c878"
30
+ "gitHead": "19ca43f7cefa3698bec2c7c2d04c4dd8bfdff781"
31
31
  }