gadgeto
gadgeto copied to clipboard
How to do custom binding for uuid?
Type: https://pkg.go.dev/github.com/google/uuid
Sample struct:
type ProjectByIdWire struct {
Id uuid.UUID `path:"id"`
}
I would like to change the default binding for that type to use Parse(s string) (UUID, error)
https://github.com/google/uuid/blob/v1.3.0/uuid.go#L64
Unfortunately I'm not sure how to do this. I'm using Fizz as well and changing the data type for the schema was straight forward:
fizz.Generator().OverrideDataType(reflect.TypeOf(&uuid.UUID{}), "string", "uuid")
The error I get when trying to bind using the defaults
{
"error": "binding error on field 'Id' of type 'ProjectByIdWire': parameter expect 16 values, got 1"
}