@@ -473,10 +473,73 @@ gulp.task('reference-saas', ['clean-dist', 'less', 'fetch-remote-openapi'], func
473
473
return parameter ;
474
474
} ) ;
475
475
476
- // Get example from request body schema or request body examples
476
+ // Process requestBody schema properties (same as body parameters)
477
477
if ( operation . requestBody && operation . requestBody . content ) {
478
478
for ( let content in operation . requestBody . content ) {
479
479
const contentObj = operation . requestBody . content [ content ] ;
480
+ // Process schema properties if schema exists
481
+ if ( contentObj . schema ) {
482
+ const readOnlyProperties = [ ] ;
483
+ // Process main properties
484
+ if ( contentObj . schema . properties ) {
485
+ _ . map ( contentObj . schema . properties , function ( property , propertyName ) {
486
+ property . default = ( property . default === 0 ) ? '0' :
487
+ ( property . default === null ) ? 'null' :
488
+ ( property . default === true ) ? 'true' :
489
+ ( property . default === false ) ? 'false' :
490
+ ( property . default && _ . isEmpty ( property . default ) ) ? '[]' : property . default ;
491
+ property [ 'x-immutable' ] = ( verb === 'patch' ) ? property [ 'x-immutable' ] : false ;
492
+ if ( verb === 'post' && property [ 'x-read-only' ] ) {
493
+ readOnlyProperties . push ( propertyName ) ;
494
+ }
495
+ } ) ;
496
+ _ . forEach ( contentObj . schema . required , function ( requiredProperty ) {
497
+ if ( contentObj . schema . properties && contentObj . schema . properties [ requiredProperty ] ) {
498
+ if ( verb !== 'patch' ) {
499
+ contentObj . schema . properties [ requiredProperty ] . required = true ;
500
+ } else {
501
+ contentObj . schema . properties [ requiredProperty ] . patchRequired = true ;
502
+ }
503
+ }
504
+ } ) ;
505
+ }
506
+ // Process items properties if schema.items exists
507
+ if ( contentObj . schema . items && contentObj . schema . items . properties ) {
508
+ _ . map ( contentObj . schema . items . properties , function ( property , propertyName ) {
509
+ property . default = ( property . default === 0 ) ? '0' :
510
+ ( property . default === null ) ? 'null' :
511
+ ( property . default === true ) ? 'true' :
512
+ ( property . default === false ) ? 'false' :
513
+ ( property . default && _ . isEmpty ( property . default ) ) ? '[]' : property . default ;
514
+ property [ 'x-immutable' ] = ( verb === 'patch' ) ? property [ 'x-immutable' ] : false ;
515
+ if ( verb === 'post' && property [ 'x-read-only' ] ) {
516
+ readOnlyProperties . push ( propertyName ) ;
517
+ }
518
+ } ) ;
519
+ _ . forEach ( contentObj . schema . items . required , function ( requiredProperty ) {
520
+ if ( contentObj . schema . items . properties && contentObj . schema . items . properties [ requiredProperty ] ) {
521
+ if ( verb !== 'patch' ) {
522
+ contentObj . schema . items . properties [ requiredProperty ] . required = true ;
523
+ } else {
524
+ contentObj . schema . items . properties [ requiredProperty ] . patchRequired = true ;
525
+ }
526
+ }
527
+ } ) ;
528
+ }
529
+ // Remove read-only properties from schema
530
+ if ( contentObj . schema . properties ) {
531
+ _ . forEach ( readOnlyProperties , function ( propToDelete ) {
532
+ delete contentObj . schema . properties [ propToDelete ] ;
533
+ } ) ;
534
+ }
535
+ // Remove read-only properties from example
536
+ if ( contentObj . schema && contentObj . schema . example ) {
537
+ _ . forEach ( readOnlyProperties , function ( propToDelete ) {
538
+ delete contentObj . schema . example [ propToDelete ] ;
539
+ } ) ;
540
+ }
541
+ }
542
+ // Get example from request body schema or request body examples
480
543
if ( contentObj . example ) {
481
544
operation . requestBody . hljsExample = formatJsonExample (
482
545
contentObj . example ,
0 commit comments