@@ -1194,7 +1194,9 @@ def to_json_schema(cls) -> Dict[str, Any]:
11941194 }
11951195
11961196 # Add match_threshold if available (check both attribute names for compatibility)
1197- threshold = getattr (cls , "match_threshold" , None ) or getattr (cls , "_match_threshold" , None )
1197+ threshold = getattr (cls , "match_threshold" , None )
1198+ if threshold is None :
1199+ threshold = getattr (cls , "_match_threshold" , None )
11981200 if threshold is not None :
11991201 schema ["x-aws-stickler-match-threshold" ] = threshold
12001202
@@ -1207,6 +1209,7 @@ def to_json_schema(cls) -> Dict[str, Any]:
12071209
12081210 # Validate field has type annotation
12091211 if field_type is None :
1212+ # Defensive: unreachable through normal Pydantic model construction
12101213 raise ValueError (f"Field '{ field_name } ' has no type annotation" )
12111214
12121215 # Unwrap Optional before type checking
@@ -1219,6 +1222,7 @@ def to_json_schema(cls) -> Dict[str, Any]:
12191222 # Handle List[StructuredModel] or List[primitive]
12201223 args = get_args (field_type )
12211224 if not args :
1225+ # Defensive: unreachable through normal Pydantic model construction
12221226 raise ValueError (
12231227 f"Field '{ field_name } ' has unparameterized list type. "
12241228 f"Use List[str], List[int], etc."
@@ -1321,7 +1325,9 @@ def to_stickler_config(cls) -> Dict[str, Any]:
13211325 }
13221326
13231327 # Add match_threshold if available (check both attribute names for compatibility)
1324- threshold = getattr (cls , "match_threshold" , None ) or getattr (cls , "_match_threshold" , None )
1328+ threshold = getattr (cls , "match_threshold" , None )
1329+ if threshold is None :
1330+ threshold = getattr (cls , "_match_threshold" , None )
13251331 if threshold is not None :
13261332 config ["match_threshold" ] = threshold
13271333
@@ -1334,35 +1340,38 @@ def to_stickler_config(cls) -> Dict[str, Any]:
13341340
13351341 # Validate field has type annotation
13361342 if field_type is None :
1343+ # Defensive: unreachable through normal Pydantic model construction
13371344 raise ValueError (f"Field '{ field_name } ' has no type annotation" )
13381345
13391346 # Unwrap Optional before type checking
13401347 field_type , _ = cls ._unwrap_optional (field_type )
13411348
13421349 # Check if nested StructuredModel - use "structured_model" type
13431350 if cls ._is_structured_model_type (field_type ):
1344- field_config = {
1345- "type" : "structured_model" ,
1346- # Recursively export nested model's fields
1347- "fields" : field_type .to_stickler_config ()["fields" ]
1348- }
1351+ nested_config = field_type .to_stickler_config ()
1352+ field_config = {"type" : "structured_model" , "fields" : nested_config ["fields" ]}
1353+ if nested_config .get ("model_name" ):
1354+ field_config ["model_name" ] = nested_config ["model_name" ]
1355+ if nested_config .get ("match_threshold" ) is not None :
1356+ field_config ["match_threshold" ] = nested_config ["match_threshold" ]
13491357 elif get_origin (field_type ) is list :
13501358 # Handle List[StructuredModel] or List[primitive]
13511359 args = get_args (field_type )
13521360 if not args :
1361+ # Defensive: unreachable through normal Pydantic model construction
13531362 raise ValueError (
13541363 f"Field '{ field_name } ' has unparameterized list type. "
13551364 f"Use List[str], List[int], etc."
13561365 )
13571366 element_type = args [0 ]
13581367
13591368 if cls ._is_structured_model_type (element_type ):
1360- # List of StructuredModels - use "list_structured_model" type
1361- field_config = {
1362- "type" : "list_structured_model" ,
1363- # Recursively export element model's fields
1364- "fields" : element_type . to_stickler_config ()[ "fields" ]
1365- }
1369+ nested_config = element_type . to_stickler_config ()
1370+ field_config = {"type" : "list_structured_model" , "fields" : nested_config [ "fields" ]}
1371+ if nested_config . get ( "model_name" ):
1372+ field_config [ "model_name" ] = nested_config [ "model_name" ]
1373+ if nested_config . get ( "match_threshold" ) is not None :
1374+ field_config [ "match_threshold" ] = nested_config [ "match_threshold" ]
13661375 else :
13671376 # Primitive list - use converter
13681377 field_config = converter .field_to_stickler_config (field_type , field_info )
0 commit comments