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

Wrangler CRD schema generation incorrectly identifies MicroTime as object in resulting openapi spec #513

Open
ebauman opened this issue Jan 29, 2025 · 2 comments · May be fixed by #514
Open

Comments

@ebauman
Copy link

ebauman commented Jan 29, 2025

Scenario:

You have a new type, say Foo. Defined as such:

type Foo struct {
... // objectMeta, typeMeta
EventTime *metav1.MicroTime `json:"eventTime"`
}

Now, you run this type through Wrangler's provided ToOpenAPIFromStruct as seen in

func ToOpenAPIFromStruct(obj interface{}) (*v1.JSONSchemaProps, error) {

Wrangler incorrectly spits out an OpenAPI schema in which the MicroTime is stored as an object. It should be stored as a string, similar to how metav1.Time is stored.

The problem is in reflection.go,

case reflect.Struct:
if t.Name() == "Time" {
return "date", nil
}

Time is correctly compensated for, but not MicroTime.

@ebauman ebauman linked a pull request Jan 29, 2025 that will close this issue
@ebauman
Copy link
Author

ebauman commented Jan 29, 2025

It is a valid workaround to define a wrangler:"type=string" tag on the field, but let's fix it at the source, yeah? :)

@ericpromislow
Copy link
Contributor

ericpromislow commented Jan 29, 2025



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

Successfully merging a pull request may close this issue.

2 participants