Closed Lazloo closed 2 years ago
Can I configure somehow the handling of datetime.date? Here is my use case:
datetime.date
I have a field in my pydantic model called start_date:
import datetime from aifora.da.schema.customer.models._base import BaseModel class MyModel(BaseModel): start_date: datetime.date
When I let pydantic generate a JSON-Schema (MyModel.schema_json), this field is represented as string:
MyModel.schema_json
"start_date": { "title": "Start Date", "type": "string", "format": "date" },
However, when I apply py-avro-schema to this field is represented as INT:
{ "name": "start_date", "type": { "type": "int", "logicalType": "date" }, },
Is there any setting that dates in py-avro-schema are converted to strings?
That is as per Avro specification. See https://avro.apache.org/docs/1.10.2/spec.html#Date
JSON does not have native support for dates. It just happens to be a convention to serialize dates as ISO strings.
Can I configure somehow the handling of
datetime.date
? Here is my use case:I have a field in my pydantic model called start_date:
When I let pydantic generate a JSON-Schema (
MyModel.schema_json
), this field is represented as string:However, when I apply py-avro-schema to this field is represented as INT:
Is there any setting that dates in py-avro-schema are converted to strings?