Skip to content

Commit

Permalink
use forked yaml modules without "replace" (#1038)
Browse files Browse the repository at this point in the history
* fix: thoroughly replace yaml packages with oasdiff's

Signed-off-by: Pierre Fenoll <[email protected]>

* require updated yaml modules

* go mod tidy

---------

Signed-off-by: Pierre Fenoll <[email protected]>
Co-authored-by: Pierre Fenoll <[email protected]>
  • Loading branch information
reuvenharrison and fenollp authored Dec 11, 2024
1 parent 793b28d commit d819171
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmd/validate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"

"github.com/getkin/kin-openapi/openapi2"
"github.com/getkin/kin-openapi/openapi3"
Expand Down
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ module github.com/getkin/kin-openapi

go 1.22.5

replace gopkg.in/yaml.v3 => github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6

replace github.com/invopop/yaml => github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3

require (
github.com/go-openapi/jsonpointer v0.21.0
github.com/gorilla/mux v1.8.0
github.com/invopop/yaml v0.3.1
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/oasdiff/yaml v0.0.0-20241210131133-6b86fb107d80
github.com/oasdiff/yaml3 v0.0.0-20241210130736-a94c01f36349
github.com/perimeterx/marshmallow v1.1.5
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -23,4 +19,5 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
11 changes: 7 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3 h1:nqCxALSUgWobWkFGIrhLRzR/bpImQdGj+3JS4/scTJo=
github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3/go.mod h1:AOyUNV9ElKz7EEZeBm/48U54UtjtgCMT9fFbZEsClQc=
github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6 h1:+ZsuDTdapTJxfMQk7SOJiNMg0v36pui01L7FEO615r8=
github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6/go.mod h1:lqlOfJRrYpgeWHQj+ky2tf7UJ3PzgHTHRQEpc90nbp0=
github.com/oasdiff/yaml v0.0.0-20241210131133-6b86fb107d80 h1:nZspmSkneBbtxU9TopEAE0CY+SBJLxO8LPUlw2vG4pU=
github.com/oasdiff/yaml v0.0.0-20241210131133-6b86fb107d80/go.mod h1:7tFDb+Y51LcDpn26GccuUgQXUk6t0CXZsivKjyimYX8=
github.com/oasdiff/yaml3 v0.0.0-20241210130736-a94c01f36349 h1:t05Ww3DxZutOqbMN+7OIuqDwXbhl32HiZGpLy26BAPc=
github.com/oasdiff/yaml3 v0.0.0-20241210130736-a94c01f36349/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -32,5 +32,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
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=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion openapi2/marsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"
)

func unmarshalError(jsonUnmarshalErr error) error {
Expand Down
2 changes: 1 addition & 1 deletion openapi2/openapi2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"reflect"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"

"github.com/getkin/kin-openapi/openapi2"
)
Expand Down
2 changes: 1 addition & 1 deletion openapi2conv/issue187_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"testing"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"
"github.com/stretchr/testify/require"

"github.com/getkin/kin-openapi/openapi2"
Expand Down
2 changes: 1 addition & 1 deletion openapi2conv/issue558_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openapi2conv
import (
"testing"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion openapi3/additionalProperties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"testing"

"github.com/oasdiff/yaml3"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"

"github.com/getkin/kin-openapi/openapi3"
)
Expand Down
2 changes: 1 addition & 1 deletion openapi3/issue241_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"testing"

"github.com/oasdiff/yaml3"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"

"github.com/getkin/kin-openapi/openapi3"
)
Expand Down
20 changes: 10 additions & 10 deletions openapi3/issue883_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package openapi3_test
import (
"testing"

invopopYaml "github.com/invopop/yaml"
yaml "github.com/oasdiff/yaml"
yamlv3 "github.com/oasdiff/yaml3"
"github.com/stretchr/testify/require"
v3 "gopkg.in/yaml.v3"

"github.com/getkin/kin-openapi/openapi3"
)
Expand Down Expand Up @@ -38,8 +38,8 @@ paths:
require.NoError(t, err)
require.NotNil(t, doc.Paths)

t.Run("Roundtrip invopop/yaml", func(t *testing.T) {
justPaths, err := invopopYaml.Marshal(doc.Paths)
t.Run("Roundtrip using yaml pkg", func(t *testing.T) {
justPaths, err := yaml.Marshal(doc.Paths)
require.NoError(t, err)
require.NotNil(t, doc.Paths)
require.YAMLEq(t, `
Expand All @@ -51,13 +51,13 @@ paths:
description: OK
`[1:], string(justPaths))

marshalledYaml, err := invopopYaml.Marshal(doc)
marshalledYaml, err := yaml.Marshal(doc)
require.NoError(t, err)
require.NotNil(t, doc.Paths)
require.YAMLEq(t, spec, string(marshalledYaml))

var newDoc openapi3.T
err = invopopYaml.Unmarshal(marshalledYaml, &newDoc)
err = yaml.Unmarshal(marshalledYaml, &newDoc)
require.NoError(t, err)
require.NotNil(t, newDoc.Paths)
require.Equal(t, doc, &newDoc)
Expand All @@ -76,7 +76,7 @@ paths:
description: OK
`[1:], string(justPaths))

justPaths, err = v3.Marshal(doc.Paths)
justPaths, err = yamlv3.Marshal(doc.Paths)
require.NoError(t, err)
require.NotNil(t, doc.Paths)
require.YAMLEq(t, `
Expand All @@ -88,14 +88,14 @@ paths:
description: OK
`[1:], string(justPaths))

marshalledYaml, err := v3.Marshal(doc)
marshalledYaml, err := yamlv3.Marshal(doc)
require.NoError(t, err)
require.NotNil(t, doc.Paths)
require.YAMLEq(t, spec, string(marshalledYaml))

t.Skip("TODO: impl https://pkg.go.dev/gopkg.in/yaml.v3#Unmarshaler on maplike types")
t.Skip("TODO: impl https://pkg.go.dev/github.com/oasdiff/yaml3#Unmarshaler on maplike types")
var newDoc openapi3.T
err = v3.Unmarshal(marshalledYaml, &newDoc)
err = yamlv3.Unmarshal(marshalledYaml, &newDoc)
require.NoError(t, err)
require.NotNil(t, newDoc.Paths)
require.Equal(t, doc, &newDoc)
Expand Down
2 changes: 1 addition & 1 deletion openapi3/issue972_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package openapi3
import (
"testing"

"github.com/oasdiff/yaml3"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

func TestIssue972(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion openapi3/marsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"
)

func unmarshalError(jsonUnmarshalErr error) error {
Expand Down
2 changes: 1 addition & 1 deletion openapi3/openapi3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/invopop/yaml"
"github.com/oasdiff/yaml"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion openapi3/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"testing"

"github.com/oasdiff/yaml3"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)

type schemaExample struct {
Expand Down
2 changes: 1 addition & 1 deletion openapi3filter/req_resp_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"strconv"
"strings"

"gopkg.in/yaml.v3"
"github.com/oasdiff/yaml3"

"github.com/getkin/kin-openapi/openapi3"
)
Expand Down

0 comments on commit d819171

Please sign in to comment.