Skip to content

v2.11.0

Compare
Choose a tag to compare
@danielgtaylor danielgtaylor released this 01 Apr 15:30
· 218 commits to main since this release
ee299ec

Overview

Sponsors

Big shout out to our new sponsors. Thank you so much! ❤️

Stoplight Elements 8.1.0

Stoplight Elements is upgraded to the latest release, version 8.1.0.

Fix omitempty Without Name

Providing a JSON tag without a name but with ,omitempty would result in fields without a name. This is now fixed and uses the same behavior as encoding/json.

type Demo struct {
  Field string `json:",omitempty"`
}

The field name would then be Field in the JSON.

Route Groups & Servers Base Path

There is now better support for route groups in various routers, as well as smart routing for fetching the OpenAPI / JSON schemas when the OpenAPI servers field is set with a base path.

mux := chi.NewMux()
mux.Route("/api", func(r chi.Router) {
	config := huma.DefaultConfig("My API", "1.0.0")
	config.Servers = []*huma.Server{
		{URL: "https://example.com/api"},
	}
	api = humachi.New(r, config)

	// Register operations...
	huma.Get(api, "/demo", func(ctx context.Context, input *struct{}) (*struct{}, error) {
		// TODO: Implement me!
		return nil, nil
	})
})
http.ListenAndServe("localhost:8888", mux)

More docs at https://huma.rocks/features/bring-your-own-router/#route-groups-base-urls.

Schema Field Example

The generated $schema field now shows an example in the docs to help make it easy to see the JSON schema path on the server.

Docs Page Title

If an OpenAPI title is provided, then the docs page title will use it now.

What's Changed

New Contributors

Full Changelog: v2.10.0...v2.11.0