-
Notifications
You must be signed in to change notification settings - Fork 222
Add OpenAPIModelNamer and opt-in generator support #537
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpbetz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @Jefftree |
@@ -339,8 +343,18 @@ func (g openAPITypeWriter) generateCall(t *types.Type) error { | |||
// Only generate for struct type and ignore the rest | |||
switch t.Kind { | |||
case types.Struct: | |||
if namer.IsPrivateGoName(t.Name.Name) { // skip private types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you encounter one of these types or is this just precautionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int64Amount
is leaking out from quantity into pkg/generated/openapi/zz_generated.openapi.go
. A grep will show this. runtime.Object
also shows up in that file.
/lgtm in case you want additional eyes |
This enables kube-openapi to use model names defined by the models instead of the
<go-package>.<go-type-name>
of the Go structs that defines the model.This is entirely opt-in. Existing behavior is retained.
openapi-gen
users may opt-in with the--use-openapi-model-names
.Models may opt-in by implementing the
OpenAPIModelNamer
interface introduced by this change:For example:
When used, the "canonical type names" and "REST friendly names" are the same model name.
This is simpler than the existing behavior where the name formats differ needlessly require conversion:
k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1.CustomResourceDefinition
io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.CustomResourceDefinition