[Feature Request] Models inheritance
denisovkiv opened this issue · comments
Denisov Kirill commented
Hello! What do you think about models inheritance? Ex.
from sanic_openapi import doc
class ShortInfo:
foo = doc.String()
class FullInfo(ShortInfo):
bar = doc.String()
Expected that FullInfo
model would include foo
field, but in the UI appears bar
field only.
One of possible solutions is to change this line
https://github.com/huge-success/sanic-openapi/blob/fe29d07ccb0e02ec0be6496e971946269b2d7907/sanic_openapi/doc.py#L143
to something like
{key: getattr(self.cls, key) for key in dir(self.cls)}.items(), typing.get_type_hints(self.cls).items()
to get all of class fields include parents, not only current class (SO example)
It would be very nice feature to keep projects DRY
Jacob Chen commented
Sounds cool, do you want to submit a PR for it?
Denisov Kirill commented
Yes, I would be very happy to help :)
Jacob Chen commented
Since #166 is merged, close this issue.