File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
openapi_core/casting/schemas Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -45,20 +45,27 @@ def cast(self, value: Any) -> Any:
4545 if "allOf" in self .schema :
4646 for subschema in self .schema / "allOf" :
4747 try :
48+ # Note: Mutates `value` iteratively. This sequentially
49+ # resolves standard overlapping types but can cause edge cases
50+ # if a string is casted to an int and passed to a string schema.
4851 value = self .schema_caster .evolve (subschema ).cast (value )
4952 except (ValueError , TypeError , CastError ):
5053 pass
5154
5255 if "oneOf" in self .schema :
5356 for subschema in self .schema / "oneOf" :
5457 try :
58+ # Note: Greedy resolution. Will return the first successful
59+ # cast based on the order of the oneOf array.
5560 return self .schema_caster .evolve (subschema ).cast (value )
5661 except (ValueError , TypeError , CastError ):
5762 pass
5863
5964 if "anyOf" in self .schema :
6065 for subschema in self .schema / "anyOf" :
6166 try :
67+ # Note: Greedy resolution. Will return the first successful
68+ # cast based on the order of the anyOf array.
6269 return self .schema_caster .evolve (subschema ).cast (value )
6370 except (ValueError , TypeError , CastError ):
6471 pass
You can’t perform that action at this time.
0 commit comments