@@ -287,6 +287,7 @@ export class SchemaPreprocessor {
287287 // This null check should no longer be necessary
288288 this . handleSerDes ( pschema , nschema , options ) ;
289289 this . handleReadonly ( pschema , nschema , options ) ;
290+ this . handleWriteonly ( pschema , nschema , options ) ;
290291 this . processDiscriminator ( pschema , nschema , options ) ;
291292 this . removeExamples ( pschema , nschema , options )
292293 }
@@ -479,6 +480,27 @@ export class SchemaPreprocessor {
479480 }
480481 }
481482
483+ private handleWriteonly (
484+ parent : OpenAPIV3 . SchemaObject ,
485+ schema : OpenAPIV3 . SchemaObject ,
486+ opts ,
487+ ) {
488+ if ( opts . kind === 'req' ) return ;
489+
490+ const required = parent ?. required ?? [ ] ;
491+ const prop = opts ?. path ?. [ opts ?. path ?. length - 1 ] ;
492+ const index = required . indexOf ( prop ) ;
493+ if ( schema . writeOnly && index > - 1 ) {
494+ // remove required if writeOnly
495+ parent . required = required
496+ . slice ( 0 , index )
497+ . concat ( required . slice ( index + 1 ) ) ;
498+ if ( parent . required . length === 0 ) {
499+ delete parent . required ;
500+ }
501+ }
502+ }
503+
482504 /**
483505 * extract all requestBodies' schemas from an operation
484506 * @param op
0 commit comments