Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/openapi-ts.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
12 changes: 11 additions & 1 deletion src/src/common/apis/icanhazdadjoke/client/clnt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) : {};
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.text() can return whitespace-only bodies (e.g., "\n"); text ? JSON.parse(text) : {} will treat that as non-empty and throw on JSON.parse. Consider trimming before the emptiness check (e.g., const trimmed = text.trim()), so whitespace-only responses are handled the same as empty bodies.

Suggested change
data = text ? JSON.parse(text) : {};
const trimmed = text.trim();
data = trimmed ? JSON.parse(trimmed) : {};

Copilot uses AI. Check for mistakes.
break;
}
case "stream":
return opts.responseStyle === "data"
? response.body
Expand Down Expand Up @@ -267,6 +273,10 @@ export const createClient = (config: Config = {}): Client => {
}
return request;
},
serializedBody: getValidRequestBody(opts) as
| BodyInit
| null
| undefined,
Comment thread
spietras marked this conversation as resolved.
url,
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/src/common/apis/icanhazdadjoke/schemas.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading