Skip to content

Commit c0be423

Browse files
committed
Move iter_valid_schemas to schema validator
1 parent b0042ca commit c0be423

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Diff for: openapi_core/unmarshalling/schemas/unmarshallers.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,7 @@ def evolve(self, schema: Spec) -> "SchemaUnmarshaller":
305305
)
306306

307307
def find_format(self, value: Any) -> Optional[str]:
308-
for schema in self.iter_valid_schemas(value):
308+
for schema in self.schema_validator.iter_valid_schemas(value):
309309
if "format" in schema:
310310
return str(schema.getkey("format"))
311311
return None
312-
313-
def iter_valid_schemas(self, value: Any) -> Iterator[Spec]:
314-
yield self.schema
315-
316-
one_of_schema = self.schema_validator.get_one_of_schema(value)
317-
if one_of_schema is not None:
318-
yield one_of_schema
319-
320-
yield from self.schema_validator.iter_any_of_schemas(value)
321-
yield from self.schema_validator.iter_all_of_schemas(value)

Diff for: openapi_core/validation/schemas/validators.py

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ def format_validator_callable(self) -> FormatValidator:
7878

7979
return lambda x: True
8080

81+
def iter_valid_schemas(self, value: Any) -> Iterator[Spec]:
82+
yield self.schema
83+
84+
one_of_schema = self.get_one_of_schema(value)
85+
if one_of_schema is not None:
86+
yield one_of_schema
87+
88+
yield from self.iter_any_of_schemas(value)
89+
yield from self.iter_all_of_schemas(value)
90+
8191
def get_one_of_schema(
8292
self,
8393
value: Any,

0 commit comments

Comments
 (0)