@@ -181,7 +181,7 @@ function getRequestBodyDef(requestBody, schemaStyle, localize) {
181181 for ( const contentType in requestBody . content ) {
182182 const contentTypeObj = requestBody . content [ contentType ] ;
183183 const requestBodyDef = [
184- { text : `${ localize . requestBody } - ${ contentType } ` , margin : [ 0 , 10 , 0 , 10 ] , style : [ 'small' , 'b' ] } ,
184+ { text : `${ localize . requestBody } - ${ contentType } ` , margin : [ 0 , 10 , 0 , 0 ] , style : [ 'small' , 'b' ] } ,
185185 ] ;
186186
187187 if ( ( contentType . includes ( 'form' ) || contentType . includes ( 'multipart-form' ) ) && contentTypeObj . schema ) {
@@ -202,18 +202,27 @@ function getRequestBodyDef(requestBody, schemaStyle, localize) {
202202 }
203203 requestBodyDef . push ( treeDef ) ;
204204 } else {
205+ // if Schema Style is Tree
205206 let schemaTableTreeDef ;
206207 if ( schemaInObjectNotaion [ '::type' ] && schemaInObjectNotaion [ '::type' ] === 'array' ) {
207208 schemaTableTreeDef = objectToTableTree ( schemaInObjectNotaion [ '::prop' ] , localize , 'array' ) ;
208209 } else {
209210 schemaTableTreeDef = objectToTableTree ( schemaInObjectNotaion , localize ) ;
210211 }
211- if ( schemaTableTreeDef && schemaTableTreeDef . length > 0 ) {
212+ if ( schemaTableTreeDef && schemaTableTreeDef . length > 0 && Array . isArray ( schemaTableTreeDef [ 0 ] ) && schemaTableTreeDef [ 0 ] . length > 0 ) {
213+ schemaTableTreeDef . unshift ( [
214+ { text : localize . name , style : [ 'sub' , 'b' , 'alternate' ] } ,
215+ { text : localize . type , style : [ 'sub' , 'b' , 'alternate' ] } ,
216+ { text : localize . description , style : [ 'sub' , 'b' , 'alternate' ] } ,
217+ ] ) ;
218+
212219 requestBodyDef . push ( {
213220 table : {
221+ headerRows : 1 ,
214222 body : schemaTableTreeDef ,
215223 } ,
216- margin : [ 10 , 10 , 0 , 0 ] ,
224+ layout : rowLinesTableLayout ,
225+ margin : [ 0 , 3 , 0 , 0 ] ,
217226 } ) ;
218227 }
219228 }
@@ -245,19 +254,30 @@ function getResponseDef(responses, schemaStyle, localize) {
245254 } else {
246255 schemaTreeDef = objectToTree ( schemaInObjectNotaion , localize ) ;
247256 }
248- responseDef . push ( schemaTreeDef ) ;
257+ if ( Array . isArray ( schemaTreeDef ) && schemaTreeDef . length > 0 ) {
258+ schemaTreeDef [ 0 ] . margin = [ 10 , 5 , 0 , 0 ] ;
259+ responseDef . push ( schemaTreeDef ) ;
260+ }
249261 } else {
262+ // If Schema style is Tree
250263 let schemaTableTreeDef ;
251264 if ( schemaInObjectNotaion [ '::type' ] && schemaInObjectNotaion [ '::type' ] === 'array' ) {
252265 schemaTableTreeDef = objectToTableTree ( schemaInObjectNotaion [ '::prop' ] , localize , 'array' ) ;
253266 } else {
254267 schemaTableTreeDef = objectToTableTree ( schemaInObjectNotaion , localize ) ;
255268 }
256- if ( schemaTableTreeDef && schemaTableTreeDef . length > 0 ) {
269+ if ( schemaTableTreeDef && schemaTableTreeDef . length > 0 && Array . isArray ( schemaTableTreeDef [ 0 ] ) && schemaTableTreeDef [ 0 ] . length > 0 ) {
270+ schemaTableTreeDef . unshift ( [
271+ { text : localize . name , style : [ 'sub' , 'b' , 'alternate' ] } ,
272+ { text : localize . type , style : [ 'sub' , 'b' , 'alternate' ] } ,
273+ { text : localize . description , style : [ 'sub' , 'b' , 'alternate' ] } ,
274+ ] ) ;
257275 responseDef . push ( {
258276 table : {
277+ headerRows : 1 ,
259278 body : schemaTableTreeDef ,
260279 } ,
280+ layout : rowLinesTableLayout ,
261281 margin : [ 10 , 3 , 0 , 0 ] ,
262282 } ) ;
263283 }
0 commit comments