v2.11.0
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
- docs: add sponsors; add dark mode images by @danielgtaylor in #335
- docs: API documentation customization by @danielgtaylor in #336
- feat: upgrade to Stoplight Elements 8.1.0 by @danielgtaylor in #339
- fix: update docs page copyright to 2024 by @danielgtaylor in #340
- fix: support fields with ,omitempty but no name by @danielgtaylor in #341
- feat: support OpenAPI servers base path & router groups by @danielgtaylor in #338
- feat: add example to $schema links by @danielgtaylor in #343
- feat: use config.Info.Title as the page title in the API docs by @nstapelbroek in #346
New Contributors
- @nstapelbroek made their first contribution in #346
Full Changelog: v2.10.0...v2.11.0