Skip to content

Adds support for slice query parameters using ParamWrapper types#998

Open
sharonjl wants to merge 3 commits intodanielgtaylor:mainfrom
sharonjl:main
Open

Adds support for slice query parameters using ParamWrapper types#998
sharonjl wants to merge 3 commits intodanielgtaylor:mainfrom
sharonjl:main

Conversation

@sharonjl
Copy link
Copy Markdown

Adds support for slice query parameters using ParamWrapper types (e.g., []OptionalParam[int]). Previously,
parseSliceInto only handled primitive slice element kinds. Struct elements implementing ParamWrapper were
returned as errUnparsable.

Changes

  • Added parseArrStructElement helper that unwraps each slice element's ParamWrapper.Receiver() and
    delegates per-element parsing to parseInto, supporting all receiver types including time.Time, url.URL,
    and TextUnmarshaler
  • Added case reflect.Struct to parseSliceInto switch for ParamWrapper-implementing struct elements
  • Threaded ctx and paramFieldInfo through parseSliceInto so the struct case can call parseInto directly
  • ParamReactor.OnParamSet is called per element when implemented, with the unwrapped parsed value matching
    scalar behavior

I am a little unsure of the reflect unwrapping but there doesn't seem to be another approach other than implementing TextMarshal/Unmarshal to support slice query params of type struct.

@sharonjl sharonjl changed the title Support ParamWrapper types and improve slice length assertions Adds support for slice query parameters using ParamWrapper types Mar 12, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.06%. Comparing base (1d5dddf) to head (558f466).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
huma.go 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #998      +/-   ##
==========================================
- Coverage   93.13%   93.06%   -0.07%     
==========================================
  Files          23       23              
  Lines        4777     4801      +24     
==========================================
+ Hits         4449     4468      +19     
- Misses        269      272       +3     
- Partials       59       61       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant