-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix: Fail when duplicate names are generated #336
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #336 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 1390 1393 +3
=========================================
+ Hits 1390 1393 +3
Continue to review full report at Codecov.
|
@@ -302,6 +306,9 @@ def build_model_property( | |||
name=name, | |||
additional_properties=additional_properties, | |||
) | |||
if prop.reference.class_name in schemas.models: | |||
raise NameClashException(f'Attempted to generate duplicate models with name "{prop.reference.class_name}"') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should return a PropertyError
here instead so our higher level error handling code can manage it rather than printing a stack trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍. Thanks for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add unit test checks for these so Codecov is happy? And sync up with main which contains #334 now.
@dbanty I removed the enum check, since it turns out that IIUC we were already checking for enum name collisions (see |
Awesome, thanks! Will merge this one now. |
Previously, it would silently create buggy code if duplicate models were generated with the same name; see #335 and #323.