Skip to content

How to do custom binding for uuid? #85

Description

@sberryman

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"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions