From d8df1bdac2f9f4ddd00eabd39754d58e6ddc5e07 Mon Sep 17 00:00:00 2001 From: Hein Date: Mon, 5 Jan 2026 17:56:54 +0200 Subject: [PATCH] =?UTF-8?q?feat(funcspec):=20=E2=9C=A8=20add=20JSON=20and?= =?UTF-8?q?=20UUID=20handling=20in=20normalization=20*=20Enhance=20normali?= =?UTF-8?q?zation=20to=20support=20JSON=20strings=20as=20json.RawMessage?= =?UTF-8?q?=20*=20Add=20support=20for=20UUID=20formatting=20*=20Maintain?= =?UTF-8?q?=20existing=20behavior=20for=20other=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/funcspec/function_api.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pkg/funcspec/function_api.go b/pkg/funcspec/function_api.go index 6d6328d..ffa7ec1 100644 --- a/pkg/funcspec/function_api.go +++ b/pkg/funcspec/function_api.go @@ -12,6 +12,8 @@ import ( "strings" "time" + "github.com/google/uuid" + "github.com/bitechdev/ResolveSpec/pkg/common" "github.com/bitechdev/ResolveSpec/pkg/logger" "github.com/bitechdev/ResolveSpec/pkg/restheadspec" @@ -1099,9 +1101,25 @@ func normalizePostgresValue(value interface{}) interface{} { case map[string]interface{}: // Recursively normalize nested maps return normalizePostgresTypes(v) - + case string: + var jsonObj interface{} + if err := json.Unmarshal([]byte(v), &jsonObj); err == nil { + // It's valid JSON, return as json.RawMessage so it's not double-encoded + return json.RawMessage(v) + } + return v + case uuid.UUID: + return v.String() + case time.Time: + return v.Format(time.RFC3339) + case bool, int, int8, int16, int32, int64, float32, float64, uint, uint8, uint16, uint32, uint64: + return v default: - // For other types (int, float, string, bool, etc.), return as-is + // For other types (int, float, bool, etc.), return as-is + // Check stringers + if str, ok := v.(fmt.Stringer); ok { + return str.String() + } return v } }