huma icon indicating copy to clipboard operation
huma copied to clipboard

Handling of custom types for List inputs of query params

Open mvrahden opened this issue 3 weeks ago • 0 comments

So currently huma supports list inputs for input parameters of query type.

However, the support seems to be limited to []string-type only. It would be handy to have the support of string-serializable custom types in order to not perform the type parsing and mapping manually.

One example:

// LicensesListFilterInput represents the list filter to match licenses.
type LicensesListFilterInput struct {
	LicenseIDs []uuid.UUID `query:"ids" required:"false" example:"a60a4a7e-33bb-4337-a72c-d33aa195936e,5b50ae19-f590-4921-871d-2ab6005a7335,35ed2d12-50d7-4939-bd54-5146e6416797"`
	// ...
}

Is there an easy way to achieve this?

Supporting the UnmarshalText(data []byte) error interface would be sufficient to support a wide range of types.

mvrahden avatar Jun 24 '24 11:06 mvrahden