diff --git a/README.md b/README.md
index 9615e97..e04e5ca 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ Child modules will continue to evolve or some new ones may be added in the futur
| `netutils` | networking utilities | host, port from address
|
| `stringutils` | `string` utilities | search in slice (with case-insensitive)
split/join query parameters as arrays
|
| `typeutils` | `go` types utilities | check the zero value for any type
safe check for a nil value
|
-| `yamlutils` | YAML utilities | converting YAML to JSON
loading YAML into a dynamic YAML document
maintaining the original order of keys in YAML objects
require `./jsonutils`
~require `github.com/mailru/easyjson`~
require `gopkg.in/yaml.v3`
|
+| `yamlutils` | YAML utilities | converting YAML to JSON
loading YAML into a dynamic YAML document
maintaining the original order of keys in YAML objects
require `./jsonutils`
~require `github.com/mailru/easyjson`~
require `go.yaml.in/yaml/v3`
|
---
@@ -51,7 +51,7 @@ Child modules will continue to evolve or some new ones may be added in the futur
The root module `github.com/go-openapi/swag` at the repo level maintains a few
dependencies outside of the standard library.
-* YAML utilities depend on `gopkg.in/yaml.v3`
+* YAML utilities depend on `go.yaml.in/yaml/v3`
* JSON utilities depend on their registered adapter module:
* by default, only the standard library is used
* `github.com/mailru/easyjson` is now only a dependency for module
@@ -167,6 +167,7 @@ A few ideas:
* [x] Complete the split of dependencies to isolate easyjson from the rest
* [x] Improve CI to reduce needed tests
+* [x] Replace dependency to `gopkg.in/yaml.v3` (`yamlutil`)
* [ ] Improve mangling utilities (improve readability, support for capitalized words,
better word substitution for non-letter symbols...)
* [ ] Move back to this common shared pot a few of the technical features introduced by go-swagger independently
@@ -174,6 +175,5 @@ A few ideas:
* [ ] Apply a similar mono-repo approach to go-openapi/strfmt which suffer from similar woes: bloated API,
imposed dependency to some database driver.
* [ ] Adapt `go-swagger` (incl. generated code) to the new `swag` API.
-* [ ] Replace dependency to `gopkg.in/yaml.v3` (`yamlutil`)
* [ ] Factorize some tests, as there is a lot of redundant testing code in `jsonutils`
diff --git a/doc.go b/doc.go
index 38e2635..a079fe8 100644
--- a/doc.go
+++ b/doc.go
@@ -52,7 +52,7 @@
//
// This repo has a few dependencies outside of the standard library:
//
-// - YAML utilities depend on [gopkg.in/yaml.v3]
+// - YAML utilities depend on [go.yaml.in/yaml/v3]
package swag
//go:generate mockery
diff --git a/go.work.sum b/go.work.sum
index 155f40e..bee4481 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -1,2 +1,4 @@
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
diff --git a/jsonutils/adapters/easyjson/go.mod b/jsonutils/adapters/easyjson/go.mod
index 85702be..81f388f 100644
--- a/jsonutils/adapters/easyjson/go.mod
+++ b/jsonutils/adapters/easyjson/go.mod
@@ -13,6 +13,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/jsonutils/adapters/easyjson/go.sum b/jsonutils/adapters/easyjson/go.sum
index d3a4426..49a874a 100644
--- a/jsonutils/adapters/easyjson/go.sum
+++ b/jsonutils/adapters/easyjson/go.sum
@@ -12,6 +12,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/jsonutils/adapters/testintegration/go.mod b/jsonutils/adapters/testintegration/go.mod
index 1561d59..837f6c7 100644
--- a/jsonutils/adapters/testintegration/go.mod
+++ b/jsonutils/adapters/testintegration/go.mod
@@ -14,6 +14,7 @@ require (
github.com/go-openapi/swag/typeutils v0.0.0-00010101000000-000000000000 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/jsonutils/adapters/testintegration/go.sum b/jsonutils/adapters/testintegration/go.sum
index d3a4426..49a874a 100644
--- a/jsonutils/adapters/testintegration/go.sum
+++ b/jsonutils/adapters/testintegration/go.sum
@@ -12,6 +12,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/jsonutils/fixtures_test/go.mod b/jsonutils/fixtures_test/go.mod
index f4da82b..222930b 100644
--- a/jsonutils/fixtures_test/go.mod
+++ b/jsonutils/fixtures_test/go.mod
@@ -2,7 +2,7 @@ module github.com/go-openapi/swag/jsonutils/fixtures_test
require (
github.com/stretchr/testify v1.11.1
- gopkg.in/yaml.v3 v3.0.1
+ go.yaml.in/yaml/v3 v3.0.4
)
require (
@@ -10,6 +10,7 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
)
go 1.24.0
diff --git a/jsonutils/fixtures_test/go.sum b/jsonutils/fixtures_test/go.sum
index bdfb3f7..ec24c6b 100644
--- a/jsonutils/fixtures_test/go.sum
+++ b/jsonutils/fixtures_test/go.sum
@@ -11,6 +11,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/jsonutils/fixtures_test/harness.go b/jsonutils/fixtures_test/harness.go
index b22c5ce..6f09b83 100644
--- a/jsonutils/fixtures_test/harness.go
+++ b/jsonutils/fixtures_test/harness.go
@@ -5,6 +5,7 @@ import (
"embed"
"encoding/json"
"errors"
+ "fmt"
"io"
"io/fs"
"iter"
@@ -12,8 +13,9 @@ import (
"regexp"
"testing"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "gopkg.in/yaml.v3"
+ yaml "go.yaml.in/yaml/v3"
)
// embedded test files
@@ -261,7 +263,7 @@ var (
func YAMLEqualOrdered(t testing.TB, expected, actual string) {
t.Helper()
- require.YAMLEq(t, expected, actual) // necessary but not sufficient condition
+ RequireYAMLEq(t, expected, actual) // necessary but not sufficient condition
// strip all indentation and comments (anchors not supported)
strippedExpected := rexStripIndent.ReplaceAllString(expected, "")
@@ -276,3 +278,38 @@ func YAMLEqualOrdered(t testing.TB, expected, actual string) {
require.Equal(t, strippedExpected, strippedActual)
}
+
+// RequireYAMLEq is the same as [require.YAMLEq] but without the dependency to go.pkg.in/yaml.v3.
+//
+// NOTE: this could be reverted once https://github.com/stretchr/testify/pull/1772 is merged.
+func RequireYAMLEq(t testing.TB, expected string, actual string, msgAndArgs ...any) {
+ t.Helper()
+
+ if AssertYAMLEq(t, expected, actual, msgAndArgs...) {
+ return
+ }
+ t.FailNow()
+}
+
+// AssertYAMLEq is the same as [assert.YAMLEq] but without the dependency to go.pkg.in/yaml.v3.
+//
+// NOTE: this could be reverted once https://github.com/stretchr/testify/pull/1772 is merged.
+func AssertYAMLEq(t testing.TB, expected string, actual string, msgAndArgs ...any) bool {
+ t.Helper()
+ var expectedYAMLAsInterface, actualYAMLAsInterface any
+
+ if err := yaml.Unmarshal([]byte(expected), &expectedYAMLAsInterface); err != nil {
+ return assert.Fail(t, fmt.Sprintf("Expected value ('%s') is not valid yaml.\nYAML parsing error: '%s'", expected, err.Error()), msgAndArgs...)
+ }
+
+ // Shortcut if same bytes
+ if actual == expected {
+ return true
+ }
+
+ if err := yaml.Unmarshal([]byte(actual), &actualYAMLAsInterface); err != nil {
+ return assert.Fail(t, fmt.Sprintf("Input ('%s') needs to be valid yaml.\nYAML error: '%s'", actual, err.Error()), msgAndArgs...)
+ }
+
+ return assert.Equal(t, expectedYAMLAsInterface, actualYAMLAsInterface, msgAndArgs...)
+}
diff --git a/jsonutils/go.mod b/jsonutils/go.mod
index 8cca28c..7bb2423 100644
--- a/jsonutils/go.mod
+++ b/jsonutils/go.mod
@@ -10,6 +10,7 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/jsonutils/go.sum b/jsonutils/go.sum
index ea88d01..2ca4c3d 100644
--- a/jsonutils/go.sum
+++ b/jsonutils/go.sum
@@ -8,6 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/loading/go.mod b/loading/go.mod
index 8d28015..f21e35e 100644
--- a/loading/go.mod
+++ b/loading/go.mod
@@ -11,6 +11,7 @@ require (
github.com/go-openapi/swag/jsonutils v0.0.0-00010101000000-000000000000 // indirect
github.com/go-openapi/swag/typeutils v0.0.0-00010101000000-000000000000 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
+ go.yaml.in/yaml/v3 v3.0.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/loading/go.sum b/loading/go.sum
index ea88d01..2ca4c3d 100644
--- a/loading/go.sum
+++ b/loading/go.sum
@@ -8,6 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/yamlutils/doc.go b/yamlutils/doc.go
index 59f6dc4..4aeadc2 100644
--- a/yamlutils/doc.go
+++ b/yamlutils/doc.go
@@ -20,5 +20,5 @@
package yamlutils
import (
- _ "gopkg.in/yaml.v3" // for documentation purpose only
+ _ "go.yaml.in/yaml/v3" // for documentation purpose only
)
diff --git a/yamlutils/go.mod b/yamlutils/go.mod
index 4b998d6..5bb59f3 100644
--- a/yamlutils/go.mod
+++ b/yamlutils/go.mod
@@ -6,12 +6,13 @@ require (
github.com/go-openapi/swag/jsonutils/fixtures_test v0.0.0-00010101000000-000000000000
github.com/go-openapi/swag/typeutils v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.11.1
- gopkg.in/yaml.v3 v3.0.1
+ go.yaml.in/yaml/v3 v3.0.4
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
)
replace (
diff --git a/yamlutils/go.sum b/yamlutils/go.sum
index ea88d01..2ca4c3d 100644
--- a/yamlutils/go.sum
+++ b/yamlutils/go.sum
@@ -8,6 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
+go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
+go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
diff --git a/yamlutils/ordered_map.go b/yamlutils/ordered_map.go
index c1fb34f..af1d7bb 100644
--- a/yamlutils/ordered_map.go
+++ b/yamlutils/ordered_map.go
@@ -11,7 +11,7 @@ import (
"github.com/go-openapi/swag/jsonutils"
"github.com/go-openapi/swag/jsonutils/adapters/ifaces"
"github.com/go-openapi/swag/typeutils"
- yaml "gopkg.in/yaml.v3"
+ yaml "go.yaml.in/yaml/v3"
)
var (
diff --git a/yamlutils/ordered_map_test.go b/yamlutils/ordered_map_test.go
index 5778274..19c34a5 100644
--- a/yamlutils/ordered_map_test.go
+++ b/yamlutils/ordered_map_test.go
@@ -21,7 +21,7 @@ import (
fixtures "github.com/go-openapi/swag/jsonutils/fixtures_test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- yaml "gopkg.in/yaml.v3"
+ yaml "go.yaml.in/yaml/v3"
)
func TestOrderedMap(t *testing.T) {
diff --git a/yamlutils/yaml.go b/yamlutils/yaml.go
index b543693..67fba8f 100644
--- a/yamlutils/yaml.go
+++ b/yamlutils/yaml.go
@@ -20,7 +20,7 @@ import (
"strconv"
"github.com/go-openapi/swag/jsonutils"
- yaml "gopkg.in/yaml.v3"
+ yaml "go.yaml.in/yaml/v3"
)
// YAMLToJSON converts a YAML document into JSON bytes.
diff --git a/yamlutils/yaml_test.go b/yamlutils/yaml_test.go
index b88f659..63750c8 100644
--- a/yamlutils/yaml_test.go
+++ b/yamlutils/yaml_test.go
@@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- yaml "gopkg.in/yaml.v3"
+ yaml "go.yaml.in/yaml/v3"
)
// embedded test files