@@ -53,6 +53,27 @@ export function pathIsInSearch(searchVal, path) {
53
53
return stringToSearch . includes ( searchVal ) ;
54
54
}
55
55
56
+ export function joinObjectKeys ( obj , resultStr = '' ) {
57
+ if ( ! obj . properties ) {
58
+ return '' ;
59
+ }
60
+
61
+ // We should use a separated string variable in order to exclude next error 'Uncaught RangeError: Invalid string length'
62
+ let recursiveresultStr = '' ;
63
+ resultStr = `${ resultStr } ${ Object . keys ( obj . properties || '' ) . join ( ' ' ) } ` ;
64
+
65
+ Object . keys ( obj . properties ) . forEach ( ( propertyName ) => {
66
+ if ( obj . properties [ propertyName ] . properties ) {
67
+ recursiveresultStr = `${ recursiveresultStr } ${ joinObjectKeys ( obj . properties [ propertyName ] , resultStr ) } ` ;
68
+ }
69
+ if ( obj . properties [ propertyName ] . type === 'array' ) {
70
+ recursiveresultStr = `${ recursiveresultStr } ${ joinObjectKeys ( obj . properties [ propertyName ] . items , resultStr ) } ` ;
71
+ }
72
+ } ) ;
73
+
74
+ return `${ resultStr } ${ recursiveresultStr } ` ;
75
+ }
76
+
56
77
export function advanceSearch ( searchVal , allSpecTags , searchOptions = [ ] ) {
57
78
if ( ! searchVal . trim ( ) || searchOptions . length === 0 ) {
58
79
return ;
@@ -74,7 +95,7 @@ export function advanceSearch(searchVal, allSpecTags, searchOptions = []) {
74
95
75
96
if ( searchOptions . includes ( 'search-api-request-body' ) && path . requestBody ) {
76
97
for ( const contentType in path . requestBody . content ) {
77
- stringToSearch = `${ stringToSearch } ${ Object . keys ( path . requestBody . content [ contentType ] . schema ?. properties || '' ) . join ( ' ' ) } ` ;
98
+ stringToSearch = `${ stringToSearch } ${ joinObjectKeys ( path . requestBody . content [ contentType ] . schema , stringToSearch ) } ` ;
78
99
}
79
100
}
80
101
0 commit comments