@@ -19,9 +19,10 @@ export const ResponseSampleBody = props => {
19
19
. filter ( v => properties [ v ] !== null )
20
20
. map ( p => {
21
21
const l = properties [ p ] ;
22
+ // console.log(l);
22
23
return (
23
24
l &&
24
- ( l . type !== "array" && l . type !== "object " && p !== "errors "
25
+ ( l . type !== "array" && p !== "errors " && l . type !== "object "
25
26
? `"${ p } ": ${
26
27
p === "id"
27
28
? "1234"
@@ -33,13 +34,37 @@ export const ResponseSampleBody = props => {
33
34
} `
34
35
: `${ JSON . stringify ( l . example ? l . example : "" ) } `
35
36
} `
36
- : `"${ p } " : [` ) +
37
+ : l . type === "object" && ! l . properties
38
+ ? `"${ p } " : {`
39
+ : l . type === "array"
40
+ ? `"${ p } " : [`
41
+ : `"${ p } " :` ) +
37
42
( l . example && l . type === "array" && ! l . items
38
43
? Object . keys ( l . example ) . map ( v => {
39
44
const va = l . example [ v ] ;
40
45
return `"${ va } "` ;
41
46
} )
42
47
: "" ) +
48
+ ( l . oneOf &&
49
+ Object . keys ( l . oneOf [ 0 ] . properties ) . map ( oop => {
50
+ const data = l . oneOf [ 0 ] . properties [ oop ] ;
51
+ return `
52
+ "${ oop } ": ${
53
+ data . example
54
+ ? JSON . stringify ( data . example )
55
+ : data . type === "array" && data . items . type === "object"
56
+ ? "[{" +
57
+ Object . keys ( data . items . properties ) . map ( di => {
58
+ const dis = data . items . properties [ di ] ;
59
+ return `
60
+ "${ di } ": ${ JSON . stringify (
61
+ dis . example ? dis . example : ""
62
+ ) } `;
63
+ } ) +
64
+ "}]"
65
+ : '""'
66
+ } `;
67
+ } ) ) +
43
68
( l . properties &&
44
69
`{` +
45
70
Object . keys ( l . properties )
@@ -169,8 +194,10 @@ export const ResponseSampleBody = props => {
169
194
l . items . allOf [ 1 ] . properties
170
195
)
171
196
: "" ) +
172
- ( l . type === "array" || l . type === "object" || p === "errors"
197
+ ( l . type === "array" || p === "errors"
173
198
? `]`
199
+ : l . type === "object" && ! l . properties
200
+ ? `}`
174
201
: "" )
175
202
) ;
176
203
} ) }
0 commit comments