Skip to content

Add CLI to generate models from schemas #105

@mferrera

Description

@mferrera

This command should walk the schemas host, collect every current schema, and use https://github.com/koxudaxi/datamodel-code-generator/ to generate Python code such that metadata objects can be represented by a Python object by consumers.

Every JSON schema can be collected by walking through https://main-fmu-schemas-prod.radix.equinor.com/schemas/?json=true (or the dev endpoint).

This command could potentially generate a simple interface to return one of these generated objects if metadata json or yaml is fed into it. Alternatively, that interface could be left to consumers to customize to their needs.

The command should not be prefaced with fmu- to not pollute that interface. It should perhaps begin with codegen- or ...

The command can reference

DEV_URL: Final[str] = "https://main-fmu-schemas-dev.radix.equinor.com"
PROD_URL: Final[str] = "https://main-fmu-schemas-prod.radix.equinor.com"

to get the url, so that the user only needs to provide 'dev' or 'prod', with a default of prod. The command can optionally take a path to output the generated code into, with a sane default.

Related issue: #30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions