Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1961 from njhale/fix/events-mfe
Browse files Browse the repository at this point in the history
Fix openapi schema generation for event fields
  • Loading branch information
njhale authored Jul 21, 2023
2 parents 86de32e + 5bdcf96 commit 300660d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
20 changes: 20 additions & 0 deletions pkg/apis/internal.acorn.io/v1/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ func NowMicro() MicroTime {
return NewMicroTime(time.Now())
}

// OpenAPISchemaType is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
//
// See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
func (_ MicroTime) OpenAPISchemaType() []string { return []string{"string"} }

// OpenAPISchemaFormat is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
func (_ MicroTime) OpenAPISchemaFormat() string { return "date-time" }

// DeepCopyInto returns a deep-copy of the MicroTime value. The underlying time.Time
// type is effectively immutable in the time API, so it is safe to
// copy-by-assign, despite the presence of (unexported) Pointer fields.
Expand Down Expand Up @@ -110,6 +120,16 @@ func (t *MicroTime) UnmarshalJSON(b []byte) error {
return nil
}

// MarshalJSON implements the json.Marshaler interface.
func (t MicroTime) MarshalJSON() ([]byte, error) {
if t.IsZero() {
// Encode unset/nil objects as JSON's "null".
return []byte("null"), nil
}

return json.Marshal(t.UTC().Format(metav1.RFC3339Micro))
}

const (
// EventSeverityInfo indicates an event describes a system operating "as expected".
EventSeverityInfo EventSeverity = "info"
Expand Down
28 changes: 10 additions & 18 deletions pkg/openapi/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/openapi/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
result := generated.GetOpenAPIDefinitions(ref)
for _, v := range result {
for name := range v.Schema.SchemaProps.Properties {
if name == "deployArgs" || name == "buildArgs" || name == "params" {
if name == "deployArgs" || name == "buildArgs" || name == "params" || name == "details" {
v.Schema.SchemaProps.Properties[name] = spec.Schema{
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
Expand Down

0 comments on commit 300660d

Please sign in to comment.