Skip to content

Commit 6b17fbb

Browse files
committed
feat: allow plain text as request body
1 parent 7ddc040 commit 6b17fbb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/openapi-typescript/fetch-factory.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ function buildInit(
6464
): RequestInit {
6565
return {
6666
...Object.assign({}, { ...defaultInit }, { ...options }),
67-
body: options.body ? JSON.stringify(options.body) : undefined,
67+
body:
68+
options.body && typeof options.body == "object"
69+
? JSON.stringify(options.body)
70+
: options.body,
6871
method: options.method?.toUpperCase(),
6972
headers,
7073
};

src/openapi-typescript/types/fetch-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type FetchOptions<Operation> = Omit<
2323
*/
2424
export type AllFetchOptions<Operation = never> = Omit<RequestInit, "body"> & {
2525
parameters: FetchParameters<Operation>;
26-
body: OperationRequestBody<Operation>;
26+
body: OperationRequestBody<Operation> | string;
2727
};
2828

2929
/**

0 commit comments

Comments
 (0)