File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,31 +3,35 @@ import type { OpenAPIV3_1 } from 'openapi-types';
33import { MediaType , type MediaTypeOptions } from './media-type.js' ;
44
55export interface RequestBodyOptions {
6- content : MediaType | MediaTypeOptions ;
6+ content ? : MediaType | MediaTypeOptions ;
77 description ?: string ;
88 required ?: boolean ;
99}
1010
1111export class RequestBody extends Construct {
1212 private options : RequestBodyOptions ;
1313
14- private content : MediaType ;
14+ private content : MediaType | undefined ;
1515
1616 constructor ( scope : Construct , id : string , options : RequestBodyOptions ) {
1717 super ( scope , id ) ;
1818 this . options = options ;
1919
20- this . content =
21- options . content instanceof MediaType
22- ? options . content
23- : new MediaType ( this , id , options . content ) ;
20+ if ( options . content ) {
21+ this . content =
22+ options . content instanceof MediaType
23+ ? options . content
24+ : new MediaType ( this , id , options . content ) ;
25+ }
2426 }
2527
2628 public synth ( ) : OpenAPIV3_1 . RequestBodyObject {
2729 return {
2830 description : this . options . description || '' ,
2931 content : {
30- [ this . options . content . contentType ] : this . content . synth ( ) ,
32+ ...( this . content && {
33+ [ this . content . contentType ] : this . content . synth ( ) ,
34+ } ) ,
3135 } ,
3236 ...( this . options . required && { required : this . options . required } ) ,
3337 } ;
You can’t perform that action at this time.
0 commit comments