@@ -5066,7 +5066,7 @@ class JSONSchema:
50665066 description: An optional description of the object described by this schema.
50675067 properties: A list of property schemas.
50685068 required: A list of properties required by the schema.
5069- conditional_dependencies : A mapping of conditional dependencies to be added to the "allOf" keyword in JSON Schema.
5069+ _conditional_dependencies : A mapping of conditional dependencies to be added to the "allOf" keyword in JSON Schema.
50705070 The key is a tuple of (watched_property, enum_value)
50715071 The value is a list of properties that become required when watched_property has the value enum_value.
50725072 """
@@ -5078,7 +5078,7 @@ class JSONSchema:
50785078 description : str = "TBD"
50795079 properties : dict [str , Property ] = field (default_factory = dict )
50805080 required : list [str ] = field (default_factory = list )
5081- conditional_dependencies : dict [tuple [str , str ], list [str ]] = field (
5081+ _conditional_dependencies : dict [tuple [str , str ], list [str ]] = field (
50825082 default_factory = dict
50835083 )
50845084
@@ -5106,12 +5106,11 @@ def as_json_schema_dict(
51065106 # in the correct format to be added as is, and they need to be converted to allOf conditions first.
51075107 # Finally the conditional dependencies are removed from the JSON Schema dict because they are not a
51085108 # valid JSON Schema keyword
5109- if self .conditional_dependencies :
5109+ if self ._conditional_dependencies :
51105110 json_schema_dict ["allOf" ] = self ._convert_conditional_properties_to_all_of (
5111- self .conditional_dependencies
5111+ self ._conditional_dependencies
51125112 )
5113- json_schema_dict .pop ("conditional_dependencies" )
5114-
5113+ json_schema_dict .pop ("_conditional_dependencies" )
51155114 return json_schema_dict
51165115
51175116 def add_required_property (self , name : str ) -> None :
@@ -5158,11 +5157,14 @@ def add_conditional_dependency(
51585157 enum_value: The value of the watched property that triggers the condition
51595158 dependent_property: The property that becomes required when the condition is triggered
51605159 """
5161- if (watched_property , enum_value ) not in self .conditional_dependencies :
5162- self .conditional_dependencies [(watched_property , enum_value )] = []
5163- self .conditional_dependencies [(watched_property , enum_value )].append (
5164- dependent_property
5165- )
5160+ if (watched_property , enum_value ) not in self ._conditional_dependencies :
5161+ self ._conditional_dependencies [(watched_property , enum_value )] = [
5162+ dependent_property
5163+ ]
5164+ else :
5165+ self ._conditional_dependencies [(watched_property , enum_value )].append (
5166+ dependent_property
5167+ )
51665168
51675169 @staticmethod
51685170 def _convert_conditional_properties_to_all_of (
0 commit comments