Skip to content

Commit

Permalink
fix: thoroughly replace yaml packages with oasdiff's
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Dec 5, 2024
1 parent 793b28d commit cda72a1
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 28 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
6 changes: 0 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ 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/perimeterx/marshmallow v1.1.5
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand Down
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 cda72a1

Please sign in to comment.