Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do custom binding for uuid? #85

Open
sberryman opened this issue Apr 23, 2022 · 0 comments
Open

How to do custom binding for uuid? #85

sberryman opened this issue Apr 23, 2022 · 0 comments

Comments

@sberryman
Copy link

sberryman commented Apr 23, 2022

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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant