Skip to content

Commit c3abe4a

Browse files
committed
chore(deps): removed direct dependencies to gopkg.in/yaml.v3
* fixes #127 The direct dependencies to this archived repo have been replaced by the active fork imported from go.yaml.in/yaml/v3. NOTE: an indirect dependency remains from stretchr/testify. There is an open PR there to solve this stretchr/testify#1772. There is not much I can do here to remove this indirect test dependency. Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent effdcb9 commit c3abe4a

File tree

21 files changed

+70
-13
lines changed

21 files changed

+70
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Child modules will continue to evolve or some new ones may be added in the futur
4242
| `netutils` | networking utilities | host, port from address<br /> |
4343
| `stringutils` | `string` utilities | search in slice (with case-insensitive)<br />split/join query parameters as arrays<br /> |
4444
| `typeutils` | `go` types utilities | check the zero value for any type<br />safe check for a nil value<br /> |
45-
| `yamlutils` | YAML utilities | converting YAML to JSON<br />loading YAML into a dynamic YAML document<br />maintaining the original order of keys in YAML objects<br />require `./jsonutils`<br />~require `github.com/mailru/easyjson`~<br />require `gopkg.in/yaml.v3`<br /> |
45+
| `yamlutils` | YAML utilities | converting YAML to JSON<br />loading YAML into a dynamic YAML document<br />maintaining the original order of keys in YAML objects<br />require `./jsonutils`<br />~require `github.com/mailru/easyjson`~<br />require `go.yaml.in/yaml/v3`<br /> |
4646

4747
---
4848

@@ -51,7 +51,7 @@ Child modules will continue to evolve or some new ones may be added in the futur
5151
The root module `github.com/go-openapi/swag` at the repo level maintains a few
5252
dependencies outside of the standard library.
5353

54-
* YAML utilities depend on `gopkg.in/yaml.v3`
54+
* YAML utilities depend on `go.yaml.in/yaml/v3`
5555
* JSON utilities depend on their registered adapter module:
5656
* by default, only the standard library is used
5757
* `github.com/mailru/easyjson` is now only a dependency for module
@@ -167,13 +167,13 @@ A few ideas:
167167

168168
* [x] Complete the split of dependencies to isolate easyjson from the rest
169169
* [x] Improve CI to reduce needed tests
170+
* [x] Replace dependency to `gopkg.in/yaml.v3` (`yamlutil`)
170171
* [ ] Improve mangling utilities (improve readability, support for capitalized words,
171172
better word substitution for non-letter symbols...)
172173
* [ ] Move back to this common shared pot a few of the technical features introduced by go-swagger independently
173174
(e.g. mangle go package names, search package with go modules support, ...)
174175
* [ ] Apply a similar mono-repo approach to go-openapi/strfmt which suffer from similar woes: bloated API,
175176
imposed dependency to some database driver.
176177
* [ ] Adapt `go-swagger` (incl. generated code) to the new `swag` API.
177-
* [ ] Replace dependency to `gopkg.in/yaml.v3` (`yamlutil`)
178178
* [ ] Factorize some tests, as there is a lot of redundant testing code in `jsonutils`
179179

doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
//
5353
// This repo has a few dependencies outside of the standard library:
5454
//
55-
// - YAML utilities depend on [gopkg.in/yaml.v3]
55+
// - YAML utilities depend on [go.yaml.in/yaml/v3]
5656
package swag
5757

5858
//go:generate mockery

go.work.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
22
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
3+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
4+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=

jsonutils/adapters/easyjson/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ require (
1313
github.com/davecgh/go-spew v1.1.1 // indirect
1414
github.com/josharian/intern v1.0.0 // indirect
1515
github.com/pmezard/go-difflib v1.0.0 // indirect
16+
go.yaml.in/yaml/v3 v3.0.4 // indirect
1617
gopkg.in/yaml.v3 v3.0.1 // indirect
1718
)
1819

jsonutils/adapters/easyjson/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1212
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1313
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
1414
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
15+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
16+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
1517
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1618
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
1719
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

