openapi-ts
openapi-ts copied to clipboard
Customizing Generated Date Types to Use Temporal.Instant
Context:
I’m using @hey-api/openapi-ts to generate TypeScript types/schemas from a FastAPI backend’s OpenAPI spec. My frontend (React) uses Temporal.Instant (via @js-temporal/polyfill) for datetime handling, but the generated types default to Date, causing type mismatches.
Problem Example:
// Generated type (simplified)
interface Event {
startTime: Date; // ❌ Needs to be Temporal.Instant
}
// Usage
const event: Event = {
startTime: Temporal.Instant.from("2024-01-01T00:00:00Z"), // ❌ Type error
};
Questions:
- Is there a built-in way to configure @hey-api/openapi-ts to use Temporal types instead of Date?
- If not, would a feature request for Temporal support be feasible?
- Are there recommended patterns (e.g., type overrides, plugins) to customize datetime types?
Environment:
@hey-api/openapi-ts: 0.56.3 @js-temporal/polyfill: 0.5.0