@@ -5,17 +5,14 @@ const recursivelyFormatNestedObjects = (
5
5
schema : SingleReponseObj [ 'schema' ] ,
6
6
rows : FlattenedSchemaPropertyItem [ ] = [ ] ,
7
7
iteration = 0 ,
8
- previousPropertyPrefix = '' ,
9
- fromArray ?: boolean
10
- ) => {
8
+ previousPropertyPrefix = ''
9
+ ) : FlattenedSchemaPropertyItem [ ] => {
11
10
console . log ( 'iteration: ' , iteration )
12
11
console . table ( rows )
13
12
console . log ( 'schema' , schema )
14
13
const isInitialIteration = iteration === 0
15
14
const conditionalPropertyPrefix = isInitialIteration ? '' : '.'
16
15
if ( schema . type === 'array' ) {
17
- console . log ( 'schema.type detected as: ' + schema . type )
18
- // console.log('schema', schema)
19
16
const row : FlattenedSchemaPropertyItem = {
20
17
property : `${ previousPropertyPrefix } ${ conditionalPropertyPrefix } []` ,
21
18
type : schema . type ?? '' ,
@@ -27,27 +24,20 @@ const recursivelyFormatNestedObjects = (
27
24
rows . push ( row )
28
25
29
26
if ( schema . items . properties ) {
30
- console . log ( 'schema.items.properties detected as: ' + schema . items . type )
31
27
recursivelyFormatNestedObjects (
32
28
schema . items ,
33
29
rows ,
34
30
iteration + 1 ,
35
- row . property ,
36
- true
31
+ row . property
37
32
)
38
33
} else {
39
34
return rows
40
35
}
41
36
} else {
42
- console . log ( 'schema.type detected as non-array: ' + schema . type )
43
-
44
- // console.log('rows', rows)
45
- // console.log('--schema', schema)
46
37
if ( schema . properties ) {
47
38
for ( const [ propertyName , propertyMetadata ] of Object . entries (
48
39
schema . properties
49
40
) ) {
50
- console . log ( 'checking propertyName: ' + propertyName )
51
41
const arrayPrefix = propertyMetadata . type === 'array' ? '.[]' : ''
52
42
const row : FlattenedSchemaPropertyItem = {
53
43
property : `${ previousPropertyPrefix } ${ conditionalPropertyPrefix } ${ propertyName } ` ,
@@ -67,8 +57,7 @@ const recursivelyFormatNestedObjects = (
67
57
propertyMetadata . items ,
68
58
rows ,
69
59
iteration + 1 ,
70
- row . property + arrayPrefix ,
71
- true
60
+ row . property + arrayPrefix
72
61
)
73
62
}
74
63
}
0 commit comments