Closed DanielRosenwasser closed 5 months ago
Currently, our Python implementation only supports TypedDicts. This is okay, but I think we need to support dataclasses.
TypedDicts
Given a reference to Event for the following code,
Event
from dataclasses import dataclass, field @dataclass class EventTimeRange: ... @dataclass class Event: day: str time_range: EventTimeRange description: str location: str | None participants: list[str] = field(default_factory=list)
We should generate the following schema for Event:
interface Event { day: string; time_range: EventTimeRange; description: string; location: string | null; participants: string[]; }
I've adapted this example from the calendar example. Note two things:
null
| None
Currently, our Python implementation only supports
TypedDicts
. This is okay, but I think we need to support dataclasses.Given a reference to
Event
for the following code,We should generate the following schema for
Event
:I've adapted this example from the calendar example. Note two things:
null
-able.| None
in an annotation makes a fieldnull
-able, but not necessarily optional.