Skip to content

Commit dada8da

Browse files
fix generated client code cannot convert UUIDs to string when used as path parameters. (#956)
1 parent b0bb99b commit dada8da

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

styleparam.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"time"
2828

2929
"github.com/deepmap/oapi-codegen/pkg/types"
30+
"github.com/google/uuid"
3031
)
3132

3233
// Parameter escaping works differently based on where a header is found
@@ -428,6 +429,10 @@ func primitiveToString(value interface{}) (string, error) {
428429
case reflect.Struct:
429430
// If input has Marshaler, such as object has Additional Property or AnyOf,
430431
// We use this Marshaler and convert into interface{} before styling.
432+
if v, ok := value.(uuid.UUID); ok {
433+
output = v.String()
434+
break
435+
}
431436
if m, ok := value.(json.Marshaler); ok {
432437
buf, err := m.MarshalJSON()
433438
if err != nil {

0 commit comments

Comments
 (0)