Skip to content

Commit c69acf7

Browse files
committed
fix: revert support for empty/undefined request body
1 parent fceb159 commit c69acf7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lib/request-body.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,31 @@ import type { OpenAPIV3_1 } from 'openapi-types';
33
import { MediaType, type MediaTypeOptions } from './media-type.js';
44

55
export interface RequestBodyOptions {
6-
content?: MediaType | MediaTypeOptions;
6+
content: MediaType | MediaTypeOptions;
77
description?: string;
88
required?: boolean;
99
}
1010

1111
export class RequestBody extends Construct {
1212
private options: RequestBodyOptions;
1313

14-
private content: MediaType | undefined;
14+
private content: MediaType;
1515

1616
constructor(scope: Construct, id: string, options: RequestBodyOptions) {
1717
super(scope, id);
1818
this.options = options;
1919

20-
if (options.content) {
21-
this.content =
22-
options.content instanceof MediaType
23-
? options.content
24-
: new MediaType(this, id, options.content);
25-
}
20+
this.content =
21+
options.content instanceof MediaType
22+
? options.content
23+
: new MediaType(this, id, options.content);
2624
}
2725

2826
public synth(): OpenAPIV3_1.RequestBodyObject {
2927
return {
3028
description: this.options.description || '',
3129
content: {
32-
...(this.content && {
33-
[this.content.contentType]: this.content.synth(),
34-
}),
30+
[this.options.content.contentType]: this.content.synth(),
3531
},
3632
...(this.options.required && { required: this.options.required }),
3733
};

0 commit comments

Comments
 (0)