Migrating From Huma V1#
- Import
github.com/danielgtaylor/huma/v2
instead ofgithub.com/danielgtaylor/huma
. - Use the
humachi.NewV4
adapter as Huma v1 uses Chi v4 under the hood - Attach your middleware to the
chi
instance. - Replace resource & operation creation with
huma.Register
- Rewrite handlers to be like
func(context.Context, *Input) (*Output, error)
- Return errors instead of
ctx.WriteError(...)
- Return instances instead of
ctx.WriteModel(...)
- Return errors instead of
- Define options via a struct and use
humacli.New
to wrap the service
Note that GraphQL support from Huma v1 has been removed. Take a look at alternative tools like https://www.npmjs.com/package/openapi-to-graphql which will automatically generate a GraphQL endpoint from Huma's generated OpenAPI spec.