datamodel-code-generator
datamodel-code-generator copied to clipboard
Use combined schema to "include" additional schema files
Is your feature request related to a problem? Please describe.
I'm struggling to write a schema file to use as input to datamodel-codegen
that "combines" multiple schema files using $ref
s. Is something like this possible?
Input JSON schema files (downloaded to local folder):
- https://raw.githubusercontent.com/CycloneDX/specification/master/schema/bom-1.3.schema.json
- https://raw.githubusercontent.com/CycloneDX/specification/master/schema/bom-1.4.schema.json
- https://raw.githubusercontent.com/CycloneDX/specification/master/schema/bom-1.5.schema.json
- https://raw.githubusercontent.com/CycloneDX/specification/master/schema/jsf-0.82.schema.json
- https://raw.githubusercontent.com/CycloneDX/specification/master/schema/spdx.schema.json
I've tried something along the lines of the following:
{
"allOf": [
{ "$ref": "specification-1.5/schema/bom-1.3.schema.json" },
{ "$ref": "specification-1.5/schema/bom-1.4.schema.json" },
{ "$ref": "specification-1.5/schema/bom-1.5.schema.json" }
]
}
as well as anyOf
and oneOf
.
With the --use-title-as-name
flag, it seems to dump everything into an __init__.py
file (with repetitive class names like ComponentType
, ComponentType1
, ComponentType2
) along with an additional spdx.py
file.
Without the flag, it generates the folder structure
output_models/
├── __init__.py
├── bom_1
│ ├── __init__.py
│ ├── field_3.py
│ ├── field_4.py
│ └── field_5.py
└── spdx.py
Describe the solution you'd like
Desired generated model directory structure:
output_models
├── cyclonedx_1_3.py
├── cyclonedx_1_4.py
├── cyclonedx_1_5.py
├── jsf_0_82.py
└── spdx.py
Describe alternatives you've considered
Additional context
Thanks for the interesting suggestion. I have a feeling it may be not easy, but I will investigate when I have time.