Skip to content

Improvement in generic schema generation #1371

Open
@adriangb

Description

@adriangb

Currently if you have a generic model and later substitute it we re-generate the entire schema by walking all of the types. This makes schema generation very expensive.

I propose that instead we wrap types as follows:

generic_model = {
    "type": "definitions",
    "schema": {
        "type": "model",
        "fields": {
            "foo": {
                "type": "definitions-ref",
                "ref": "T::some-ref",
            }
        }
    },
    "definitions": [
        {
            "type": "any",
            "ref": "T::some-ref",
        }
    ]
}

concrete_model = {
    "type": "definitions",
    "schema": generic_model,
    "definitions": [
        {
            "type": "int",
            "ref": "T::some-ref",
        }
    ]
}

This has the potential to greatly improve generics schema generation performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions