mirror of https://github.com/eyhc1/rendercv.git
data_models: refactor
This commit is contained in:
parent
a39ea4732c
commit
96a2be6455
|
@ -183,7 +183,7 @@ class BulletEntry(RenderCVBaseModel):
|
||||||
|
|
||||||
|
|
||||||
class EntryWithDate(RenderCVBaseModel):
|
class EntryWithDate(RenderCVBaseModel):
|
||||||
date: Optional[int | RenderCVDate | str] = pydantic.Field(
|
date: Optional[int | str] = pydantic.Field(
|
||||||
default=None,
|
default=None,
|
||||||
title="Date",
|
title="Date",
|
||||||
description=(
|
description=(
|
||||||
|
@ -1509,7 +1509,7 @@ def get_a_sample_data_model(
|
||||||
),
|
),
|
||||||
authors=[
|
authors=[
|
||||||
"Albert Smith",
|
"Albert Smith",
|
||||||
name,
|
f"***{name}***",
|
||||||
"Jane Derry",
|
"Jane Derry",
|
||||||
"Harry Tom",
|
"Harry Tom",
|
||||||
"Frodo Baggins",
|
"Frodo Baggins",
|
||||||
|
@ -1663,15 +1663,6 @@ def generate_json_schema() -> dict[str, Any]:
|
||||||
field["oneOf"] = field["anyOf"]
|
field["oneOf"] = field["anyOf"]
|
||||||
del 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
|
return json_schema
|
||||||
|
|
||||||
schema = RenderCVDataModel.model_json_schema(
|
schema = RenderCVDataModel.model_json_schema(
|
||||||
|
|
Loading…
Reference in New Issue