|
11 | 11 | from ..errors import ParseError, PropertyError, RecursiveReferenceInterupt
|
12 | 12 |
|
13 | 13 | if TYPE_CHECKING: # pragma: no cover
|
14 |
| - from .enum_property import EnumProperty |
15 |
| - from .model_property import ModelProperty |
| 14 | + from .property import Property |
16 | 15 | else:
|
17 |
| - EnumProperty = "EnumProperty" |
18 |
| - ModelProperty = "ModelProperty" |
| 16 | + Property = "Property" |
19 | 17 |
|
20 | 18 | T = TypeVar("T")
|
21 | 19 | _ReferencePath = NewType("_ReferencePath", str)
|
@@ -64,10 +62,10 @@ class Schemas:
|
64 | 62 | """Structure for containing all defined, shareable, and reusable schemas (attr classes and Enums)"""
|
65 | 63 |
|
66 | 64 | classes_by_reference: Dict[
|
67 |
| - _ReferencePath, _Holder[Union[EnumProperty, ModelProperty, RecursiveReferenceInterupt]] |
| 65 | + _ReferencePath, _Holder[Union[Property, RecursiveReferenceInterupt]] |
68 | 66 | ] = attr.ib(factory=dict)
|
69 | 67 | classes_by_name: Dict[
|
70 |
| - _ClassName, _Holder[Union[EnumProperty, ModelProperty, RecursiveReferenceInterupt]] |
| 68 | + _ClassName, _Holder[Union[Property, RecursiveReferenceInterupt]] |
71 | 69 | ] = attr.ib(factory=dict)
|
72 | 70 | errors: List[ParseError] = attr.ib(factory=list)
|
73 | 71 |
|
@@ -105,17 +103,12 @@ def _update_schemas_with_reference(
|
105 | 103 | def _update_schemas_with_data(
|
106 | 104 | *, ref_path: _ReferencePath, data: oai.Schema, schemas: Schemas, visited: Set[_ReferencePath], config: Config
|
107 | 105 | ) -> Union[Schemas, PropertyError]:
|
108 |
| - from . import build_enum_property, build_model_property |
| 106 | + from . import property_from_data |
109 | 107 |
|
110 |
| - prop: Union[PropertyError, ModelProperty, EnumProperty] |
111 |
| - if data.enum is not None: |
112 |
| - prop, schemas = build_enum_property( |
113 |
| - data=data, name=ref_path, required=True, schemas=schemas, enum=data.enum, parent_name=None, config=config |
114 |
| - ) |
115 |
| - else: |
116 |
| - prop, schemas = build_model_property( |
117 |
| - data=data, name=ref_path, schemas=schemas, required=True, parent_name=None, config=config |
118 |
| - ) |
| 108 | + prop: Union[PropertyError, Property] |
| 109 | + prop, schemas = property_from_data( |
| 110 | + data=data, name=ref_path, schemas=schemas, required=True, parent_name="", config=config |
| 111 | + ) |
119 | 112 |
|
120 | 113 | holder = schemas.classes_by_reference.get(ref_path)
|
121 | 114 | if isinstance(prop, PropertyError):
|
|
0 commit comments