diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 84e64a1..9872937 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -1347,6 +1347,8 @@ def generate_json_schema() -> dict[str, Any]: dict: The JSON schema of RenderCV. """ + # def loop_through_pro + class RenderCVSchemaGenerator(pydantic.json_schema.GenerateJsonSchema): def generate(self, schema, mode="validation"): # type: ignore 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 # fields - for _, value in json_schema["$defs"].items(): + for object_name, value in json_schema["$defs"].items(): # Don't allow additional properties value["additionalProperties"] = False @@ -1372,14 +1374,22 @@ def generate_json_schema() -> dict[str, Any]: # don't want to provide them. null_type_dict = {} null_type_dict["type"] = "null" - for field in value["properties"].values(): + for field_name, field in value["properties"].items(): if "anyOf" in field: if ( len(field["anyOf"]) == 2 and null_type_dict in field["anyOf"] ): - field["allOf"] = [field["anyOf"][0]] + field["oneOf"] = [field["anyOf"][0]] 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: field["oneOf"] = field["anyOf"] del field["anyOf"] diff --git a/schema.json b/schema.json index 8853014..4a28b82 100644 --- a/schema.json +++ b/schema.json @@ -154,7 +154,7 @@ "default": null, "description": "The name of the person.", "title": "Name", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -164,7 +164,7 @@ "default": null, "description": "The label of the person.", "title": "Label", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -174,7 +174,7 @@ "default": null, "description": "The location of the person.", "title": "Location", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -184,7 +184,7 @@ "default": null, "description": "The email of the person.", "title": "Email", - "allOf": [ + "oneOf": [ { "format": "email", "type": "string" @@ -195,7 +195,7 @@ "default": null, "description": "The phone number of the person.", "title": "Phone", - "allOf": [ + "oneOf": [ { "format": "phone", "maxLength": 64, @@ -208,7 +208,7 @@ "default": null, "description": "The website of the person.", "title": "Website", - "allOf": [ + "oneOf": [ { "format": "uri", "maxLength": 2083, @@ -221,7 +221,7 @@ "default": null, "description": "The social networks of the person.", "title": "Social Networks", - "allOf": [ + "oneOf": [ { "items": { "$ref": "#/$defs/SocialNetwork" @@ -234,10 +234,10 @@ "default": null, "description": "The sections of the CV.", "title": "Sections", - "allOf": [ + "oneOf": [ { "additionalProperties": { - "anyOf": [ + "oneOf": [ { "items": { "$ref": "#/$defs/OneLineEntry" @@ -314,7 +314,7 @@ "MS" ], "title": "Degree", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -327,7 +327,7 @@ "Istanbul, T\u00fcrkiye" ], "title": "Location", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -405,7 +405,7 @@ "Did that." ], "title": "Highlights", - "allOf": [ + "oneOf": [ { "items": { "type": "string" @@ -614,7 +614,7 @@ "Istanbul, T\u00fcrkiye" ], "title": "Location", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -692,7 +692,7 @@ "Did that." ], "title": "Highlights", - "allOf": [ + "oneOf": [ { "items": { "type": "string" @@ -1078,7 +1078,7 @@ "Istanbul, T\u00fcrkiye" ], "title": "Location", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -1156,7 +1156,7 @@ "Did that." ], "title": "Highlights", - "allOf": [ + "oneOf": [ { "items": { "type": "string" @@ -1254,7 +1254,7 @@ "10.48550/arXiv.2310.03138" ], "title": "DOI", - "allOf": [ + "oneOf": [ { "type": "string" } @@ -1279,7 +1279,7 @@ "default": null, "description": "The journal or the conference name.", "title": "Journal", - "allOf": [ + "oneOf": [ { "type": "string" }