From 8ad7aedb3e4861d5035ac14b55f5c53919e068a6 Mon Sep 17 00:00:00 2001 From: Benyamin Beyzaie Date: Thu, 9 Feb 2023 11:14:07 +0330 Subject: [PATCH] fix generated client code cannot convert UUIDs to string when used as path parameters. --- pkg/runtime/styleparam.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/runtime/styleparam.go b/pkg/runtime/styleparam.go index 8f7e12927a..06b2e2506e 100644 --- a/pkg/runtime/styleparam.go +++ b/pkg/runtime/styleparam.go @@ -27,6 +27,7 @@ import ( "time" "github.com/deepmap/oapi-codegen/pkg/types" + "github.com/google/uuid" ) // Parameter escaping works differently based on where a header is found @@ -428,6 +429,10 @@ func primitiveToString(value interface{}) (string, error) { case reflect.Struct: // If input has Marshaler, such as object has Additional Property or AnyOf, // We use this Marshaler and convert into interface{} before styling. + if v, ok := value.(uuid.UUID); ok { + output = v.String() + break + } if m, ok := value.(json.Marshaler); ok { buf, err := m.MarshalJSON() if err != nil {