mirror of https://github.com/eyhc1/rendercv.git
docs: fix bugs in JSON Schema
This commit is contained in:
parent
f705015911
commit
a465a1ce81
|
@ -1347,6 +1347,8 @@ def generate_json_schema() -> dict[str, Any]:
|
||||||
dict: The JSON schema of RenderCV.
|
dict: The JSON schema of RenderCV.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# def loop_through_pro
|
||||||
|
|
||||||
class RenderCVSchemaGenerator(pydantic.json_schema.GenerateJsonSchema):
|
class RenderCVSchemaGenerator(pydantic.json_schema.GenerateJsonSchema):
|
||||||
def generate(self, schema, mode="validation"): # type: ignore
|
def generate(self, schema, mode="validation"): # type: ignore
|
||||||
json_schema = super().generate(schema, mode=mode)
|
json_schema = super().generate(schema, mode=mode)
|
||||||
|
@ -1361,7 +1363,7 @@ def generate_json_schema() -> dict[str, Any]:
|
||||||
|
|
||||||
# Loop through $defs and remove docstring descriptions and fix optional
|
# Loop through $defs and remove docstring descriptions and fix optional
|
||||||
# fields
|
# fields
|
||||||
for _, value in json_schema["$defs"].items():
|
for object_name, value in json_schema["$defs"].items():
|
||||||
# Don't allow additional properties
|
# Don't allow additional properties
|
||||||
value["additionalProperties"] = False
|
value["additionalProperties"] = False
|
||||||
|
|
||||||
|
@ -1372,14 +1374,22 @@ def generate_json_schema() -> dict[str, Any]:
|
||||||
# don't want to provide them.
|
# don't want to provide them.
|
||||||
null_type_dict = {}
|
null_type_dict = {}
|
||||||
null_type_dict["type"] = "null"
|
null_type_dict["type"] = "null"
|
||||||
for field in value["properties"].values():
|
for field_name, field in value["properties"].items():
|
||||||
if "anyOf" in field:
|
if "anyOf" in field:
|
||||||
if (
|
if (
|
||||||
len(field["anyOf"]) == 2
|
len(field["anyOf"]) == 2
|
||||||
and null_type_dict in field["anyOf"]
|
and null_type_dict in field["anyOf"]
|
||||||
):
|
):
|
||||||
field["allOf"] = [field["anyOf"][0]]
|
field["oneOf"] = [field["anyOf"][0]]
|
||||||
del field["anyOf"]
|
del field["anyOf"]
|
||||||
|
|
||||||
|
# for sections field of CurriculumVitae:
|
||||||
|
if "additionalProperties" in field["oneOf"][0]:
|
||||||
|
field["oneOf"][0]["additionalProperties"]["oneOf"] = (
|
||||||
|
field["oneOf"][0]["additionalProperties"]["anyOf"]
|
||||||
|
)
|
||||||
|
del field["oneOf"][0]["additionalProperties"]["anyOf"]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
field["oneOf"] = field["anyOf"]
|
field["oneOf"] = field["anyOf"]
|
||||||
del field["anyOf"]
|
del field["anyOf"]
|
||||||
|
|
36
schema.json
36
schema.json
|
@ -154,7 +154,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The name of the person.",
|
"description": "The name of the person.",
|
||||||
"title": "Name",
|
"title": "Name",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The label of the person.",
|
"description": "The label of the person.",
|
||||||
"title": "Label",
|
"title": "Label",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The location of the person.",
|
"description": "The location of the person.",
|
||||||
"title": "Location",
|
"title": "Location",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The email of the person.",
|
"description": "The email of the person.",
|
||||||
"title": "Email",
|
"title": "Email",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"format": "email",
|
"format": "email",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The phone number of the person.",
|
"description": "The phone number of the person.",
|
||||||
"title": "Phone",
|
"title": "Phone",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"format": "phone",
|
"format": "phone",
|
||||||
"maxLength": 64,
|
"maxLength": 64,
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The website of the person.",
|
"description": "The website of the person.",
|
||||||
"title": "Website",
|
"title": "Website",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"format": "uri",
|
"format": "uri",
|
||||||
"maxLength": 2083,
|
"maxLength": 2083,
|
||||||
|
@ -221,7 +221,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The social networks of the person.",
|
"description": "The social networks of the person.",
|
||||||
"title": "Social Networks",
|
"title": "Social Networks",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/$defs/SocialNetwork"
|
"$ref": "#/$defs/SocialNetwork"
|
||||||
|
@ -234,10 +234,10 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The sections of the CV.",
|
"description": "The sections of the CV.",
|
||||||
"title": "Sections",
|
"title": "Sections",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/$defs/OneLineEntry"
|
"$ref": "#/$defs/OneLineEntry"
|
||||||
|
@ -314,7 +314,7 @@
|
||||||
"MS"
|
"MS"
|
||||||
],
|
],
|
||||||
"title": "Degree",
|
"title": "Degree",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@
|
||||||
"Istanbul, T\u00fcrkiye"
|
"Istanbul, T\u00fcrkiye"
|
||||||
],
|
],
|
||||||
"title": "Location",
|
"title": "Location",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@
|
||||||
"Did that."
|
"Did that."
|
||||||
],
|
],
|
||||||
"title": "Highlights",
|
"title": "Highlights",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -614,7 +614,7 @@
|
||||||
"Istanbul, T\u00fcrkiye"
|
"Istanbul, T\u00fcrkiye"
|
||||||
],
|
],
|
||||||
"title": "Location",
|
"title": "Location",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@
|
||||||
"Did that."
|
"Did that."
|
||||||
],
|
],
|
||||||
"title": "Highlights",
|
"title": "Highlights",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -1078,7 +1078,7 @@
|
||||||
"Istanbul, T\u00fcrkiye"
|
"Istanbul, T\u00fcrkiye"
|
||||||
],
|
],
|
||||||
"title": "Location",
|
"title": "Location",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -1156,7 +1156,7 @@
|
||||||
"Did that."
|
"Did that."
|
||||||
],
|
],
|
||||||
"title": "Highlights",
|
"title": "Highlights",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -1254,7 +1254,7 @@
|
||||||
"10.48550/arXiv.2310.03138"
|
"10.48550/arXiv.2310.03138"
|
||||||
],
|
],
|
||||||
"title": "DOI",
|
"title": "DOI",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
@ -1279,7 +1279,7 @@
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The journal or the conference name.",
|
"description": "The journal or the conference name.",
|
||||||
"title": "Journal",
|
"title": "Journal",
|
||||||
"allOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue