openapi-core/openapi_core/extensions/models/models.py

18 lines
504 B
Python
Raw Normal View History

2018-04-17 12:18:40 +00:00
"""OpenAPI X-Model extension models module"""
class BaseModel(dict):
2018-04-17 12:18:40 +00:00
"""Base class for OpenAPI X-Model."""
def __getattr__(self, attr_name):
"""Only search through properties if attribute not found normally.
:type attr_name: str
"""
try:
return self[attr_name]
except KeyError:
raise AttributeError(
'type object {0!r} has no attribute {1!r}'
.format(type(self).__name__, attr_name)
)