Conversation
There was a problem hiding this comment.
Pull request overview
Updates the generated Hey API client + schemas configuration for the icanhazdadjoke OpenAPI integration, aiming to improve robustness of JSON parsing and expand date/datetime handling in the Zod generator.
Changes:
- Switched generated Zod import style to a namespace import (
import * as z from "zod"). - Made Fetch client JSON parsing tolerant of 200 responses with an empty body (no
Content-Length). - Extended
openapi-tsZod plugin config to allow local/offset datetimes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/src/common/apis/icanhazdadjoke/schemas.ts | Updates Zod import style in generated schemas. |
| src/src/common/apis/icanhazdadjoke/client/clnt.ts | Adjusts JSON parsing for empty-body 200s; passes serializedBody into SSE client. |
| src/openapi-ts.config.mts | Adds dates configuration for Zod schema generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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) : {}; |
There was a problem hiding this comment.
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.
| data = text ? JSON.parse(text) : {}; | |
| const trimmed = text.trim(); | |
| data = trimmed ? JSON.parse(trimmed) : {}; |
No description provided.