Skip to content

Commit c4e8bf3

Browse files
chore(internal): codegen related update
1 parent e1bd0c2 commit c4e8bf3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/client.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,12 +1132,20 @@ export class OpenAI {
11321132
return () => controller.abort();
11331133
}
11341134

1135-
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
1135+
private buildBody({ options }: { options: FinalRequestOptions }): {
11361136
bodyHeaders: HeadersLike;
11371137
body: BodyInit | undefined;
11381138
isStreamingBody: boolean;
11391139
} {
1140+
const { body, headers: rawHeaders } = options;
11401141
if (!body) {
1142+
// A resource method always passes a `body` key when its operation defines a
1143+
// request body, even if the caller omitted an optional body param. Keep the
1144+
// content-type for those, and only elide it for operations with no body at
1145+
// all (e.g. GET/DELETE).
1146+
if (body == null && 'body' in options) {
1147+
return this.#encoder({ body, headers: buildHeaders([rawHeaders]) });
1148+
}
11411149
return { bodyHeaders: undefined, body: undefined, isStreamingBody: false };
11421150
}
11431151
const headers = buildHeaders([rawHeaders]);

0 commit comments

Comments
 (0)