You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when I try to use the models I end up with the unhelpful message:
...
/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/typing.py:415: in _eval_type
return t._evaluate(globalns, localns, type_params, recursive_guard=recursive_guard)
/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/typing.py:938: in _evaluate
eval(self.forward_code, globalns, locals_to_pass),
:1: in
???
../.venv/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py:237: in getattr
raise AttributeError(item)
E AttributeError: AnonymousSchema15
The import seems to break the types for pydantic. It works fine when I go with from .AnonymousSchema15 import AnonymousSchema15 and then Optional[AnonymousSchema15].
This seems to be some deep crappy typehinting black magic eff-up.
So the fix might just be to adjust the import + the usage.
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
Describe the bug.
(ref. asyncapi/cli#1485)
So with
--pyDantic
, the CLI generates models like:with
But when I try to use the models I end up with the unhelpful message:
The import seems to break the types for pydantic. It works fine when I go with
from .AnonymousSchema15 import AnonymousSchema15
and thenOptional[AnonymousSchema15]
.This seems to be some deep crappy typehinting black magic eff-up.
So the fix might just be to adjust the import + the usage.
Expected behavior
Nested models should work out of the box.
Screenshots
How to Reproduce
allOf
:asyncapi generate models python asyncapi.yaml --pyDantic
🥦 Browser
None
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
None
The text was updated successfully, but these errors were encountered: