Skip to content

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

Merged
merged 9 commits into from
Feb 10, 2021

Conversation

forest-benchling
Copy link
Collaborator

@forest-benchling forest-benchling commented Feb 10, 2021

Previously, it would silently create buggy code if duplicate models were generated with the same name; see #335 and #323.

@codecov
Copy link

codecov bot commented Feb 10, 2021

Codecov Report

Merging #336 (ba9bf86) into main (2833602) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #336   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         1390      1393    +3     
=========================================
+ Hits          1390      1393    +3     
Impacted Files Coverage Δ
...penapi_python_client/parser/properties/__init__.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2833602...3ae0f18. Read the comment docs.

@forest-benchling
Copy link
Collaborator Author

cc @dbanty @emann @bowenwr @packyg

@@ -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}"')
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍. Thanks for the review!

Copy link
Collaborator

@dbanty dbanty left a 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.

@forest-benchling
Copy link
Collaborator Author

@dbanty I removed the enum check, since it turns out that IIUC we were already checking for enum name collisions (see openapi_python_client/parser/properties/__init__.py:349).

@dbanty
Copy link
Collaborator

dbanty commented Feb 10, 2021

Awesome, thanks! Will merge this one now.

@dbanty dbanty merged commit 2bfe610 into openapi-generators:main Feb 10, 2021
dbanty added a commit that referenced this pull request Feb 10, 2021
@forest-benchling forest-benchling deleted the forest-clash branch February 10, 2021 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants