openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Customizing Generated Date Types to Use Temporal.Instant

Open DtechB opened this issue 7 months ago • 0 comments

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:

  1. Is there a built-in way to configure @hey-api/openapi-ts to use Temporal types instead of Date?
  2. If not, would a feature request for Temporal support be feasible?
  3. 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

DtechB avatar Mar 30 '25 14:03 DtechB