Update github.com/danielgtaylor/huma/v2 to v2.39.0
This MR contains the following updates:
| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| github.com/danielgtaylor/huma/v2 | require | minor | v2.38.0 -> v2.39.0 |
v2.39.1 |
MR created with the help of gitlab-org/frontend/renovate-gitlab-bot
Release Notes
danielgtaylor/huma (github.com/danielgtaylor/huma/v2)
v2.39.0
v2.39.0
Overview
This release adds a new framework adapter, a handful of developer-facing features, and a large batch of correctness fixes spanning SSE, the Fiber adapter, schema generation, and validation.
Echo v5 Support
The humaecho adapter now supports Echo v5 alongside the existing versions. (#959)
No More Faulty Duplicate-Schema Panics
Registering operations that use inline structs with differing field names (and an empty operation ID) previously panicked at startup on a false-positive duplicate-schema collision. Conflicting names are now auto-incremented deterministically (Request, Request1, Request2, ...), so the app starts and the generated spec stays readable. (#893)
Context Propagation to Adapters
WithContext now propagates the context directly into the underlying adapter's own context wrapper (bun, chi, echo, fiber, gin, go, httprouter) instead of relying on a generic sub-context, so cancellation and context values flow correctly through the request lifecycle. (#867)
SSE Streaming on Fiber / fasthttp
Server-Sent Events (and other streaming responses) previously failed on the Fiber adapters with unable to flush, since fasthttp doesn't implement http.Flusher. SSE now streams correctly on Fiber v2 and v3 via an internal streaming hook, with no new public API and fasthttp remaining an indirect dependency. (#1059)
More SSE Improvements
- Response headers are now flushed before the user handler runs, so
EventSource.onopenfires immediately rather than waiting for the first event (#1038) - Comments can now be sent over SSE streams, a common way to keep connections alive (#1054)
New Features
Schema.Constfor pinning a schema to a single allowed value (#1004)- Customizable docs renderer config for finer control over the documentation UI (#1024)
encoding.TextUnmarshalersupport for slice query parameters, matching the existing behavior for scalar params (#1021)- Non-file JSON form-data fields: multipart form fields tagged
contentType:"application/json"are now unmarshalled and validated (#1060)
Validation & Schema Fixes
- Integer enums no longer always fail validation on query/path parameters; numeric enum values are now compared numerically rather than by strict Go type (#1050)
- Content-Type validation is now case-insensitive per RFC 9110, so e.g.
Application/Jsonno longer returns415(#1052) - Path parameters are always marked
required: truein the generated spec, per the OpenAPI specification (#1011) - Prevented a panic (and dropped response) in
uniqueItemsvalidation when array items are unhashable types, now returning422correctly (#1045) - The
json:",inline"tag is now honored for embedding anonymous fields in schemas (#1006) - Hidden route schemas are no longer leaked into the generated spec (#1032)
Adapter & Robustness Fixes
- humafiber (v2): corrected
EachHeaderiteration (it previously invoked the callback once per byte, breaking cookie reads) and switchedBodyReadertoBody()for automatic request-body decompression (#1058) - autopatch: prevented chi route-context reuse from recursing internal
GETsub-requests back into the generatedPATCHhandler and panicking (#1049) - Fixed a URL parsing panic in
getAPIPrefixwhen server URLs contain template variables like{port}or{version}(#1027) - The read deadline is now cleared after the request body is read, so a slow handler can't cause a background read to time out and cancel the connection context (#1028)
Docs UI & Documentation
- Forms are now permitted in the docs UI CSP (#1036)
- Added
allow-downloadsto the Stoplight CSP so the Export button works (#1048) - Updated Restish references to v2 (#1041)
What's Changed
- Avoid leaking hidden route schemas by @wolveix in https://github.com/danielgtaylor/huma/pull/1032
- fix: parse server vars on getAPIPrefix to avoid parsing URL panic by @kukymbr in https://github.com/danielgtaylor/huma/pull/1027
- Add
encoding.TextUnmarshalersupport for slice query parameters by @B94715 in https://github.com/danielgtaylor/huma/pull/1021 - fix: enforce required=true for path parameters per OpenAPI spec by @Yanhu007 in https://github.com/danielgtaylor/huma/pull/1011
- huma: clear read deadline on reading by @atn18 in https://github.com/danielgtaylor/huma/pull/1028
- feat: support customizing the docs renderer config by @johnletey in https://github.com/danielgtaylor/huma/pull/1024
- feat: add Schema.Const by @seanwu1105 in https://github.com/danielgtaylor/huma/pull/1004
- Permit forms in docs UI CSP by @wolveix in https://github.com/danielgtaylor/huma/pull/1036
- fix(sse): flush response headers before user handler runs by @alswl in https://github.com/danielgtaylor/huma/pull/1038
- docs: update Restish v2 references by @danielgtaylor in https://github.com/danielgtaylor/huma/pull/1041
- fix: add 'allow-downloads' to CSP for stoplight by @ovikk13 in https://github.com/danielgtaylor/huma/pull/1048
- Echov5 support by @sharath-09 in https://github.com/danielgtaylor/huma/pull/959
- fix(autopatch): prevent chi route-context reuse in internal requests by @wolveix in https://github.com/danielgtaylor/huma/pull/1049
- fix: support json inline tag for embedding anonymous fields in schema by @lsdch in https://github.com/danielgtaylor/huma/pull/1006
- fix: compare numeric enum values numerically by @wolveix in https://github.com/danielgtaylor/huma/pull/1050
- fix: content type validation should be case insensitive by @hlavacekvit in https://github.com/danielgtaylor/huma/pull/1052
- fix(humafiber): correct Fiber v2 EachHeader iteration and body decompression by @wolveix in https://github.com/danielgtaylor/huma/pull/1058
- feat: propagate context to adapters on WithContext by @costela in https://github.com/danielgtaylor/huma/pull/867
- Support sending comments with SSE by @seanwu1105 in https://github.com/danielgtaylor/huma/pull/1054
- fix(sse): support streaming responses on Fiber/fasthttp adapters by @wolveix in https://github.com/danielgtaylor/huma/pull/1059
- fix: prevent panic in uniqueItems validation for unhashable types (#1042) by @ArdyJunata in https://github.com/danielgtaylor/huma/pull/1045
- fix: avoid faulty duplicate detection by @Mcklmo in https://github.com/danielgtaylor/huma/pull/893
- feat(form-data): handle unmarshalling and validation of non-file JSON form data fields by @lsdch in https://github.com/danielgtaylor/huma/pull/1060
New Contributors
- @kukymbr made their first contribution in https://github.com/danielgtaylor/huma/pull/1027
- @B94715 made their first contribution in https://github.com/danielgtaylor/huma/pull/1021
- @Yanhu007 made their first contribution in https://github.com/danielgtaylor/huma/pull/1011
- @atn18 made their first contribution in https://github.com/danielgtaylor/huma/pull/1028
- @johnletey made their first contribution in https://github.com/danielgtaylor/huma/pull/1024
- @seanwu1105 made their first contribution in https://github.com/danielgtaylor/huma/pull/1004
- @alswl made their first contribution in https://github.com/danielgtaylor/huma/pull/1038
- @ovikk13 made their first contribution in https://github.com/danielgtaylor/huma/pull/1048
- @sharath-09 made their first contribution in https://github.com/danielgtaylor/huma/pull/959
- @hlavacekvit made their first contribution in https://github.com/danielgtaylor/huma/pull/1052
- @ArdyJunata made their first contribution in https://github.com/danielgtaylor/huma/pull/1045
- @Mcklmo made their first contribution in https://github.com/danielgtaylor/huma/pull/893
Full Changelog: https://github.com/danielgtaylor/huma/compare/v2.38.0...v2.39.0
Configuration
- If you want to rebase/retry this MR, check this box
This MR has been generated by Renovate Bot.