diff --git a/huma.go b/huma.go index 32e075f8..21d8725f 100644 --- a/huma.go +++ b/huma.go @@ -16,6 +16,7 @@ import ( "io" "net" "net/http" + "net/url" "reflect" "regexp" "slices" @@ -1127,6 +1128,16 @@ func Register[I, O any](api API, op Operation, handler func(context.Context, *I) f.Set(reflect.ValueOf(t)) pv = value break + // Special case: url.URL + } else if f.Type() == urlType { + u, err := url.Parse(value) + if err != nil { + res.Add(pb, value, "invalid url.URL value") + return + } + f.Set(reflect.ValueOf(*u)) + pv = value + break } // Last resort: use the `encoding.TextUnmarshaler` interface.