jsonutils/adapters/testintegration/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/go-openapi/swag/typeutils v0.0.0-00010101000000-000000000000 // indirect
1515
github.com/josharian/intern v1.0.0 // indirect
1616
github.com/pmezard/go-difflib v1.0.0 // indirect
17+
go.yaml.in/yaml/v3 v3.0.4 // indirect
1718
gopkg.in/yaml.v3 v3.0.1 // indirect
1819
)
1920

jsonutils/adapters/testintegration/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1212
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1313
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
1414
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
15+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
16+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
1517
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1618
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
1719
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

jsonutils/fixtures_test/go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ module github.com/go-openapi/swag/jsonutils/fixtures_test
22

33
require (
44
github.com/stretchr/testify v1.11.1
5-
gopkg.in/yaml.v3 v3.0.1
5+
go.yaml.in/yaml/v3 v3.0.4
66
)
77

88
require (
99
github.com/davecgh/go-spew v1.1.1 // indirect
1010
github.com/kr/text v0.2.0 // indirect
1111
github.com/pmezard/go-difflib v1.0.0 // indirect
1212
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
1314
)
1415

1516
go 1.24.0

jsonutils/fixtures_test/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1111
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1212
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
1313
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
14+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
15+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
1416
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1517
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
1618
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

jsonutils/fixtures_test/harness.go

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import (
55
"embed"
66
"encoding/json"
77
"errors"
8+
"fmt"
89
"io"
910
"io/fs"
1011
"iter"
1112
"path/filepath"
1213
"regexp"
1314
"testing"
1415

16+
"github.com/stretchr/testify/assert"
1517
"github.com/stretchr/testify/require"
16-
"gopkg.in/yaml.v3"
18+
yaml "go.yaml.in/yaml/v3"
1719
)
1820

1921
// embedded test files
@@ -261,7 +263,7 @@ var (
261263
func YAMLEqualOrdered(t testing.TB, expected, actual string) {
262264
t.Helper()
263265

264-
require.YAMLEq(t, expected, actual) // necessary but not sufficient condition
266+
RequireYAMLEq(t, expected, actual) // necessary but not sufficient condition
265267

266268
// strip all indentation and comments (anchors not supported)
267269
strippedExpected := rexStripIndent.ReplaceAllString(expected, "")
@@ -276,3 +278,38 @@ func YAMLEqualOrdered(t testing.TB, expected, actual string) {
276278

277279
require.Equal(t, strippedExpected, strippedActual)
278280
}
281+
282+
// RequireYAMLEq is the same as [require.YAMLEq] but without the dependency to go.pkg.in/yaml.v3.
283+
//
284+
// NOTE: this could be reverted once https://github.com/stretchr/testify/pull/1772 is merged.
285+
func RequireYAMLEq(t testing.TB, expected string, actual string, msgAndArgs ...any) {
286+
t.Helper()
287+
288+
if AssertYAMLEq(t, expected, actual, msgAndArgs...) {
289+
return
290+
}
291+
t.FailNow()
292+
}
293+
294+
// AssertYAMLEq is the same as [assert.YAMLEq] but without the dependency to go.pkg.in/yaml.v3.
295+
//
296+
// NOTE: this could be reverted once https://github.com/stretchr/testify/pull/1772 is merged.
297+
func AssertYAMLEq(t testing.TB, expected string, actual string, msgAndArgs ...any) bool {
298+
t.Helper()
299+
var expectedYAMLAsInterface, actualYAMLAsInterface any
300+
301+
if err := yaml.Unmarshal([]byte(expected), &expectedYAMLAsInterface); err != nil {
302+
return assert.Fail(t, fmt.Sprintf("Expected value ('%s') is not valid yaml.\nYAML parsing error: '%s'", expected, err.Error()), msgAndArgs...)
303+
}
304+
305+
// Shortcut if same bytes
306+
if actual == expected {
307+
return true
308+
}
309+
310+
if err := yaml.Unmarshal([]byte(actual), &actualYAMLAsInterface); err != nil {
311+
return assert.Fail(t, fmt.Sprintf("Input ('%s') needs to be valid yaml.\nYAML error: '%s'", actual, err.Error()), msgAndArgs...)
312+
}
313+
314+
return assert.Equal(t, expectedYAMLAsInterface, actualYAMLAsInterface, msgAndArgs...)
315+
}

0 commit comments

Comments
 (0)