Skip to content

Commit

Permalink
Fix unsupported param type url.URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-ebrown committed Sep 19, 2024
1 parent 69d32c3 commit f8f175b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions huma.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"io"
"net"
"net/http"
"net/url"
"reflect"
"regexp"
"slices"
Expand Down Expand Up @@ -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

Check warning on line 1136 in huma.go

View check run for this annotation

Codecov / codecov/patch

huma.go#L1133-L1136

Added lines #L1133 - L1136 were not covered by tests
}
f.Set(reflect.ValueOf(*u))
pv = value
break

Check warning on line 1140 in huma.go

View check run for this annotation

Codecov / codecov/patch

huma.go#L1138-L1140

Added lines #L1138 - L1140 were not covered by tests
}

// Last resort: use the `encoding.TextUnmarshaler` interface.
Expand Down

0 comments on commit f8f175b

Please sign in to comment.