datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

merge generated structure based on version and apiversion/kind structure

Open haarchri opened this issue 1 year ago • 0 comments

we generate datamodels from a folder structure

		"--input-file-type",
		"openapi",
		"--input",
		".",
		"--output-model-type",
		"pydantic_v2.BaseModel",
		"--target-python-version",
		"3.12",
		"--use-field-description",
		"--output",
                     "models".

the output looks like

tree models 
models
└── apis
    ├── composition_basics
    │   ├── XAccountScaffold
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           ├── __init__.py
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   └── XCompositeCluster
    │       └── definition.yaml_openapi_v3
    │           ├── co
    │           │   └── acme
    │           │       └── platform
    │           │           ├── __init__.py
    │           │           └── v1alpha1.py
    │           └── io
    │               └── k8s
    │                   └── apimachinery
    │                       └── pkg
    │                           └── apis
    │                               └── meta
    │                                   ├── __init__.py
    │                                   └── v1.py
    ├── primitives
    │   ├── XCluster
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   ├── XDatabase
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   ├── XNetwork
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   ├── XNodepool
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   ├── XServiceAccount
    │   │   └── definition.yaml_openapi_v3
    │   │       ├── co
    │   │       │   └── acme
    │   │       │       └── platform
    │   │       │           ├── __init__.py
    │   │       │           └── v1alpha1.py
    │   │       └── io
    │   │           └── k8s
    │   │               └── apimachinery
    │   │                   └── pkg
    │   │                       └── apis
    │   │                           └── meta
    │   │                               ├── __init__.py
    │   │                               └── v1.py
    │   └── XSubnetwork
    │       └── definition.yaml_openapi_v3
    │           ├── co
    │           │   └── acme
    │           │       └── platform
    │           │           ├── __init__.py
    │           │           └── v1alpha1.py
    │           └── io
    │               └── k8s
    │                   └── apimachinery
    │                       └── pkg
    │                           └── apis
    │                               └── meta
    │                                   ├── __init__.py
    │                                   └── v1.py

wonder if we can get this to the following structure:

models
├── co
│   └── acme
│       └── platform
│           ├── accountscaffold
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── cluster
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── compositecluster
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── database
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── network
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── nodepool
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── serviceaccount
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── subnetwork
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xaccountscaffold
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xcluster
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xcompositecluster
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xdatabase
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xnetwork
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xnodepool
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           ├── xserviceaccount
│           │   ├── __init__.py
│           │   └── v1alpha1.py
│           └── xsubnetwork
│               ├── __init__.py
│               └── v1alpha1.py
└── io
    ├── crossplane
    │   └── fn
    │       └── pt
    │           └── resources
    │               ├── __init__.py
    │               └── v1beta1.py
    └── k8s
        └── apimachinery
            └── pkg
                └── apis
                    └── meta
                        ├── __init__.py
                        └── v1.py

haarchri avatar Oct 02 '24 18:10 haarchri