You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logic in type_converter when, with orjson enabled, types are generated as "datetime.date".
Describe alternatives you've considered
Potentially some other hooks or injectable logic inside type_converter that could allow a developer to inject or otherwise override type generation. This could be some kind of type registry.
Additional context
I am generating schema for date types that do not have time component, and would be incorrect to use datetime type.
Activity
tractorcow commentedon Mar 10, 2025
Alternatively, if a type is generated as "type": "string", and some unknown "format", it should at least type as a string rather than erroring.
feat: add support for date-only format (datetime.date type)
dougborg commentedon Oct 27, 2025
✅ Implemented in PR #122
Date-only type support has been added! String fields with
format: "date"now generatedatetime.datetype.Usage
OpenAPI Spec:
{ "birth_date": { "type": "string", "format": "date" } }Generated Code:
Requirements
use_orjson=Truewhen generating code (same as other format conversions like UUID and datetime)strtype when orjson is disabledImplementation
The feature leverages the refactored
_handle_format_conversions()function from #98, making it a clean 9-line addition in a single location.Testing
test_date_format_generates_date_type: Verifies proper date type generationtest_date_format_without_orjson: Verifies str fallback behaviorThe feature will be available once PR #122 is merged.