File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 55const _ = require ( 'lodash' ) ;
66
77module . 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' ) {
Original file line number Diff line number Diff line change 55const _ = require ( 'lodash' ) ;
66
77module . 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' ) {
You can’t perform that action at this time.
0 commit comments