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
Remove models with same set of field. #170
Comments
@gk-patel I will implement this feature after remove bugs. |
@gk-patel I put an example. Input datamodel-code-generator/tests/data/json/duplicate_models.json Lines 1 to 15 in 681ca87
Output datamodel-code-generator/tests/data/expected/main/main_json_resuse_model/output.py Lines 10 to 29 in 681ca87
I'm sorry, My work is too late. |
@koxudaxi No worries man, looks nice. Although, the following would have been much more cooler,
If you can do that, it would look much nicer. But if you cannot, then you can close the issue. I leave it up to you. |
@gk-patel But, I found a problem with a case.
We should assign to another value. or we don't touch duplicated enum 🤔 |
Well, IMHO the easiest way would be to check if the content of enums is exactly the same,
Do you have any arguments against this idea ? |
@gk-patel datamodel-code-generator/tests/data/expected/main/main_json_reuse_model/output.py Lines 16 to 26 in ada9b19
The enum will reuse the same model. A duplicate model will be created too. Because some models may need the enum from other modules. datamodel-code-generator/tests/data/expected/main/main_json_reuse_enum/output.py Lines 13 to 28 in ada9b19
|
It would be good if we can identify that a similar model exists and use that model instead of creating a new model, especially when the FIELDS and DATA-TYPE are same.
For example, when my data is as follows,
we get the following output,
Describe the solution you'd like
I think it would be good if we can detect that models for ArmLeft and ArmRight are the same, and then to just use one of these models. For example,
Describe alternatives you've considered
Currently, I just delete manually. But, we have a big system with many similar structures in JSON and many time we need to manually delete about 1000 models. :(
Thank you very much for this excellent tool.
The text was updated successfully, but these errors were encountered: