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

Conversation

@danielgtaylor
Copy link
Owner

@danielgtaylor danielgtaylor commented May 25, 2023

This change enables people to start playing with the v2 branch (requires a replace directive in your go.mod at the moment pointing to the v2 branch).

import (
	"github.com/danielgtaylor/huma"
	humav2 "github.com/danielgtaylor/huma/v2"
	"github.com/danielgtaylor/huma/v2/adapters/humachi"
)

// ...

mux := chi.NewRouter()

app := huma.NewWithMux("My API", "1.0.0", mux)
// ... register v1 routes

// Set up v2 to use the same mux & register v2 routes
api := humachi.New(mux, humav2.DefaultConfig("My API", "1.0.0"))
humav2.Register(/* ... */)

app.Run()

Note: this does not merge the generated OpenAPI. You can manually use a Huma v1 Open API hook to do that to merge the v2 api.OpenAPI() if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants