Skip to content

v2.19.0

Compare
Choose a tag to compare
@danielgtaylor danielgtaylor released this 15 Jul 16:46
· 130 commits to main since this release
9bf5661

Overview

Sponsors

A big thank you to our new sponsor:

Multipart Form File Metadata

It's now possible to get filename & size metadata information from multipart form files.

huma.Post(api, "/form-example", func(ctx context.Context, input *struct{
	RawBody huma.MultipartFormFiles[struct {
		HelloWorld   huma.FormFile   `form:"file" contentType:"text/plain" required:"true"`
	}]
}) (*struct{}, error) {
 	fileData := input.RawBody.Data()
	fmt.Println( fileData.HelloWorld.Filename)
	fmt.Println( fileData.HelloWorld.Size)
}

Easier Custom Context When Testing

It's now easier to pass a custom context to operations in the test API. Instead of having to create a custom request with its own context and manually call the adapter you can now use the methods like GetCtx instead of Get.

_, api := humatest.New(t)
ctx := context.Background() // define your necessary context
resp := api.GetCtx(ctx, "/greeting/world") // provide it using the 'Ctx' suffixed methods

Exploded Query Params

It's now possible to use the OpenAPI explode feature where query params are passed multiple times rather than using comma separated values.

huma.Get(api, "/example", func(ctx context.Context, input *struct{
	Value []string `query:"value,explode"`
}) (*struct{}, error) {
	fmt.Println(input.Value)
	return nil, nil
})

You can then make requests like GET /example?value=foo&value=bar.

Autopatch Schema Improvements

Autopatch now uses the PUT schema (modified to all be optional) rather than just relying on an object with any allowed properties, which improves documentation for users. This is automatic so there is no need to configure anything new.

Other Improvements

  • Performance improvement by removing the response body from panics which could be very large.
  • Fixes to min/max items schema generation when using arrays.
  • Remove slices dependency to continue to support Go 1.20 until 1.23 is released (we will support the latest two major versions just like the Go project itself)

What's Changed

New Contributors

Full Changelog: v2.18.0...v2.19.0