diff --git a/src/openapi-ts.config.mts b/src/openapi-ts.config.mts index 6958847..839fcfd 100644 --- a/src/openapi-ts.config.mts +++ b/src/openapi-ts.config.mts @@ -77,6 +77,14 @@ export default defineConfig( // Use PascalCase for schema names case: "PascalCase", + dates: { + // Allow datetimes without timezone + local: true, + + // Allow datetimes with offset timezone + offset: true, + }, + definitions: { name: "{{name}}Schema", }, diff --git a/src/src/common/apis/icanhazdadjoke/client/clnt.ts b/src/src/common/apis/icanhazdadjoke/client/clnt.ts index 664cbc4..f06e785 100644 --- a/src/src/common/apis/icanhazdadjoke/client/clnt.ts +++ b/src/src/common/apis/icanhazdadjoke/client/clnt.ts @@ -182,10 +182,16 @@ export const createClient = (config: Config = {}): Client => { case "arrayBuffer": case "blob": case "formData": - case "json": case "text": data = await response[parseAs](); break; + case "json": { + // Some servers return 200 with no Content-Length and empty body. + // response.json() would throw; read as text and parse if non-empty. + const text = await response.text(); + data = text ? JSON.parse(text) : {}; + break; + } case "stream": return opts.responseStyle === "data" ? response.body @@ -267,6 +273,10 @@ export const createClient = (config: Config = {}): Client => { } return request; }, + serializedBody: getValidRequestBody(opts) as + | BodyInit + | null + | undefined, url, }); }; diff --git a/src/src/common/apis/icanhazdadjoke/schemas.ts b/src/src/common/apis/icanhazdadjoke/schemas.ts index 58458d3..186a99c 100644 --- a/src/src/common/apis/icanhazdadjoke/schemas.ts +++ b/src/src/common/apis/icanhazdadjoke/schemas.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import { z } from "zod"; +import * as z from "zod"; /** * Success response payload for getting a random joke