这是indexloc提供的服务,不要输入任何密码
Skip to content

v2.33.0

Compare
Choose a tag to compare
@danielgtaylor danielgtaylor released this 23 Jun 04:40
· 9 commits to main since this release
e5fa153

Overview

Minimum Go Version Upgrade

Go 1.23+ is now required, keeping to the "last two versions" approach that Go itself uses for support. Dependencies have also been upgraded, including a few dependabots for security issues.

Explicitly Set Empty Example

You can now explicitly set empty example strings:

type MyInput struct {
	MyField string `json:"my_field" example:""`
}

Empty Group Path

It's now possible to use operations on a group with an empty path, having the operation use the group's path without any additions:

grp := huma.NewGroup(api, "/users")

huma.Get(grp, "", func(ctx context.Context, input *struct{}) (*struct{}, error) {
	return nil, nil
})

Adapter Context Unwrapping Fixes

You can now use huma.WithValue and huma.WithContext to wrap a context and the adapter-specific Unwrap function will no longer panic.

subctx := huma.WithValue(ctx, key, "value")
r, w := humago.Unwrap(subctx)

Nested CLI Options

Nested CLI options via structs are now supported.

type DatabaseConfig struct {
    Host     string `doc:"Database host"`
    Port     int    `doc:"Database port" default:"5432"`
    Username string `doc:"Database username"`
}

type AppConfig struct {
    Debug bool            `doc:"Enable debug mode"`
    DB    *DatabaseConfig `doc:"Database configuration"` // Here both ptr or direct would have been acceptable.
}

Results in options like --db.host localhost and --db.port 5432.

Other

Various other fixes and feature improvements. Thanks everyone!

What's Changed

  • fix: Allow explicitely setting the "example" tag to the empty string by @mumu1000 in #773
  • chore(docs): add link to IANA auth schemes by @costela in #774
  • minor: use ErrUnknownContentType in more places by @costela in #799
  • Fix panic when sending an empty file field in a form by @Supet1337 in #785
  • Add WithIndex to PathBuffer by @chrisguitarguy in #788
  • fix: make order of SSE events stable in openapi by @culli in #806
  • Allow empty path in group operations by @Serjlee in #807
  • feat: Go 1.23 minimum, modernize codebase by @danielgtaylor in #820
  • Add option to customize the Gorilla Mux route by @RangelReale in #810
  • Make autopatch merge-patch work with nullable fields by @betaprior in #791
  • Incorrect import path for autopatch by @byronmurg in #838
  • add Japanese README (README_JA.md) by @SoraDaibu in #836
  • feat: add humagin.NewContext by @bbedward in #837
  • fix: linter issues by @danielgtaylor in #842
  • feature: improve default response status flow for head method by @hiddenmarten in #830
  • chore(deps): bump github.com/gofiber/fiber/v2 from 2.52.6 to 2.52.7 by @dependabot in #827
  • Fix adapter.Unwrap() not working after huma.WithContext() by @Serjlee in #829
  • Fix: Support for nested pointer struct fields in CLI options by @tomMoulard in #824
  • fix: export of embed properties when struct type is not exported by @iamnoah in #822
  • Unescape path values in chi adapter by @Serjlee in #821
  • chore(deps): bump github.com/go-chi/chi/v5 from 5.1.0 to 5.2.2 in /examples by @dependabot in #845
  • chore(deps): bump github.com/go-chi/chi/v5 from 5.2.1 to 5.2.2 by @dependabot in #846
  • Potential fix for code scanning alert no. 5: Workflow does not contain permissions by @danielgtaylor in #847
  • Revert "fix: export of embed properties when struct type is not exported" by @danielgtaylor in #848

New Contributors

Full Changelog: v2.32.0...v2.33.0