Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qmfrederik opened this issue Apr 27, 2018 · 2 comments
Closed

Comments

@qmfrederik
Copy link
Contributor

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?

@brendandburns
Copy link
Contributor

Maybe? Swagger doesn't really represent this kind of stuff well, see the discussion here:

OAI/OpenAPI-Specification#1313

We'd have to post-process it on, similar to what you are doing with watch, or add an Enum to the swagger spec.

@qmfrederik
Copy link
Contributor Author

#152 fixed this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants