openapi-ts-request 0.8.4 → 0.9.0
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.
|
@@ -671,14 +671,12 @@ class ServiceGenerator {
|
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
673
|
resolveRefObject(refObject) {
|
|
674
|
-
var _a, _b;
|
|
675
674
|
if (!(0, util_1.isReferenceObject)(refObject)) {
|
|
676
675
|
return refObject;
|
|
677
676
|
}
|
|
678
|
-
// 测试了很多用例,很少有用例走到这里
|
|
679
677
|
const refPaths = refObject.$ref.split('/');
|
|
680
678
|
if (refPaths[0] === '#') {
|
|
681
|
-
const schema = (
|
|
679
|
+
const schema = (0, util_1.resolveRefs)(this.openAPIData, refPaths.slice(1));
|
|
682
680
|
if (!schema) {
|
|
683
681
|
throw new Error(`[GenSDK] Data Error! Notfoud: ${refObject.$ref}`);
|
|
684
682
|
}
|
package/dist/generator/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArraySchemaObject, BinaryArraySchemaObject, ComponentsObject, ISchemaObject, NonArraySchemaObject, OperationObject, ReferenceObject, SchemaObject } from '../type';
|
|
1
|
+
import { ArraySchemaObject, BinaryArraySchemaObject, ComponentsObject, ISchemaObject, NonArraySchemaObject, OpenAPIObject, OperationObject, ReferenceObject, SchemaObject } from '../type';
|
|
2
2
|
import { ITypeItem } from './type';
|
|
3
3
|
export declare function stripDot(str: string): string;
|
|
4
4
|
export declare function resolveTypeName(typeName: string): string;
|
|
@@ -17,3 +17,4 @@ export declare function isSchemaObject(schema: unknown): schema is SchemaObject;
|
|
|
17
17
|
export declare function isNonArraySchemaObject(schema: unknown): schema is NonArraySchemaObject;
|
|
18
18
|
export declare function isArraySchemaObject(schema: unknown): schema is ArraySchemaObject;
|
|
19
19
|
export declare function isBinaryArraySchemaObject(schema: unknown): schema is BinaryArraySchemaObject;
|
|
20
|
+
export declare function resolveRefs(obj: OpenAPIObject, fields: string[]): unknown;
|
package/dist/generator/util.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.isSchemaObject = isSchemaObject;
|
|
|
17
17
|
exports.isNonArraySchemaObject = isNonArraySchemaObject;
|
|
18
18
|
exports.isArraySchemaObject = isArraySchemaObject;
|
|
19
19
|
exports.isBinaryArraySchemaObject = isBinaryArraySchemaObject;
|
|
20
|
+
exports.resolveRefs = resolveRefs;
|
|
20
21
|
const tslib_1 = require("tslib");
|
|
21
22
|
const lodash_1 = require("lodash");
|
|
22
23
|
const reserved_words_1 = tslib_1.__importDefault(require("reserved-words"));
|
|
@@ -315,3 +316,13 @@ function isBinaryArraySchemaObject(schema) {
|
|
|
315
316
|
(((_a = schema.items) === null || _a === void 0 ? void 0 : _a.format) === 'binary' ||
|
|
316
317
|
((_b = schema.items) === null || _b === void 0 ? void 0 : _b.format) === 'base64'));
|
|
317
318
|
}
|
|
319
|
+
function resolveRefs(obj, fields) {
|
|
320
|
+
return fields.reduce((acc, field) => {
|
|
321
|
+
if (!acc)
|
|
322
|
+
return;
|
|
323
|
+
const s = acc[decodeURIComponent(field)];
|
|
324
|
+
if (!s)
|
|
325
|
+
return;
|
|
326
|
+
return s;
|
|
327
|
+
}, obj);
|
|
328
|
+
}
|
package/package.json
CHANGED