Skip to content

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

@ebauman

Description

@ebauman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions