Skip to content
Prev Previous commit
Next Next commit
Style
  • Loading branch information
forest-benchling authored and dbanty committed Aug 1, 2021
commit e4e235386cff952195ad202ac5a1ad8311c21442
11 changes: 7 additions & 4 deletions openapi_python_client/parser/properties/model_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ... import schema as oai
from ... import utils
from ..errors import ParseError, PropertyError
from .enum_property import EnumProperty
from .property import Property
from .schemas import Class, Schemas, parse_reference_path

Expand Down Expand Up @@ -50,18 +51,20 @@ def get_imports(self, *, prefix: str) -> Set[str]:


def _is_string_enum(prop: Property) -> bool:
return prop.__class__.__name__ == "EnumProperty" and prop.value_type == str
return isinstance(prop, EnumProperty) and prop.value_type == str


def _is_int_enum(prop: Property) -> bool:
return prop.__class__.__name__ == "EnumProperty" and prop.value_type == int
return isinstance(prop, EnumProperty) and prop.value_type == int


def _is_subtype(first: Property, second: Property) -> bool:
from . import IntProperty, StringProperty

return any(
[
_is_string_enum(first) and second.__class__.__name__ == "StringProperty",
_is_int_enum(first) and second.__class__.__name__ == "IntProperty",
_is_string_enum(first) and isinstance(second, StringProperty),
_is_int_enum(first) and isinstance(second, IntProperty),
_is_string_enum(first)
and _is_string_enum(second)
and set(first.values.items()) <= set(second.values.items()),
Expand Down