File tree 1 file changed +21
-21
lines changed
1 file changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -64,27 +64,27 @@ def type2schema(t: Any) -> JsonSchemaValue:
64
64
Returns:
65
65
JsonSchemaValue: The JSON schema
66
66
"""
67
- if PYDANTIC_V1 :
68
- if t is None :
69
- return {"type" : "null" }
70
- elif get_origin (t ) is Union :
71
- return {"anyOf" : [type2schema (tt ) for tt in get_args (t )]}
72
- elif get_origin (t ) in [Tuple , tuple ]:
73
- prefixItems = [type2schema (tt ) for tt in get_args (t )]
74
- return {
75
- "maxItems" : len (prefixItems ),
76
- "minItems" : len (prefixItems ),
77
- "prefixItems" : prefixItems ,
78
- "type" : "array" ,
79
- }
80
-
81
- d = schema_of (t )
82
- if "title" in d :
83
- d .pop ("title" )
84
- if "description" in d :
85
- d .pop ("description" )
86
-
87
- return d
67
+
68
+ if t is None :
69
+ return {"type" : "null" }
70
+ elif get_origin (t ) is Union :
71
+ return {"anyOf" : [type2schema (tt ) for tt in get_args (t )]}
72
+ elif get_origin (t ) in [Tuple , tuple ]:
73
+ prefixItems = [type2schema (tt ) for tt in get_args (t )]
74
+ return {
75
+ "maxItems" : len (prefixItems ),
76
+ "minItems" : len (prefixItems ),
77
+ "prefixItems" : prefixItems ,
78
+ "type" : "array" ,
79
+ }
80
+ else :
81
+ d = schema_of (t )
82
+ if "title" in d :
83
+ d .pop ("title" )
84
+ if "description" in d :
85
+ d .pop ("description" )
86
+
87
+ return d
88
88
89
89
def model_dump (model : BaseModel ) -> Dict [str , Any ]:
90
90
"""Convert a pydantic model to a dict
You can’t perform that action at this time.
0 commit comments