Fixed with PR #2461
datamodel-code-generator reproducible example for issue #2460
| Inputs | Outputs |
|---|---|
| inputs/aaaschema.json | outputs/aaaschema.py |
| inputs/commons.json | outputs/commons.py |
| inputs/bug.json | outputs/bug.py |
- I define
allowedAnimalsinaaaschema.jsonas an array of objects - I generate the code. A RootModel is generated and it works.
- I define
allowedAnimalsas object withadditionalProperties: falseinbug.json - I generate the code. The model of the first schema has been edited and now the RootModel has
extra: forbid(which is not valid) - I rename
allowedAnimalsinbug.jsonwith a different name - Now the generated code of
aaaschema.jsonis correct again.
We don't want bug.json definitions to interfere with the generation of the models for aaaschema.json
Somehow, allowedAnimals definition in bug.json add extra: false to allowedAnimals RootModel generated for aaaschema.json which result in an:
- Incorrect behavior
- Invalid output
$ pip install -r requirements.txt
$ datamodel-codegen