diff --git a/pkg/runtime/styleparam.go b/pkg/runtime/styleparam.go index ae2f33b2d..6c01def1b 100644 --- a/pkg/runtime/styleparam.go +++ b/pkg/runtime/styleparam.go @@ -382,7 +382,12 @@ func primitiveToString(value interface{}) (string, error) { case reflect.String: output = v.String() default: - return "", fmt.Errorf("unsupported type %s", reflect.TypeOf(value).String()) + v, ok := value.(fmt.Stringer) + if !ok { + return "", fmt.Errorf("unsupported type %s", reflect.TypeOf(value).String()) + } + + output = v.String() } return output, nil } diff --git a/pkg/runtime/styleparam_test.go b/pkg/runtime/styleparam_test.go index 821c1a90b..ff7e52d7c 100644 --- a/pkg/runtime/styleparam_test.go +++ b/pkg/runtime/styleparam_test.go @@ -629,6 +629,11 @@ func TestStyleParam(t *testing.T) { assert.NoError(t, err) assert.EqualValues(t, "1.05", result) + uuidValue := uuid.MustParse("c2d07ba4-5106-4eab-bcad-0bd6068dcb1a") + result, err = StyleParamWithLocation("simple", false, "foo", ParamLocationQuery, types.UUID(uuidValue)) + assert.NoError(t, err) + assert.EqualValues(t, "c2d07ba4-5106-4eab-bcad-0bd6068dcb1a", result) + // Test that we handle optional fields type TestObject2 struct { FirstName *string `json:"firstName"`