Repository: danielgtaylor/huma
Pull request #124 (2023-09-08 05:22:31)

feat: upgrade to Chi v5
Switch to the latest Chi release. Older versions can still be used, but you will need to copy the adapter and swap the import path.


Patch:
diff --git a/adapters/humachi/humachi.go b/adapters/humachi/humachi.go
index 4cf04bb..c8ccdd0 100644
--- a/adapters/humachi/humachi.go
+++ b/adapters/humachi/humachi.go
@@ -10,7 +10,7 @@ import (
 
 	"github.com/danielgtaylor/huma/v2"
 	"github.com/danielgtaylor/huma/v2/queryparam"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 )
 
 type chiContext struct {
diff --git a/examples/cmd/main.go b/examples/cmd/main.go
index 5cbe3d4..727f200 100644
--- a/examples/cmd/main.go
+++ b/examples/cmd/main.go
@@ -11,7 +11,7 @@ import (
 	"github.com/danielgtaylor/huma/v2/adapters/humachi"
 	"github.com/danielgtaylor/huma/v2/autopatch"
 	"github.com/danielgtaylor/huma/v2/sse"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/goccy/go-yaml"
 	"github.com/spf13/cobra"
 )
diff --git a/examples/greet/main.go b/examples/greet/main.go
index 8d1e7ba..d3bb14b 100644
--- a/examples/greet/main.go
+++ b/examples/greet/main.go
@@ -8,7 +8,7 @@ import (
 
 	"github.com/danielgtaylor/huma/v2"
 	"github.com/danielgtaylor/huma/v2/adapters/humachi"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 )
 
 // Options for the CLI.
diff --git a/go.mod b/go.mod
index c8dc2b6..5a5e7ec 100644
--- a/go.mod
+++ b/go.mod
@@ -9,7 +9,7 @@ require (
 	github.com/evanphx/json-patch/v5 v5.6.0
 	github.com/fxamacker/cbor/v2 v2.4.0
 	github.com/gin-gonic/gin v1.9.1
-	github.com/go-chi/chi v4.1.2+incompatible
+	github.com/go-chi/chi/v5 v5.0.10
 	github.com/goccy/go-yaml v1.11.0
 	github.com/gofiber/fiber/v2 v2.45.0
 	github.com/google/uuid v1.3.0
@@ -37,6 +37,7 @@ require (
 	github.com/fsnotify/fsnotify v1.6.0 // indirect
 	github.com/gabriel-vasile/mimetype v1.4.2 // indirect
 	github.com/gin-contrib/sse v0.1.0 // indirect
+	github.com/go-chi/chi v4.1.2+incompatible // indirect
 	github.com/go-playground/locales v0.14.1 // indirect
 	github.com/go-playground/universal-translator v0.18.1 // indirect
 	github.com/go-playground/validator/v10 v10.14.0 // indirect
diff --git a/go.sum b/go.sum
index 608043d..a9786c9 100644
--- a/go.sum
+++ b/go.sum
@@ -152,6 +152,8 @@ github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
 github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
 github.com/go-chi/chi v4.1.2+incompatible h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=
 github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
+github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
+github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=


Test patch:
diff --git a/adapters/humachi/humachi_test.go b/adapters/humachi/humachi_test.go
index f7b2272..7593ee4 100644
--- a/adapters/humachi/humachi_test.go
+++ b/adapters/humachi/humachi_test.go
@@ -15,7 +15,7 @@ import (
 	humav1 "github.com/danielgtaylor/huma"
 	"github.com/danielgtaylor/huma/responses"
 	"github.com/danielgtaylor/huma/v2"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 )
 
 var lastModified = time.Now()
diff --git a/api_test.go b/api_test.go
index 145a59e..5a64283 100644
--- a/api_test.go
+++ b/api_test.go
@@ -3,7 +3,7 @@ package huma
 import (
 	"testing"
 
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/error_test.go b/error_test.go
index 35f57dd..b6c78d7 100644
--- a/error_test.go
+++ b/error_test.go
@@ -6,7 +6,7 @@ import (
 	"net/http/httptest"
 	"testing"
 
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/huma_test.go b/huma_test.go
index adc7460..07c47b6 100644
--- a/huma_test.go
+++ b/huma_test.go
@@ -15,7 +15,7 @@ import (
 	"time"
 
 	"github.com/danielgtaylor/huma/v2/queryparam"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/goccy/go-yaml"
 	"github.com/mitchellh/mapstructure"
 	"github.com/stretchr/testify/assert"
diff --git a/humatest/humatest.go b/humatest/humatest.go
index 6881422..9477105 100644
--- a/humatest/humatest.go
+++ b/humatest/humatest.go
@@ -16,7 +16,7 @@ import (
 
 	"github.com/danielgtaylor/huma/v2"
 	"github.com/danielgtaylor/huma/v2/queryparam"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 )
 
 // TB is a subset of the `testing.TB` interface used by the test API and
diff --git a/humatest/humatest_test.go b/humatest/humatest_test.go
index 7f08e8b..8d1b327 100644
--- a/humatest/humatest_test.go
+++ b/humatest/humatest_test.go
@@ -8,7 +8,7 @@ import (
 	"testing"
 
 	"github.com/danielgtaylor/huma/v2"
-	"github.com/go-chi/chi"
+	"github.com/go-chi/chi/v5"
 	"github.com/stretchr/testify/assert"
 )