Skip to content

Add static Kind and ApiVersion properties on generated model classes #151

Closed
@qmfrederik

Description

@qmfrederik

It would be super useful if generated classes could have a static Kind and ApiVersion property.

For example, right now I had to do:

if(genericObject.Kind == "Status")
{
    var status = SafeJsonConvert.DeserializeObject<V1Status>(json);
}

where Status is a magic value I had to introduce.

It would be great if I would be able to just do:

if(genericObject.Kind == V1Status.Kind)
{
    var status = SafeJsonConvert.DeserializeObject<V1Status>(json);
}

making the code a bit more explicit and allowing me to bypass the need for a magic constant.

Is this something the code generator could do?

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