-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] from . import AnonymousSchemaX breaks types (?) #2076
Comments
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. |
I can strip down the schema to a minimal example if the issue isn't apparent. My quick workaround is to patch it after code generation: LC_ALL=C find models/generated -type f -exec sed -i '' -r 's/^from . import (AnonymousSchema[0-9]+)/from .\1 import \1/' {} \; \
&& LC_ALL=C find models/generated -type f -exec sed -i '' -r 's/Optional\[AnonymousSchema[0-9]+\./Optional[/' {} \; |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Stale - yes, but still as valid as it's been half a year ago. |
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: