yapi-apifox-to-typescript 4.2.2 → 4.2.3
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.
|
@@ -187,14 +187,26 @@ var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
187
187
|
};
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
_proto.normalizeSchema = function normalizeSchema(schema) {
|
|
190
|
+
_proto.normalizeSchema = function normalizeSchema(schema, visited) {
|
|
191
|
+
if (visited === void 0) {
|
|
192
|
+
visited = new Set();
|
|
193
|
+
}
|
|
194
|
+
|
|
191
195
|
var result = (0, _extends2.default)({}, schema);
|
|
192
196
|
|
|
193
197
|
if (schema.$ref) {
|
|
198
|
+
if (visited.has(schema.$ref)) {
|
|
199
|
+
// 循环引用,直接返回空对象避免无限递归
|
|
200
|
+
return {
|
|
201
|
+
type: 'object'
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
visited.add(schema.$ref);
|
|
194
206
|
var resolved = this.resolveRef(schema.$ref);
|
|
195
207
|
|
|
196
208
|
if (resolved) {
|
|
197
|
-
return this.normalizeSchema(resolved);
|
|
209
|
+
return this.normalizeSchema(resolved, new Set(visited));
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
|
|
@@ -207,13 +219,13 @@ var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
207
219
|
_value = _Object$entries2$_i[1];
|
|
208
220
|
|
|
209
221
|
if (_value) {
|
|
210
|
-
result.properties[key] = this.normalizeSchema(_value);
|
|
222
|
+
result.properties[key] = this.normalizeSchema(_value, new Set(visited));
|
|
211
223
|
}
|
|
212
224
|
}
|
|
213
225
|
}
|
|
214
226
|
|
|
215
227
|
if (schema.items) {
|
|
216
|
-
result.items = this.normalizeSchema(schema.items);
|
|
228
|
+
result.items = this.normalizeSchema(schema.items, new Set(visited));
|
|
217
229
|
}
|
|
218
230
|
|
|
219
231
|
delete result.$ref;
|
|
@@ -173,14 +173,26 @@ export var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
173
173
|
};
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
_proto.normalizeSchema = function normalizeSchema(schema) {
|
|
176
|
+
_proto.normalizeSchema = function normalizeSchema(schema, visited) {
|
|
177
|
+
if (visited === void 0) {
|
|
178
|
+
visited = new Set();
|
|
179
|
+
}
|
|
180
|
+
|
|
177
181
|
var result = _extends({}, schema);
|
|
178
182
|
|
|
179
183
|
if (schema.$ref) {
|
|
184
|
+
if (visited.has(schema.$ref)) {
|
|
185
|
+
// 循环引用,直接返回空对象避免无限递归
|
|
186
|
+
return {
|
|
187
|
+
type: 'object'
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
visited.add(schema.$ref);
|
|
180
192
|
var resolved = this.resolveRef(schema.$ref);
|
|
181
193
|
|
|
182
194
|
if (resolved) {
|
|
183
|
-
return this.normalizeSchema(resolved);
|
|
195
|
+
return this.normalizeSchema(resolved, new Set(visited));
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
198
|
|
|
@@ -193,13 +205,13 @@ export var ApifoxToYApiData = /*#__PURE__*/function () {
|
|
|
193
205
|
_value = _Object$entries2$_i[1];
|
|
194
206
|
|
|
195
207
|
if (_value) {
|
|
196
|
-
result.properties[key] = this.normalizeSchema(_value);
|
|
208
|
+
result.properties[key] = this.normalizeSchema(_value, new Set(visited));
|
|
197
209
|
}
|
|
198
210
|
}
|
|
199
211
|
}
|
|
200
212
|
|
|
201
213
|
if (schema.items) {
|
|
202
|
-
result.items = this.normalizeSchema(schema.items);
|
|
214
|
+
result.items = this.normalizeSchema(schema.items, new Set(visited));
|
|
203
215
|
}
|
|
204
216
|
|
|
205
217
|
delete result.$ref;
|