-
Notifications
You must be signed in to change notification settings - Fork 41
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
Running codegen against server-provided swagger spec #38
Comments
Tried to tackle with that recently; set
I've tried to modify
Any ideas how to implement support for anonymous types? |
Depends. Share your |
Also, if the only reason you're attempting this is to get CRUD API for your CRD, you may want to just use k8s-openapi-derive instead. (Read the docs from the source because docs.rs is still broken for proc-macro crates.) |
Unfortunately, that's not mine CRD. Those came from cert-manager: https://github.com/jetstack/cert-manager/blob/v0.11.0/deploy/manifests/00-crds.yaml#L29 "metadata": {
"description": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta_v2"
} while others put all def into I think one can try to construct the appropriate ListMeta struct dynamically or find already defined |
I'm surprised that Kubernetes is inlining the defintion like that instead of using a It's worth testing if it does that for all CRDs, eg for the one in this repo's test.
Replacing it with a |
Might be wrong, looks like when custom resource is described in code and uses kubebuilder to generate yamls it can also be annotated to generate openapi spec (haven’t yet looked how the generated openapi spec gets into k8s) via |
So in 4c55b81 I've implemented emitting lists as aliases of a single Currently it believes anything with an |
I use |
@wdv4758h Can you share how you did that? |
I think it would be super valuable to generate custom API bindings. |
@ibotty It was years ago, I don't have the source code of the hack version anymore. And I forgot the real steps. IIRC, what I did was:
|
k8s-openapi/k8s-openapi-codegen/src/main.rs Lines 125 to 143 in 5a079ad
/openapi/v2 endpoint or to a pre-downloaded spec file using an arbitrary version string for the parameter name and see how usable the output is.
|
The API server exposes its spec at
/openapi/v2
Is it worth allowing a user to run
k8s-openapi-codegen
against this endpoint to generate a custom API bindings crate?Edit: Starting with v1.15, CRDs are also included in the spec:
The text was updated successfully, but these errors were encountered: