From f8f175bc53ffa9b16b447679c663373c107ec4c4 Mon Sep 17 00:00:00 2001 From: ddl-ebrown Date: Thu, 19 Sep 2024 15:20:15 -0700 Subject: [PATCH] Fix unsupported param type url.URL --- huma.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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.