Client and server binding loses the model --reuse-model replaced when it was moved into an _internal module
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Inspect the _target_binding._Binder.reused method and the DataModel.reused_reference attribute in the binder source. Run the fixtures modular.yaml, circular_imports_class_conflict.yaml, reuse_model_cross_module_users.yaml and nullable_map_value_cycle_reuse.yaml (client and server) to observe FinalModelSymbol.discriminator becoming None. Fix by reading the replaced model from DataModel.reused_reference instead of the /reuse suffix, then verify discriminator is set.
Written by the indexing model from the issue text.
Description
Summary
With --reuse-model, client and server binding loses the model that reuse replaced when the replaced model was first moved into an _internal module.
Details
A duplicate model inside a module cycle is moved to _internal before reuse, so its subclass's path becomes _internal.X/reuse. _target_binding._Binder.reused strips the /reuse suffix and looks the path up among the resolver keys, which keep the schema path, so it finds nothing, while DataModel.reused_reference names the model.
This happens in 28 binder calls across the existing fixtures modular.yaml, circular_imports_class_conflict.yaml, reuse_model_cross_module_users.yaml and nullable_map_value_cycle_reuse.yaml (client and server).
Effect
FinalModelSymbol.discriminator (the replaced union's own discriminator) is None for such a model. No generated output difference has been found: in the fixtures the replaced models are not unions, and a constructed discriminated union reused inside an _internal cycle has the same discriminator as its canonical model.
Expected
The binding reads the model reuse replaced from DataModel.reused_reference, never from the /reuse path suffix.
- Dominant language
- Python
- Stars
- 4k
- Forks
- 460
- Avg merge
- 7h 27m
- Merged PRs (30d)
- 910
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from datamodel-code-generator/datamodel-code-generator
-
A directory input with a non-identifier subdirectory name writes an import that is not valid PythonPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
datamodel-code-generator/datamodel-code-generator#5999 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
datamodel-code-generator/datamodel-code-generator#5984 ·
Maintainers usually reply within 1 day
-
A control character in a pattern is written as a regex escape in a raw literalPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
datamodel-code-generator/datamodel-code-generator#5982 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
datamodel-code-generator/datamodel-code-generator#5978 ·
Maintainers usually reply within 1 day
-
A media type with schema: null and an itemSchema generates no model in components.requestBodiesOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
datamodel-code-generator/datamodel-code-generator#5963 ·
Maintainers usually reply within 1 day
All issues in datamodel-code-generator/datamodel-code-generator
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
521xueweihan/HelloGitHub#4237 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/gaussx#721 ·
Maintainers usually reply within 1 day
-
mock-core-configs/etc/mock/rocky-10-riscv64.cfg contains the wrong architecture in config_opts['root']Possibly taken @jasonmontleon claimed this 4 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 94/100
rpm-software-management/mock#1834 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
elastic/elastic-otel-python#683 ·
Maintainers usually reply within 1 day
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retriesOpenfollow-up
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day