From 2f96c132143323ee468c1edb9a2d9e6bb89dd71f Mon Sep 17 00:00:00 2001 From: Timo Riski Date: Fri, 9 Feb 2024 11:00:39 +0200 Subject: [PATCH] fix: time unmarshalling --- generator/main.go | 1 + generator/models.go | 5 +++-- handler/project/project.go | 12 ++++++------ handler/service/service.go | 12 ++++++------ handler/serviceuser/serviceuser.go | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/generator/main.go b/generator/main.go index 2144b82..1dfc963 100644 --- a/generator/main.go +++ b/generator/main.go @@ -315,6 +315,7 @@ func exec() error { } ifErr := jen.If(jen.Err().Op("!=").Nil()).Block(returnErr) + if rsp == nil { block = append(block, jen.Return(jen.Err())) } else { diff --git a/generator/models.go b/generator/models.go index 18c68f3..81119f7 100644 --- a/generator/models.go +++ b/generator/models.go @@ -204,8 +204,9 @@ func (s *Schema) init(doc *Doc, scope map[string]*Schema, name string) { if s.Type == SchemaTypeString { parts := strings.Split(s.name, "_") - switch parts[len(parts)-1] { - case "at", "time": + suffix := parts[len(parts)-1] + + if len(parts) > 1 && (suffix == "at" || suffix == "time") { s.Type = SchemaTypeTime } } diff --git a/handler/project/project.go b/handler/project/project.go index 3096360..20554d9 100644 --- a/handler/project/project.go +++ b/handler/project/project.go @@ -365,12 +365,12 @@ type EndOfLifeExtensionOut struct { Elasticsearch *ElasticsearchOut `json:"elasticsearch,omitempty"` } type EventOut struct { - Actor string `json:"actor"` - EventDesc string `json:"event_desc"` - EventType string `json:"event_type"` - Id string `json:"id"` - ServiceName string `json:"service_name"` - Time time.Time `json:"time"` + Actor string `json:"actor"` + EventDesc string `json:"event_desc"` + EventType string `json:"event_type"` + Id string `json:"id"` + ServiceName string `json:"service_name"` + Time string `json:"time"` } type GroupUserOut struct { MemberType string `json:"member_type"` diff --git a/handler/service/service.go b/handler/service/service.go index 4a9ea37..bffb590 100644 --- a/handler/service/service.go +++ b/handler/service/service.go @@ -678,17 +678,17 @@ type ListPublicServiceTypesOut struct { Any *AnyOut `json:"ANY,omitempty"` } type LogOut struct { - Msg string `json:"msg"` - Time *time.Time `json:"time,omitempty"` - Unit string `json:"unit,omitempty"` + Msg string `json:"msg"` + Time string `json:"time,omitempty"` + Unit string `json:"unit,omitempty"` } type MaintenanceIn struct { - Dow DowType `json:"dow,omitempty"` - Time *time.Time `json:"time,omitempty"` + Dow DowType `json:"dow,omitempty"` + Time string `json:"time,omitempty"` } type MaintenanceOut struct { Dow string `json:"dow"` - Time time.Time `json:"time"` + Time string `json:"time"` Updates []UpdateOut `json:"updates"` } type MetadataOut struct { diff --git a/handler/serviceuser/serviceuser.go b/handler/serviceuser/serviceuser.go index 157bc9b..30337d8 100644 --- a/handler/serviceuser/serviceuser.go +++ b/handler/serviceuser/serviceuser.go @@ -178,7 +178,7 @@ type IntegrationStatusOut struct { } type MaintenanceOut struct { Dow string `json:"dow"` - Time time.Time `json:"time"` + Time string `json:"time"` Updates []UpdateOut `json:"updates"` } type MetadataOut struct {