data_models: refactor

This commit is contained in:
Sina Atalay 2024-05-20 21:58:18 +03:00
parent a39ea4732c
commit 96a2be6455
1 changed files with 2 additions and 11 deletions

View File

@ -183,7 +183,7 @@ class BulletEntry(RenderCVBaseModel):
class EntryWithDate(RenderCVBaseModel):
date: Optional[int | RenderCVDate | str] = pydantic.Field(
date: Optional[int | str] = pydantic.Field(
default=None,
title="Date",
description=(
@ -1509,7 +1509,7 @@ def get_a_sample_data_model(
),
authors=[
"Albert Smith",
name,
f"***{name}***",
"Jane Derry",
"Harry Tom",
"Frodo Baggins",
@ -1663,15 +1663,6 @@ def generate_json_schema() -> dict[str, Any]:
field["oneOf"] = field["anyOf"]
del field["anyOf"]
# In date field, we both allow string and RenderCVDate type. Since we
# use "oneOf", matching both RenderCVDate and string is a problem
# for the JSON schema. So, we remove the RenderCVDate type from the
# "oneOf" list.
if "date" in value["properties"]:
for i, one_of in enumerate(value["properties"]["date"]["oneOf"]):
if "pattern" in one_of:
del value["properties"]["date"]["oneOf"][i]
return json_schema
schema = RenderCVDataModel.model_json_schema(