I am generating Kubernetes CRD (Custom Resource Definition) using kubebuilder. Along with CRD, I also need to document the REST endpoints by creating OpenAPI v3 Spec (OAS) file. Is there a way to get this done using kubebuilder? Also does kubebuilder allow us to add sample Request/Response payload details in the .go file so that the generated OAS file is more user friendly?
One option I found is to use curl :/openapi/v3, but maintaining the spec file manually is not sustainable. I want to use kubebuilder generated .go spec file as one source of truth. Any suggestion?
Seems to be there is no intended way to generate openapi files. As per this Git Link comment by DirectXMan12 :
You can also refer to this Git linkcomment and doc for further information .
Edit : Kubebuilder is generating only CRD and by using controller gen can generate an open API but kubebuilder is still not intended to generate open api. You can use other third party tools like mentioned in this document by Vyom Srivastava.