Skip to content

Commit 5a92f02

Browse files
committed
fix: solving maximun call size issue from swagger2 files
1 parent 523c7d0 commit 5a92f02

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/parser/swagger2/body.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
const _ = require('lodash');
66

77
module.exports = function() {
8+
9+
let seenSchemas = new WeakSet();
10+
811

912
return function get(verb, path, bodyResponse) {
1013
if (!_.isObject(global.definition.paths)) {
@@ -38,6 +41,18 @@ module.exports = function() {
3841
};
3942

4043
function replaceRefs(schema){
44+
45+
if (!_.isObject(schema)) return schema;
46+
47+
// Detectar ciclos por identidad
48+
if (seenSchemas.has(schema)) {
49+
return {
50+
type: "string",
51+
description: "Circular schema avoided"
52+
};
53+
}
54+
seenSchemas.add(schema);
55+
4156
let result = {};
4257
for (let i in schema) {
4358
if (i === '$ref'){

src/parser/swagger2/pathParameters.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const _ = require('lodash');
66

77
module.exports = function() {
8+
let seenSchemas = new WeakSet();
89

910
return function get(verb,path){
1011
if (!_.isObject(global.definition.paths)) {
@@ -23,6 +24,17 @@ module.exports = function() {
2324
}
2425

2526
function replaceRefs(schema){
27+
if (!_.isObject(schema)) return schema;
28+
29+
// Detectar ciclos por identidad
30+
if (seenSchemas.has(schema)) {
31+
return {
32+
type: "string",
33+
description: "Circular schema avoided"
34+
};
35+
}
36+
seenSchemas.add(schema);
37+
2638
let result = {};
2739
for (let i in schema) {
2840
if (i === '$ref'){

0 commit comments

Comments
 (0)