buehler / dotnet-operator-sdk

KubeOps is a kubernetes operator sdk in dotnet. Strongly inspired by kubebuilder.
https://buehler.github.io/dotnet-operator-sdk/
Apache License 2.0
236 stars 64 forks source link

[feature]: JsonSchema.Net.Generation for openapi schema generation? #748

Open SGStino opened 5 months ago

SGStino commented 5 months ago

Is your feature request related to a problem? Please describe.

Currently, the schema generation is limited to what is implemented,

Issues like https://github.com/buehler/dotnet-operator-sdk/issues/741, https://github.com/buehler/dotnet-operator-sdk/issues/396, https://github.com/buehler/dotnet-operator-sdk/issues/351 could possibly benefit from this

Describe the solution you would like

It would be nice to team up with a schema generator library and outsource those capabilities to generate the OpenApiV3 spec.

JsonSchema.Net offers JsonSchema with customizable keywords and validation on JsonNodes. JsonSchema.Net.Generation can generate schemas from C# classes with reflection (for use in KubeOps.Cli?)

Additional Context

No response

buehler commented 5 months ago

Hey @SGStino

That's a good idea! As long as there are possibilities to add the special "x-kubernetes" attributes, we should be good to go. According to the docs of Kubernetes, they use openapi v3 and as such, we could use a lib for that.

SGStino commented 5 months ago

The library supports adding custom vocabulary, so the x-kubernetes should be implemented as those.

I'll see if I can bash something together as reference so you can see how to fit it in the operator?

buehler commented 5 months ago

That would be amazing! Thank you :-)

SGStino commented 5 months ago

https://github.com/SGStino/JsonSchemaTest

If you have any real-life examples of entities we can test against? Just to see what comes out, then we can figure out if anything works different or not at all.

buehler commented 5 months ago

Hey @SGStino Thanks :-)

Sadly - no. Since I made this SDK, I've only written one operator (weird, I know).

But maybe other contributors can provide some real world examples.