diff --git a/.github/docs/openapi2.txt b/.github/docs/openapi2.txt index 9025f5a83..37119d136 100644 --- a/.github/docs/openapi2.txt +++ b/.github/docs/openapi2.txt @@ -1,4 +1,4 @@ -package openapi2 // import "github.com/getkin/kin-openapi/openapi2" +package openapi2 // import "github.com/oasdiff/kin-openapi/openapi2" Package openapi2 parses and writes OpenAPIv2 specification documents. diff --git a/.github/docs/openapi2conv.txt b/.github/docs/openapi2conv.txt index e24925aa3..1a076b72c 100644 --- a/.github/docs/openapi2conv.txt +++ b/.github/docs/openapi2conv.txt @@ -1,4 +1,4 @@ -package openapi2conv // import "github.com/getkin/kin-openapi/openapi2conv" +package openapi2conv // import "github.com/oasdiff/kin-openapi/openapi2conv" Package openapi2conv converts an OpenAPI v2 specification document to v3. diff --git a/.github/docs/openapi3.txt b/.github/docs/openapi3.txt index a8ec46977..0dcd86f21 100644 --- a/.github/docs/openapi3.txt +++ b/.github/docs/openapi3.txt @@ -1,4 +1,4 @@ -package openapi3 // import "github.com/getkin/kin-openapi/openapi3" +package openapi3 // import "github.com/oasdiff/kin-openapi/openapi3" Package openapi3 parses and writes OpenAPI 3 specification documents. diff --git a/.github/docs/openapi3filter.txt b/.github/docs/openapi3filter.txt index 2239377e6..018b90637 100644 --- a/.github/docs/openapi3filter.txt +++ b/.github/docs/openapi3filter.txt @@ -1,4 +1,4 @@ -package openapi3filter // import "github.com/getkin/kin-openapi/openapi3filter" +package openapi3filter // import "github.com/oasdiff/kin-openapi/openapi3filter" Package openapi3filter validates that requests and inputs request an OpenAPI 3 specification file. diff --git a/.github/docs/openapi3gen.txt b/.github/docs/openapi3gen.txt index e8543a47d..d506da61f 100644 --- a/.github/docs/openapi3gen.txt +++ b/.github/docs/openapi3gen.txt @@ -1,4 +1,4 @@ -package openapi3gen // import "github.com/getkin/kin-openapi/openapi3gen" +package openapi3gen // import "github.com/oasdiff/kin-openapi/openapi3gen" Package openapi3gen generates OpenAPIv3 JSON schemas from Go types. diff --git a/.github/docs/routers.txt b/.github/docs/routers.txt index e2605a80a..126290de5 100644 --- a/.github/docs/routers.txt +++ b/.github/docs/routers.txt @@ -1,4 +1,4 @@ -package routers // import "github.com/getkin/kin-openapi/routers" +package routers // import "github.com/oasdiff/kin-openapi/routers" VARIABLES diff --git a/.github/docs/routers_gorillamux.txt b/.github/docs/routers_gorillamux.txt index a7c8a8ec4..01f4b8300 100644 --- a/.github/docs/routers_gorillamux.txt +++ b/.github/docs/routers_gorillamux.txt @@ -1,4 +1,4 @@ -package gorillamux // import "github.com/getkin/kin-openapi/routers/gorillamux" +package gorillamux // import "github.com/oasdiff/kin-openapi/routers/gorillamux" Package gorillamux implements a router. diff --git a/.github/docs/routers_legacy.txt b/.github/docs/routers_legacy.txt index 9082e9304..2059cade7 100644 --- a/.github/docs/routers_legacy.txt +++ b/.github/docs/routers_legacy.txt @@ -1,4 +1,4 @@ -package legacy // import "github.com/getkin/kin-openapi/routers/legacy" +package legacy // import "github.com/oasdiff/kin-openapi/routers/legacy" Package legacy implements a router. diff --git a/.github/docs/routers_legacy_pathpattern.txt b/.github/docs/routers_legacy_pathpattern.txt index db79f7ac7..a9832c6f0 100644 --- a/.github/docs/routers_legacy_pathpattern.txt +++ b/.github/docs/routers_legacy_pathpattern.txt @@ -1,4 +1,4 @@ -package pathpattern // import "github.com/getkin/kin-openapi/routers/legacy/pathpattern" +package pathpattern // import "github.com/oasdiff/kin-openapi/routers/legacy/pathpattern" Package pathpattern implements path matching. diff --git a/README.md b/README.md index 6f37ae89b..9fccac897 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,9 @@ for _, path := range doc.Paths.InMatchingOrder() { ## CHANGELOG: Sub-v1 breaking API changes +### v0.136.0 +* Module renamed from `github.com/getkin/kin-openapi` to `github.com/oasdiff/kin-openapi`. Update all imports accordingly: `openapi2`, `openapi2conv`, `openapi3`, `openapi3filter`, `openapi3gen`, `routers`, `routers/gorillamux`, `routers/legacy`, `routers/legacy/pathpattern` + ### v0.135.0 * `openapi3.MediaType.Encoding` field type changed from `map[string]*Encoding` to `Encodings` * `openapi3.Server.Variables` field type changed from `map[string]*ServerVariable` to `ServerVariables` diff --git a/cmd/validate/main.go b/cmd/validate/main.go index 751940708..2cbba19ac 100644 --- a/cmd/validate/main.go +++ b/cmd/validate/main.go @@ -8,8 +8,8 @@ import ( "github.com/oasdiff/yaml" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) var ( @@ -36,7 +36,7 @@ func main() { flag.Parse() filename := flag.Arg(0) if len(flag.Args()) != 1 || filename == "" { - log.Fatalf("Usage: go run github.com/getkin/kin-openapi/cmd/validate@latest [--circular] [--defaults] [--examples] [--ext] [--patterns] -- \nGot: %+v\n", os.Args) + log.Fatalf("Usage: go run github.com/oasdiff/kin-openapi/cmd/validate@latest [--circular] [--defaults] [--examples] [--ext] [--patterns] -- \nGot: %+v\n", os.Args) } data, err := os.ReadFile(filename) diff --git a/go.mod b/go.mod index eeaceae42..8bae30651 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/getkin/kin-openapi +module github.com/oasdiff/kin-openapi go 1.22.5 @@ -6,8 +6,8 @@ require ( github.com/go-openapi/jsonpointer v0.21.0 github.com/gorilla/mux v1.8.0 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 - github.com/oasdiff/yaml v0.0.4 - github.com/oasdiff/yaml3 v0.0.4 + github.com/oasdiff/yaml v0.0.7 + github.com/oasdiff/yaml3 v0.0.6 github.com/perimeterx/marshmallow v1.1.5 github.com/stretchr/testify v1.9.0 github.com/woodsbury/decimal128 v1.3.0 diff --git a/go.sum b/go.sum index 50d05a537..cd935d9e2 100644 --- a/go.sum +++ b/go.sum @@ -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.4 h1:airPco4LbUoK4nbVwu+wwkRg2WarLC96cgBhgN93fsE= -github.com/oasdiff/yaml v0.0.4/go.mod h1:EaJ6/lcrRLK+syawtvtrHdbrrln4/SUmQw6aBTIlaMs= -github.com/oasdiff/yaml3 v0.0.4 h1:U5RTQZpBmsbcyCFlzPVuMctk6Jme6lOrbl0jJoOovMw= -github.com/oasdiff/yaml3 v0.0.4/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o= +github.com/oasdiff/yaml v0.0.7 h1:r/BR4tqb+W/5fSV6RknYrfBa+PSZnRRvZ/nUnDdepFQ= +github.com/oasdiff/yaml v0.0.7/go.mod h1:EaJ6/lcrRLK+syawtvtrHdbrrln4/SUmQw6aBTIlaMs= +github.com/oasdiff/yaml3 v0.0.6 h1:459QJwIK3pqFs91pIbH/XxCld0ugHd4/F8xHkFjaJPo= +github.com/oasdiff/yaml3 v0.0.6/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= diff --git a/openapi2/marsh.go b/openapi2/marsh.go index 1745734b1..4ef55bef1 100644 --- a/openapi2/marsh.go +++ b/openapi2/marsh.go @@ -19,7 +19,7 @@ func unmarshalError(jsonUnmarshalErr error) error { func unmarshal(data []byte, v any) error { var jsonErr, yamlErr error - // See https://github.com/getkin/kin-openapi/issues/680 + // See https://github.com/oasdiff/kin-openapi/issues/680 if jsonErr = json.Unmarshal(data, v); jsonErr == nil { return nil } diff --git a/openapi2/openapi2.go b/openapi2/openapi2.go index bd3375339..825963fc8 100644 --- a/openapi2/openapi2.go +++ b/openapi2/openapi2.go @@ -3,7 +3,7 @@ package openapi2 import ( "encoding/json" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // T is the root of an OpenAPI v2 document diff --git a/openapi2/openapi2_test.go b/openapi2/openapi2_test.go index d1b3aa56a..9d545b16f 100644 --- a/openapi2/openapi2_test.go +++ b/openapi2/openapi2_test.go @@ -8,7 +8,7 @@ import ( "github.com/oasdiff/yaml" - "github.com/getkin/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi2" ) func Example() { diff --git a/openapi2/operation.go b/openapi2/operation.go index 64f10d1f1..e7d811034 100644 --- a/openapi2/operation.go +++ b/openapi2/operation.go @@ -3,7 +3,7 @@ package openapi2 import ( "encoding/json" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type Operation struct { diff --git a/openapi2/parameter.go b/openapi2/parameter.go index 7f2bddb2c..084248461 100644 --- a/openapi2/parameter.go +++ b/openapi2/parameter.go @@ -4,7 +4,7 @@ import ( "encoding/json" "sort" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type Parameters []*Parameter diff --git a/openapi2/path_item.go b/openapi2/path_item.go index 624cc74dc..84a71240c 100644 --- a/openapi2/path_item.go +++ b/openapi2/path_item.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type PathItem struct { diff --git a/openapi2/response.go b/openapi2/response.go index 3a2983ce1..850d876b5 100644 --- a/openapi2/response.go +++ b/openapi2/response.go @@ -3,7 +3,7 @@ package openapi2 import ( "encoding/json" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type Response struct { diff --git a/openapi2/schema.go b/openapi2/schema.go index 64bed2751..08fd6e522 100644 --- a/openapi2/schema.go +++ b/openapi2/schema.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strings" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type ( @@ -260,7 +260,7 @@ func (schema *Schema) UnmarshalJSON(data []byte) error { *schema = Schema(x) if schema.Format == "date" { - // This is a fix for: https://github.com/getkin/kin-openapi/issues/697 + // This is a fix for: https://github.com/oasdiff/kin-openapi/issues/697 if eg, ok := schema.Example.(string); ok { schema.Example = strings.TrimSuffix(eg, "T00:00:00Z") } diff --git a/openapi2/security_scheme.go b/openapi2/security_scheme.go index cd6e6a5dd..01aff19ce 100644 --- a/openapi2/security_scheme.go +++ b/openapi2/security_scheme.go @@ -3,7 +3,7 @@ package openapi2 import ( "encoding/json" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type SecurityRequirements []map[string][]string diff --git a/openapi2conv/issue1016_test.go b/openapi2conv/issue1016_test.go index acd87d077..7e979003f 100644 --- a/openapi2conv/issue1016_test.go +++ b/openapi2conv/issue1016_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/getkin/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi2" "github.com/stretchr/testify/require" ) diff --git a/openapi2conv/issue1069_test.go b/openapi2conv/issue1069_test.go index f7bb8bcdc..b34ca76d8 100644 --- a/openapi2conv/issue1069_test.go +++ b/openapi2conv/issue1069_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" "github.com/oasdiff/yaml" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/openapi2conv/issue1091_test.go b/openapi2conv/issue1091_test.go index bf3e1864d..dfc453e31 100644 --- a/openapi2conv/issue1091_test.go +++ b/openapi2conv/issue1091_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi2" ) func TestIssue1091_PropertyExtensions(t *testing.T) { diff --git a/openapi2conv/issue187_test.go b/openapi2conv/issue187_test.go index 4cec87532..5274e7a53 100644 --- a/openapi2conv/issue187_test.go +++ b/openapi2conv/issue187_test.go @@ -8,8 +8,8 @@ import ( "github.com/oasdiff/yaml" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) func v2v3JSON(spec2 []byte) (doc3 *openapi3.T, err error) { diff --git a/openapi2conv/issue440_test.go b/openapi2conv/issue440_test.go index 5c9f67dc0..3fa3d6825 100644 --- a/openapi2conv/issue440_test.go +++ b/openapi2conv/issue440_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue440(t *testing.T) { diff --git a/openapi2conv/issue979_test.go b/openapi2conv/issue979_test.go index 8d87902c9..93db47f0c 100644 --- a/openapi2conv/issue979_test.go +++ b/openapi2conv/issue979_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue979(t *testing.T) { diff --git a/openapi2conv/openapi2_conv.go b/openapi2conv/openapi2_conv.go index e50e15186..478d44695 100644 --- a/openapi2conv/openapi2_conv.go +++ b/openapi2conv/openapi2_conv.go @@ -7,8 +7,8 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) // ToV3 converts an OpenAPIv2 spec to an OpenAPIv3 spec diff --git a/openapi2conv/openapi2_conv_test.go b/openapi2conv/openapi2_conv_test.go index ce3423787..4c54fa3a3 100644 --- a/openapi2conv/openapi2_conv_test.go +++ b/openapi2conv/openapi2_conv_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi2" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi2" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestConvOpenAPIV3ToV2(t *testing.T) { diff --git a/openapi3/additionalProperties_test.go b/openapi3/additionalProperties_test.go index 46cf0dbe8..41a64c841 100644 --- a/openapi3/additionalProperties_test.go +++ b/openapi3/additionalProperties_test.go @@ -9,7 +9,7 @@ import ( "github.com/oasdiff/yaml3" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestMarshalAdditionalProperties(t *testing.T) { diff --git a/openapi3/callback.go b/openapi3/callback.go index 31f4e4be2..a3e168404 100644 --- a/openapi3/callback.go +++ b/openapi3/callback.go @@ -56,6 +56,6 @@ func (callback *Callback) Validate(ctx context.Context, opts ...ValidationOption // UnmarshalJSON sets Callbacks to a copy of data. func (callbacks *Callbacks) UnmarshalJSON(data []byte) (err error) { - *callbacks, _, err = unmarshalStringMapP[CallbackRef](data) + *callbacks, err = unmarshalStringMapP[CallbackRef](data) return } diff --git a/openapi3/components.go b/openapi3/components.go index eac75ab4a..fe25f06fd 100644 --- a/openapi3/components.go +++ b/openapi3/components.go @@ -95,8 +95,6 @@ func (components *Components) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "schemas") delete(x.Extensions, "parameters") delete(x.Extensions, "headers") diff --git a/openapi3/contact.go b/openapi3/contact.go index 241ea0ef9..269db2f7f 100644 --- a/openapi3/contact.go +++ b/openapi3/contact.go @@ -52,8 +52,6 @@ func (contact *Contact) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "name") delete(x.Extensions, "url") delete(x.Extensions, "email") diff --git a/openapi3/content.go b/openapi3/content.go index 73e301e05..64db65f65 100644 --- a/openapi3/content.go +++ b/openapi3/content.go @@ -125,6 +125,6 @@ func (content Content) Validate(ctx context.Context, opts ...ValidationOption) e // UnmarshalJSON sets Content to a copy of data. func (content *Content) UnmarshalJSON(data []byte) (err error) { - *content, _, err = unmarshalStringMapP[MediaType](data) + *content, err = unmarshalStringMapP[MediaType](data) return } diff --git a/openapi3/discriminator.go b/openapi3/discriminator.go index 90fc3b228..ca215bcb4 100644 --- a/openapi3/discriminator.go +++ b/openapi3/discriminator.go @@ -60,8 +60,6 @@ func (discriminator *Discriminator) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "propertyName") delete(x.Extensions, "mapping") if len(x.Extensions) == 0 { diff --git a/openapi3/encoding.go b/openapi3/encoding.go index 2cab939a4..bd0108a0d 100644 --- a/openapi3/encoding.go +++ b/openapi3/encoding.go @@ -29,7 +29,7 @@ type Encodings map[string]*Encoding // UnmarshalJSON sets Encodings to a copy of data, stripping __origin__ metadata. func (encodings *Encodings) UnmarshalJSON(data []byte) (err error) { - *encodings, _, err = unmarshalStringMapP[Encoding](data) + *encodings, err = unmarshalStringMapP[Encoding](data) return } @@ -91,8 +91,6 @@ func (encoding *Encoding) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "contentType") delete(x.Extensions, "headers") delete(x.Extensions, "style") diff --git a/openapi3/example.go b/openapi3/example.go index 884a21e19..22422c31f 100644 --- a/openapi3/example.go +++ b/openapi3/example.go @@ -60,8 +60,6 @@ func (example *Example) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "summary") delete(x.Extensions, "description") delete(x.Extensions, "value") @@ -70,7 +68,6 @@ func (example *Example) UnmarshalJSON(data []byte) error { x.Extensions = nil } *example = Example(x) - example.Value = stripOriginFromAny(example.Value) return nil } @@ -90,6 +87,6 @@ func (example *Example) Validate(ctx context.Context, opts ...ValidationOption) // UnmarshalJSON sets Examples to a copy of data. func (examples *Examples) UnmarshalJSON(data []byte) (err error) { - *examples, _, err = unmarshalStringMapP[ExampleRef](data) + *examples, err = unmarshalStringMapP[ExampleRef](data) return } diff --git a/openapi3/example_refs_test.go b/openapi3/example_refs_test.go index b2f36e3ea..be6d4943f 100644 --- a/openapi3/example_refs_test.go +++ b/openapi3/example_refs_test.go @@ -3,7 +3,7 @@ package openapi3_test import ( "testing" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" "github.com/stretchr/testify/require" ) diff --git a/openapi3/external_docs.go b/openapi3/external_docs.go index 2c082b1ff..672dd9174 100644 --- a/openapi3/external_docs.go +++ b/openapi3/external_docs.go @@ -50,8 +50,6 @@ func (e *ExternalDocs) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "description") delete(x.Extensions, "url") if len(x.Extensions) == 0 { diff --git a/openapi3/header.go b/openapi3/header.go index 6b23db52e..a37bcc44e 100644 --- a/openapi3/header.go +++ b/openapi3/header.go @@ -97,6 +97,6 @@ func (header *Header) Validate(ctx context.Context, opts ...ValidationOption) er // UnmarshalJSON sets Headers to a copy of data. func (headers *Headers) UnmarshalJSON(data []byte) (err error) { - *headers, _, err = unmarshalStringMapP[HeaderRef](data) + *headers, err = unmarshalStringMapP[HeaderRef](data) return } diff --git a/openapi3/info.go b/openapi3/info.go index 31ff91814..fd6af3f2e 100644 --- a/openapi3/info.go +++ b/openapi3/info.go @@ -63,8 +63,6 @@ func (info *Info) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "title") delete(x.Extensions, "description") delete(x.Extensions, "termsOfService") diff --git a/openapi3/issue241_test.go b/openapi3/issue241_test.go index 9a643ede4..3babc43ef 100644 --- a/openapi3/issue241_test.go +++ b/openapi3/issue241_test.go @@ -8,7 +8,7 @@ import ( "github.com/oasdiff/yaml3" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue241(t *testing.T) { diff --git a/openapi3/issue513_test.go b/openapi3/issue513_test.go index 38454f672..248cdbaaa 100644 --- a/openapi3/issue513_test.go +++ b/openapi3/issue513_test.go @@ -34,7 +34,7 @@ paths: `[1:]) // When that site fails to respond: - // see https://github.com/getkin/kin-openapi/issues/495 + // see https://github.com/oasdiff/kin-openapi/issues/495 // http://schemas.sentex.io/store/categories.json // { diff --git a/openapi3/issue594_test.go b/openapi3/issue594_test.go index 42bc7e797..df11052c8 100644 --- a/openapi3/issue594_test.go +++ b/openapi3/issue594_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue594(t *testing.T) { diff --git a/openapi3/issue615_test.go b/openapi3/issue615_test.go index 02532bb5a..992a88e49 100644 --- a/openapi3/issue615_test.go +++ b/openapi3/issue615_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue615(t *testing.T) { diff --git a/openapi3/issue652_test.go b/openapi3/issue652_test.go index 738569a4b..a75a13c45 100644 --- a/openapi3/issue652_test.go +++ b/openapi3/issue652_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue652(t *testing.T) { diff --git a/openapi3/issue657_test.go b/openapi3/issue657_test.go index a745e5606..7bb610a50 100644 --- a/openapi3/issue657_test.go +++ b/openapi3/issue657_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestOneOf_Warning_Errors(t *testing.T) { diff --git a/openapi3/issue689_test.go b/openapi3/issue689_test.go index b7479f9f4..3963e5e1f 100644 --- a/openapi3/issue689_test.go +++ b/openapi3/issue689_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue689(t *testing.T) { diff --git a/openapi3/issue735_test.go b/openapi3/issue735_test.go index eb57ab896..1b02dc404 100644 --- a/openapi3/issue735_test.go +++ b/openapi3/issue735_test.go @@ -155,7 +155,7 @@ func TestIssue735(t *testing.T) { value: map[string]any{"foo": 42}, extraNotContains: []any{42}, }, - // TODO: uncomment when https://github.com/getkin/kin-openapi/issues/502 is fixed + // TODO: uncomment when https://github.com/oasdiff/kin-openapi/issues/502 is fixed //{ // name: "read only properties", // schema: NewSchema().WithProperties(map[string]*Schema{ diff --git a/openapi3/issue767_test.go b/openapi3/issue767_test.go index 04fd9d03f..54b4f947d 100644 --- a/openapi3/issue767_test.go +++ b/openapi3/issue767_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue767(t *testing.T) { diff --git a/openapi3/issue883_test.go b/openapi3/issue883_test.go index 7609e6ac3..eea90f103 100644 --- a/openapi3/issue883_test.go +++ b/openapi3/issue883_test.go @@ -7,7 +7,7 @@ import ( yamlv3 "github.com/oasdiff/yaml3" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue883(t *testing.T) { diff --git a/openapi3/license.go b/openapi3/license.go index 440b3d762..755b5d93f 100644 --- a/openapi3/license.go +++ b/openapi3/license.go @@ -46,8 +46,6 @@ func (license *License) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "name") delete(x.Extensions, "url") if len(x.Extensions) == 0 { diff --git a/openapi3/link.go b/openapi3/link.go index 54694d949..72a2e7e1e 100644 --- a/openapi3/link.go +++ b/openapi3/link.go @@ -68,8 +68,6 @@ func (link *Link) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "operationRef") delete(x.Extensions, "operationId") delete(x.Extensions, "description") @@ -80,7 +78,6 @@ func (link *Link) UnmarshalJSON(data []byte) error { x.Extensions = nil } *link = Link(x) - link.RequestBody = stripOriginFromAny(link.RequestBody) return nil } @@ -100,6 +97,6 @@ func (link *Link) Validate(ctx context.Context, opts ...ValidationOption) error // UnmarshalJSON sets Links to a copy of data. func (links *Links) UnmarshalJSON(data []byte) (err error) { - *links, _, err = unmarshalStringMapP[LinkRef](data) + *links, err = unmarshalStringMapP[LinkRef](data) return } diff --git a/openapi3/load_cicular_ref_with_external_file_test.go b/openapi3/load_cicular_ref_with_external_file_test.go index cff5c01fe..69c76f2a1 100644 --- a/openapi3/load_cicular_ref_with_external_file_test.go +++ b/openapi3/load_cicular_ref_with_external_file_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) //go:embed testdata/circularRef/* diff --git a/openapi3/load_with_go_embed_test.go b/openapi3/load_with_go_embed_test.go index 27b46b29f..374d4025b 100644 --- a/openapi3/load_with_go_embed_test.go +++ b/openapi3/load_with_go_embed_test.go @@ -8,7 +8,7 @@ import ( "fmt" "net/url" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) //go:embed testdata/recursiveRef/* diff --git a/openapi3/loader.go b/openapi3/loader.go index 1e9e648fd..714529a07 100644 --- a/openapi3/loader.go +++ b/openapi3/loader.go @@ -15,9 +15,9 @@ import ( "strings" ) -// IncludeOrigin specifies whether to include the origin of the OpenAPI elements -// Set this to true before loading a spec to include the origin of the OpenAPI elements -// Note it is global and affects all loaders +// IncludeOrigin specifies whether to include the origin of the OpenAPI elements. +// Deprecated: set Loader.IncludeOrigin instead. This global is read by NewLoader +// for backward compatibility but is not safe for concurrent use. var IncludeOrigin = false func foundUnresolvedRef(ref string) error { @@ -33,6 +33,11 @@ type Loader struct { // IsExternalRefsAllowed enables visiting other files IsExternalRefsAllowed bool + // IncludeOrigin enables recording the file/line/column of each OpenAPI element. + // Prefer this over the package-level IncludeOrigin global, which is not safe for + // concurrent use. + IncludeOrigin bool + // ReadFromURIFunc allows overriding the any file/URL reading func ReadFromURIFunc ReadFromURIFunc @@ -53,7 +58,8 @@ type Loader struct { // NewLoader returns an empty Loader func NewLoader() *Loader { return &Loader{ - Context: context.Background(), + Context: context.Background(), + IncludeOrigin: IncludeOrigin, } } @@ -108,7 +114,7 @@ func (loader *Loader) loadSingleElementFromURI(ref string, rootPath *url.URL, el if err != nil { return nil, err } - if err := unmarshal(data, element, IncludeOrigin, resolvedPath); err != nil { + if err := unmarshal(data, element, loader.IncludeOrigin || IncludeOrigin, resolvedPath); err != nil { return nil, err } @@ -144,7 +150,7 @@ func (loader *Loader) LoadFromIoReader(reader io.Reader) (*T, error) { func (loader *Loader) LoadFromData(data []byte) (*T, error) { loader.resetVisitedPathItemRefs() doc := &T{} - if err := unmarshal(data, doc, IncludeOrigin, nil); err != nil { + if err := unmarshal(data, doc, loader.IncludeOrigin || IncludeOrigin, nil); err != nil { return nil, err } if err := loader.ResolveRefsIn(doc, nil); err != nil { @@ -173,7 +179,7 @@ func (loader *Loader) loadFromDataWithPathInternal(data []byte, location *url.UR doc := &T{} loader.visitedDocuments[uri] = doc - if err := unmarshal(data, doc, IncludeOrigin, location); err != nil { + if err := unmarshal(data, doc, loader.IncludeOrigin || IncludeOrigin, location); err != nil { return nil, err } @@ -427,7 +433,7 @@ func (loader *Loader) resolveComponent(doc *T, ref string, path *url.URL, resolv if err2 != nil { return nil, nil, err } - if err2 = unmarshal(data, &cursor, IncludeOrigin, path); err2 != nil { + if err2 = unmarshal(data, &cursor, loader.IncludeOrigin || IncludeOrigin, path); err2 != nil { return nil, nil, err } if cursor, err2 = drill(cursor); err2 != nil || cursor == nil { diff --git a/openapi3/maplike.go b/openapi3/maplike.go index 36aa244de..ac723b4d4 100644 --- a/openapi3/maplike.go +++ b/openapi3/maplike.go @@ -124,17 +124,6 @@ func (responses *Responses) UnmarshalJSON(data []byte) (err error) { continue } - if k == originKey { - var data []byte - if data, err = json.Marshal(v); err != nil { - return - } - if err = json.Unmarshal(data, &x.Origin); err != nil { - return - } - continue - } - var data []byte if data, err = json.Marshal(v); err != nil { return @@ -265,17 +254,6 @@ func (callback *Callback) UnmarshalJSON(data []byte) (err error) { continue } - if k == originKey { - var data []byte - if data, err = json.Marshal(v); err != nil { - return - } - if err = json.Unmarshal(data, &x.Origin); err != nil { - return - } - continue - } - var data []byte if data, err = json.Marshal(v); err != nil { return @@ -406,17 +384,6 @@ func (paths *Paths) UnmarshalJSON(data []byte) (err error) { continue } - if k == originKey { - var data []byte - if data, err = json.Marshal(v); err != nil { - return - } - if err = json.Unmarshal(data, &x.Origin); err != nil { - return - } - continue - } - var data []byte if data, err = json.Marshal(v); err != nil { return diff --git a/openapi3/marsh.go b/openapi3/marsh.go index 657862f5a..5686a3ae1 100644 --- a/openapi3/marsh.go +++ b/openapi3/marsh.go @@ -20,7 +20,7 @@ func unmarshalError(jsonUnmarshalErr error) error { func unmarshal(data []byte, v any, includeOrigin bool, location *url.URL) error { var jsonErr, yamlErr error - // See https://github.com/getkin/kin-openapi/issues/680 + // See https://github.com/oasdiff/kin-openapi/issues/680 if jsonErr = json.Unmarshal(data, v); jsonErr == nil { return nil } @@ -30,9 +30,13 @@ func unmarshal(data []byte, v any, includeOrigin bool, location *url.URL) error if location != nil { file = location.Path } - if yamlErr = yaml.UnmarshalWithOrigin(data, v, yaml.OriginOpt{Enabled: includeOrigin, File: file}); yamlErr == nil { + originOpt := yaml.OriginOpt{Enabled: includeOrigin, File: file} + tree, err := yaml.UnmarshalWithOriginTree(data, v, originOpt) + if err == nil { + applyOrigins(v, tree) return nil } + yamlErr = err // If both unmarshaling attempts fail, return a new error that includes both errors return fmt.Errorf("failed to unmarshal data: json error: %v, yaml error: %v", jsonErr, yamlErr) diff --git a/openapi3/media_type.go b/openapi3/media_type.go index c0edcf9c1..6aada3567 100644 --- a/openapi3/media_type.go +++ b/openapi3/media_type.go @@ -102,8 +102,6 @@ func (mediaType *MediaType) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "schema") delete(x.Extensions, "example") delete(x.Extensions, "examples") @@ -112,7 +110,6 @@ func (mediaType *MediaType) UnmarshalJSON(data []byte) error { x.Extensions = nil } *mediaType = MediaType(x) - mediaType.Example = stripOriginFromAny(mediaType.Example) return nil } diff --git a/openapi3/openapi3.go b/openapi3/openapi3.go index 77ebe494c..ed8a016c5 100644 --- a/openapi3/openapi3.go +++ b/openapi3/openapi3.go @@ -116,8 +116,6 @@ func (doc *T) UnmarshalJSON(data []byte) error { delete(x.Extensions, "servers") delete(x.Extensions, "tags") delete(x.Extensions, "externalDocs") - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) if len(x.Extensions) == 0 { x.Extensions = nil } diff --git a/openapi3/operation.go b/openapi3/operation.go index dd10405b5..c26e260de 100644 --- a/openapi3/operation.go +++ b/openapi3/operation.go @@ -117,8 +117,6 @@ func (operation *Operation) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "tags") delete(x.Extensions, "summary") delete(x.Extensions, "description") diff --git a/openapi3/origin.go b/openapi3/origin.go index ea0ae15fa..7deb26e28 100644 --- a/openapi3/origin.go +++ b/openapi3/origin.go @@ -1,7 +1,17 @@ package openapi3 +import ( + "encoding/json" + "reflect" + "strings" + + "github.com/oasdiff/yaml" +) + const originKey = "__origin__" +var originPtrType = reflect.TypeOf((*Origin)(nil)) + // Origin contains the origin of a collection. // Key is the location of the collection itself. // Fields is a map of the location of each scalar field in the collection. @@ -20,35 +30,243 @@ type Location struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` } -// stripOriginFromAny recursively removes the __origin__ key from any -// map[string]any value. This is needed for interface{}/any-typed fields -// (e.g. Schema.Enum, Schema.Default, Parameter.Example) that have no -// dedicated UnmarshalJSON to consume the origin metadata injected by -// the YAML origin-tracking loader. -func stripOriginFromAny(v any) any { - switch x := v.(type) { - case map[string]any: - delete(x, originKey) - for k, val := range x { - x[k] = stripOriginFromAny(val) +// originFromSeq parses the compact []any sequence produced by yaml3's addOrigin. +// +// Format: [file, key_name, key_line, key_col, nf, f1_name, f1_delta, f1_col, ..., ns, s1_name, s1_count, s1_l0_delta, s1_c0, ...] +func originFromSeq(s []any) *Origin { + // Need at least: file, key_name, key_line, key_col, nf, ns + if len(s) < 6 { + return nil + } + file, _ := s[0].(string) + keyName, _ := s[1].(string) + keyLine := toInt(s[2]) + keyCol := toInt(s[3]) + + o := &Origin{ + Key: &Location{ + File: file, + Line: keyLine, + Column: keyCol, + Name: keyName, + }, + } + + idx := 4 + nf := toInt(s[idx]) + idx++ + if nf > 0 && idx+nf*3 <= len(s) { + o.Fields = make(map[string]Location, nf) + for i := 0; i < nf; i++ { + fname, _ := s[idx].(string) + delta := toInt(s[idx+1]) + col := toInt(s[idx+2]) + o.Fields[fname] = Location{ + File: file, + Line: keyLine + delta, + Column: col, + Name: fname, + } + idx += 3 + } + } + + if idx >= len(s) { + return o + } + ns := toInt(s[idx]) + idx++ + if ns > 0 { + o.Sequences = make(map[string][]Location, ns) + for i := 0; i < ns; i++ { + if idx >= len(s) { + break + } + sname, _ := s[idx].(string) + idx++ + count := toInt(s[idx]) + idx++ + locs := make([]Location, count) + for j := 0; j < count && idx+2 < len(s); j++ { + name, _ := s[idx].(string) + delta := toInt(s[idx+1]) + col := toInt(s[idx+2]) + locs[j] = Location{File: file, Line: keyLine + delta, Column: col, Name: name} + idx += 3 + } + o.Sequences[sname] = locs + } + } + return o +} + +// UnmarshalJSON parses the compact []any sequence produced by yaml3's addOrigin. +// This allows __origin__ to be decoded directly during JSON unmarshaling without +// a separate applyOrigins pass when the caller does not use UnmarshalWithOriginTree. +func (o *Origin) UnmarshalJSON(data []byte) error { + var seq []any + if err := json.Unmarshal(data, &seq); err != nil { + return err + } + if parsed := originFromSeq(seq); parsed != nil { + *o = *parsed + } + return nil +} + +// toInt converts numeric types to int. Handles int/uint64 from YAML decoding +// and float64 from JSON decoding of []any sequences. +func toInt(v any) int { + switch n := v.(type) { + case int: + return n + case uint64: + return int(n) + case float64: + return int(n) + } + return 0 +} + +// applyOrigins walks a Go struct tree and a parallel OriginTree, setting +// Origin fields on each struct from the extracted origin data. +func applyOrigins(v any, tree *yaml.OriginTree) { + if tree == nil { + return + } + applyOriginsToValue(reflect.ValueOf(v), tree) +} + +func applyOriginsToValue(val reflect.Value, tree *yaml.OriginTree) { + // Keep track of the last pointer so we can pass it to struct handlers + // (needed for calling methods like Map() on maplike types). + var ptr reflect.Value + for val.Kind() == reflect.Ptr || val.Kind() == reflect.Interface { + if val.IsNil() { + return + } + if val.Kind() == reflect.Ptr { + ptr = val + } + val = val.Elem() + } + + switch val.Kind() { + case reflect.Struct: + applyOriginsToStruct(val, ptr, tree) + case reflect.Map: + applyOriginsToMap(val, tree) + case reflect.Slice: + applyOriginsToSlice(val, tree) + } +} + +func applyOriginsToStruct(val reflect.Value, ptr reflect.Value, tree *yaml.OriginTree) { + typ := val.Type() + + // Set Origin field if tagged with json:"__origin__" or json:"-" (maplike types). + // Skip *Ref types which have Origin with no json tag — those pass through to Value. + if tree.Origin != nil { + if sf, ok := typ.FieldByName("Origin"); ok && sf.Type == originPtrType { + tag := sf.Tag.Get("json") + if strings.Contains(tag, originKey) || tag == "-" { + if s, ok := tree.Origin.([]any); ok { + val.FieldByName("Origin").Set(reflect.ValueOf(originFromSeq(s))) + } + } + } + } + + // Recurse into exported struct fields using json tags + for i := 0; i < typ.NumField(); i++ { + sf := typ.Field(i) + if !sf.IsExported() { + continue + } + tag := jsonTagName(sf) + if tag == "" || tag == "-" { + continue + } + childTree := tree.Fields[tag] + if childTree != nil { + applyOriginsToValue(val.Field(i), childTree) + } + } + + // Handle wrapper types whose inner struct has no json tag: + // - *Ref types (e.g. SchemaRef, ResponseRef) have a "Value" field + // - AdditionalProperties has a "Schema" field + // The origin tree data applies to the inner struct, not a sub-key. + for _, fieldName := range []string{"Value", "Schema"} { + vf := val.FieldByName(fieldName) + if !vf.IsValid() || vf.Kind() != reflect.Ptr || vf.IsNil() { + continue + } + sf, _ := typ.FieldByName(fieldName) + if sf.Tag.Get("json") == "" { + applyOriginsToValue(vf, tree) + } + } + + // Handle "maplike" types (Paths, Responses, Callback) whose items are + // stored in an unexported map accessible via a Map() method. + // Use the original pointer (if available) since dereferenced values + // are not addressable. + receiver := val + if ptr.IsValid() { + receiver = ptr + } else if val.CanAddr() { + receiver = val.Addr() + } + if receiver.Kind() == reflect.Ptr { + if mapMethod := receiver.MethodByName("Map"); mapMethod.IsValid() { + results := mapMethod.Call(nil) + if len(results) == 1 { + applyOriginsToMap(results[0], tree) + } + } + } +} + +func applyOriginsToMap(val reflect.Value, tree *yaml.OriginTree) { + if tree.Fields == nil { + return + } + for _, key := range val.MapKeys() { + childTree := tree.Fields[key.String()] + if childTree == nil { + continue } - return x - case []any: - for i, val := range x { - x[i] = stripOriginFromAny(val) + elem := val.MapIndex(key) + // Map values are not addressable. For pointer-typed values we can + // recurse directly. For value types we must copy, apply, and set back. + if elem.Kind() == reflect.Ptr || elem.Kind() == reflect.Interface { + applyOriginsToValue(elem, childTree) + } else if elem.Kind() == reflect.Struct { + // Copy to a settable value + cp := reflect.New(elem.Type()).Elem() + cp.Set(elem) + applyOriginsToStruct(cp, reflect.Value{}, childTree) + val.SetMapIndex(key, cp) } - return x - default: - return v } } -// stripExtensionsOrigin removes __origin__ from every value in an extensions -// map. Extension values are any-typed objects, so the YAML decoder injects -// __origin__ into them. Without stripping it, two specs loaded from different -// file paths would report spurious diffs in their extension values. -func stripExtensionsOrigin(ext map[string]any) { - for k, v := range ext { - ext[k] = stripOriginFromAny(v) +func applyOriginsToSlice(val reflect.Value, tree *yaml.OriginTree) { + for i := 0; i < val.Len() && i < len(tree.Items); i++ { + if tree.Items[i] != nil { + applyOriginsToValue(val.Index(i), tree.Items[i]) + } } } + +// jsonTagName returns the JSON field name from a struct field's json tag. +func jsonTagName(f reflect.StructField) string { + tag := f.Tag.Get("json") + if tag == "" { + return "" + } + name, _, _ := strings.Cut(tag, ",") + return name +} + diff --git a/openapi3/origin_load_test.go b/openapi3/origin_load_test.go new file mode 100644 index 000000000..51159186c --- /dev/null +++ b/openapi3/origin_load_test.go @@ -0,0 +1,57 @@ +package openapi3 + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +// TestOrigin_LoadAllTestdata verifies that enabling origin tracking does not +// break loading of any spec in the testdata directory. It catches regressions +// where __origin__ leaks into fields and causes unmarshal failures or panics. +func TestOrigin_LoadAllTestdata(t *testing.T) { + specs := []struct { + name string + file string + externalRefs bool + }{ + {name: "spec", file: "testdata/spec.yaml", externalRefs: true}, + {name: "main", file: "testdata/main.yaml", externalRefs: true}, + {name: "link-example", file: "testdata/link-example.yaml"}, + {name: "lxkns", file: "testdata/lxkns.yaml"}, + {name: "303bis", file: "testdata/303bis/service.yaml", externalRefs: true}, + {name: "issue638/test1", file: "testdata/issue638/test1.yaml", externalRefs: true}, + {name: "issue638/test2", file: "testdata/issue638/test2.yaml", externalRefs: true}, + {name: "refInRefInProperty", file: "testdata/refInRefInProperty/openapi.yaml", externalRefs: true}, + {name: "circularRef2", file: "testdata/circularRef2/circular2.yaml", externalRefs: true}, + {name: "origin/simple", file: "testdata/origin/simple.yaml"}, + {name: "origin/parameters", file: "testdata/origin/parameters.yaml"}, + {name: "origin/security", file: "testdata/origin/security.yaml"}, + {name: "origin/components", file: "testdata/origin/components.yaml"}, + {name: "origin/extensions", file: "testdata/origin/extensions.yaml"}, + {name: "origin/alias", file: "testdata/origin/alias.yaml"}, + {name: "origin/any_fields", file: "testdata/origin/any_fields.yaml"}, + {name: "origin/required_sequence", file: "testdata/origin/required_sequence.yaml"}, + {name: "origin/headers", file: "testdata/origin/headers.yaml"}, + {name: "origin/example", file: "testdata/origin/example.yaml"}, + {name: "origin/example_with_array", file: "testdata/origin/example_with_array.yaml"}, + {name: "origin/external", file: "testdata/origin/external.yaml", externalRefs: true}, + {name: "origin/additional_properties", file: "testdata/origin/additional_properties.yaml"}, + {name: "origin/request_body", file: "testdata/origin/request_body.yaml"}, + {name: "origin/xml", file: "testdata/origin/xml.yaml"}, + {name: "origin/external_docs", file: "testdata/origin/external_docs.yaml"}, + } + + for _, tc := range specs { + t.Run(tc.name, func(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + loader.IsExternalRefsAllowed = tc.externalRefs + loader.Context = context.Background() + + _, err := loader.LoadFromFile(tc.file) + require.NoError(t, err) + }) + } +} diff --git a/openapi3/origin_test.go b/openapi3/origin_test.go index 84a28d318..b475a1fc1 100644 --- a/openapi3/origin_test.go +++ b/openapi3/origin_test.go @@ -7,17 +7,10 @@ import ( "github.com/stretchr/testify/require" ) -func unsetIncludeOrigin() { - IncludeOrigin = false -} - func TestOrigin_Info(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/simple.yaml") @@ -55,10 +48,7 @@ func TestOrigin_Info(t *testing.T) { func TestOrigin_Paths(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/simple.yaml") @@ -100,10 +90,7 @@ func TestOrigin_Paths(t *testing.T) { func TestOrigin_RequestBody(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/request_body.yaml") @@ -134,10 +121,7 @@ func TestOrigin_RequestBody(t *testing.T) { func TestOrigin_Responses(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/simple.yaml") @@ -178,10 +162,7 @@ func TestOrigin_Responses(t *testing.T) { func TestOrigin_Parameters(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/parameters.yaml") @@ -220,10 +201,7 @@ func TestOrigin_Parameters(t *testing.T) { func TestOrigin_SchemaInAdditionalProperties(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/additional_properties.yaml") @@ -255,10 +233,7 @@ func TestOrigin_SchemaInAdditionalProperties(t *testing.T) { func TestOrigin_ExternalDocs(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/external_docs.yaml") @@ -298,10 +273,7 @@ func TestOrigin_ExternalDocs(t *testing.T) { func TestOrigin_Security(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/security.yaml") @@ -359,10 +331,7 @@ func TestOrigin_Security(t *testing.T) { func TestOrigin_Example(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/example.yaml") @@ -397,10 +366,7 @@ func TestOrigin_Example(t *testing.T) { func TestOrigin_XML(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true loader.Context = context.Background() doc, err := loader.LoadFromFile("testdata/origin/xml.yaml") @@ -436,38 +402,53 @@ func TestOrigin_XML(t *testing.T) { base.Origin.Fields["prefix"]) } -func TestStripOriginFromAny_Slice(t *testing.T) { - // Simulates what the YAML origin-tracking loader produces for example - // values that contain arrays of objects. - input := map[string]any{ - "name": "test", - "items": []any{ - map[string]any{ - "__origin__": map[string]any{"file": "a.yaml", "line": 1}, - "id": 1, - }, - map[string]any{ - "__origin__": map[string]any{"file": "a.yaml", "line": 2}, - "id": 2, - }, - }, - } +// TestOrigin_AnyFieldsStripped verifies that __origin__ is absent from all +// any-typed fields (Schema.Enum, Schema.Default, Schema.Example, +// Parameter.Example, MediaType.Example, Link.RequestBody) after loading. +// These fields have no dedicated UnmarshalJSON; extractOrigins strips +// __origin__ before JSON marshaling so it never reaches these values. +func TestOrigin_AnyFieldsStripped(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + doc, err := loader.LoadFromFile("testdata/origin/any_fields.yaml") + require.NoError(t, err) - result := stripOriginFromAny(input) - m := result.(map[string]any) - items := m["items"].([]any) - for _, item := range items { - itemMap := item.(map[string]any) - require.NotContains(t, itemMap, "__origin__") + op := doc.Paths.Find("/items").Get + resp := op.Responses.Value("200").Value + + // Parameter.Example + paramEx := op.Parameters[0].Value.Example.(map[string]any) + require.NotContains(t, paramEx, originKey, "Parameter.Example must not contain __origin__") + + // MediaType.Example + mediaEx := resp.Content["application/json"].Example.(map[string]any) + require.NotContains(t, mediaEx, originKey, "MediaType.Example must not contain __origin__") + + schema := resp.Content["application/json"].Schema.Value + + // Schema.Default + schemaDefault := schema.Default.(map[string]any) + require.NotContains(t, schemaDefault, originKey, "Schema.Default must not contain __origin__") + + // Schema.Example + schemaEx := schema.Example.(map[string]any) + require.NotContains(t, schemaEx, originKey, "Schema.Example must not contain __origin__") + + // Schema.Enum items + for i, v := range schema.Enum { + m, ok := v.(map[string]any) + require.True(t, ok, "Schema.Enum[%d] must be a map", i) + require.NotContains(t, m, originKey, "Schema.Enum[%d] must not contain __origin__", i) } + + // Link.RequestBody + linkRB := resp.Links["self"].Value.RequestBody.(map[string]any) + require.NotContains(t, linkRB, originKey, "Link.RequestBody must not contain __origin__") } func TestOrigin_ExampleWithArrayValue(t *testing.T) { loader := NewLoader() - - IncludeOrigin = true - defer unsetIncludeOrigin() - + loader.IncludeOrigin = true doc, err := loader.LoadFromFile("testdata/origin/example_with_array.yaml") require.NoError(t, err) @@ -507,9 +488,7 @@ components: ` loader := NewLoader() - - IncludeOrigin = true - defer unsetIncludeOrigin() + loader.IncludeOrigin = true _, err := loader.LoadFromData([]byte(data)) require.Error(t, err) @@ -524,9 +503,7 @@ components: // between specs loaded from different file paths. func TestOrigin_ExtensionValuesStripped(t *testing.T) { loader := NewLoader() - - IncludeOrigin = true - defer unsetIncludeOrigin() + loader.IncludeOrigin = true doc, err := loader.LoadFromFile("testdata/origin/extensions.yaml") require.NoError(t, err) @@ -553,9 +530,7 @@ func TestOrigin_ExtensionValuesStripped(t *testing.T) { func TestOrigin_WithExternalRef(t *testing.T) { loader := NewLoader() loader.IsExternalRefsAllowed = true - - IncludeOrigin = true - defer unsetIncludeOrigin() + loader.IncludeOrigin = true loader.Context = context.Background() @@ -564,25 +539,217 @@ func TestOrigin_WithExternalRef(t *testing.T) { base := doc.Paths.Find("/subscribe").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value require.NotNil(t, base.XML.Origin) - require.Equal(t, base.XML.Origin.Key.File, "testdata/origin/external-schema.yaml") - // require.Equal(t, - // &Location{ - // Line: 1, - // Column: 1, - // }, - // base.Origin.Key) - - // require.Equal(t, - // Location{ - // Line: 2, - // Column: 3, - // }, - // base.Origin.Fields["namespace"]) - - // require.Equal(t, - // Location{ - // Line: 3, - // Column: 3, - // }, - // base.Origin.Fields["prefix"]) + require.Equal(t, + &Location{ + File: "testdata/origin/external-schema.yaml", + Line: 2, + Column: 1, + Name: "xml", + }, + base.XML.Origin.Key) + + require.Equal(t, + Location{ + File: "testdata/origin/external-schema.yaml", + Line: 3, + Column: 3, + Name: "namespace", + }, + base.XML.Origin.Fields["namespace"]) + + require.Equal(t, + Location{ + File: "testdata/origin/external-schema.yaml", + Line: 4, + Column: 3, + Name: "prefix", + }, + base.XML.Origin.Fields["prefix"]) +} + +// TestOrigin_MaplikeNoOriginKey verifies that __origin__ does not appear as a +// map key in Responses, Paths, or Callback maplike types after loading. +// The if k == originKey blocks in their UnmarshalJSON were removed; this +// confirms extractOrigins strips __origin__ before it reaches those iterators. +func TestOrigin_MaplikeNoOriginKey(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + doc, err := loader.LoadFromFile("testdata/origin/simple.yaml") + require.NoError(t, err) + + // Paths map must not contain __origin__ as a path key + require.Nil(t, doc.Paths.Find(originKey), "Paths must not contain __origin__ as a key") + + // Responses map must not contain __origin__ as a status code key + op := doc.Paths.Find("/partner-api/test/some-method").Get + require.Nil(t, op.Responses.Value(originKey), "Responses must not contain __origin__ as a key") +} + +func TestOrigin_NoSpuriousOriginsInComponents(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + + doc, err := loader.LoadFromFile("testdata/origin/components.yaml") + + require.Nil(t, doc.Components.Schemas[originKey]) + require.Nil(t, doc.Components.Parameters[originKey]) + require.Nil(t, doc.Components.Headers[originKey]) + require.Nil(t, doc.Components.RequestBodies[originKey]) + require.Nil(t, doc.Components.Responses[originKey]) + require.Nil(t, doc.Components.SecuritySchemes[originKey]) + require.Nil(t, doc.Components.Examples[originKey]) + require.Nil(t, doc.Components.Links[originKey]) + require.Nil(t, doc.Components.Callbacks[originKey]) + + require.NoError(t, err) +} + +// TestOrigin_RequiredSequence verifies that Origin.Sequences records the +// file/line/column of each item in a required: [...] list. +// These locations are used by NewSourceFromSequenceItem to pinpoint +// breaking changes to individual required field names. +func TestOrigin_RequiredSequence(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + + doc, err := loader.LoadFromFile("testdata/origin/required_sequence.yaml") + require.NoError(t, err) + + schema := doc.Paths.Find("/items").Post.RequestBody.Value.Content["application/json"].Schema.Value + require.NotNil(t, schema.Origin) + + // "required" must appear in Fields (it's a sequence-valued field) + require.Contains(t, schema.Origin.Fields, "required") + + // Sequences must record per-item locations for "required" + seqLocs, ok := schema.Origin.Sequences["required"] + require.True(t, ok, "Origin.Sequences must contain 'required'") + require.Len(t, seqLocs, 2) + + require.Equal(t, Location{ + File: "testdata/origin/required_sequence.yaml", + Line: 14, + Column: 19, + Name: "name", + }, seqLocs[0]) + + require.Equal(t, Location{ + File: "testdata/origin/required_sequence.yaml", + Line: 15, + Column: 19, + Name: "age", + }, seqLocs[1]) +} + +// TestOrigin_YAMLAlias verifies that a schema referenced via YAML alias loads +// without error and carries origin metadata from the anchor definition. +// Multiple aliases of the same anchor must not produce duplicate __origin__ keys. +func TestOrigin_YAMLAlias(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + + doc, err := loader.LoadFromFile("testdata/origin/alias.yaml") + require.NoError(t, err) + + anchor := doc.Components.Schemas["Base"].Value + alias1 := doc.Components.Schemas["Alias1"].Value + alias2 := doc.Components.Schemas["Alias2"].Value + + // All three point to the same anchor node, so origin reflects the anchor location. + anchorLoc := &Location{ + File: "testdata/origin/alias.yaml", + Line: 7, + Column: 5, + Name: "Base", + } + require.Equal(t, anchorLoc, anchor.Origin.Key) + require.Equal(t, anchorLoc, alias1.Origin.Key) + require.Equal(t, anchorLoc, alias2.Origin.Key) +} + +// TestOrigin_Headers verifies that response header origin is tracked correctly. +func TestOrigin_Headers(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + + doc, err := loader.LoadFromFile("testdata/origin/headers.yaml") + require.NoError(t, err) + + headers := doc.Paths.Find("/items").Get.Responses.Value("200").Value.Headers + + require.Equal(t, + &Location{ + File: "testdata/origin/headers.yaml", + Line: 12, + Column: 13, + Name: "X-Rate-Limit", + }, + headers["X-Rate-Limit"].Value.Origin.Key) + + require.Equal(t, + Location{ + File: "testdata/origin/headers.yaml", + Line: 13, + Column: 15, + Name: "description", + }, + headers["X-Rate-Limit"].Value.Origin.Fields["description"]) + + require.Equal(t, + &Location{ + File: "testdata/origin/headers.yaml", + Line: 16, + Column: 13, + Name: "X-Request-Id", + }, + headers["X-Request-Id"].Value.Origin.Key) +} + +// TestOrigin_IntegerStatusCode verifies that response origin is tracked when +// HTTP status codes are written as bare integers (200:) rather than quoted +// strings ("200":). Bare integers produce map[interface{}]interface{} in the +// YAML decoder, which required a dedicated fix in extractOrigins. +func TestOrigin_IntegerStatusCode(t *testing.T) { + loader := NewLoader() + loader.IncludeOrigin = true + + doc, err := loader.LoadFromFile("testdata/origin/parameters.yaml") + require.NoError(t, err) + + resp200 := doc.Paths.Find("/api/test").Get.Responses.Value("200").Value + require.NotNil(t, resp200.Origin) + require.Equal(t, + &Location{ + File: "testdata/origin/parameters.yaml", + Line: 14, + Column: 9, + Name: "200", + }, + resp200.Origin.Key) + + resp201 := doc.Paths.Find("/api/test").Post.Responses.Value("201").Value + require.NotNil(t, resp201.Origin) + require.Equal(t, + &Location{ + File: "testdata/origin/parameters.yaml", + Line: 18, + Column: 9, + Name: "201", + }, + resp201.Origin.Key) +} + +// TestOrigin_Disabled verifies that all Origin fields are nil when +// IncludeOrigin is false (the default), ensuring no overhead in the common case. +func TestOrigin_Disabled(t *testing.T) { + loader := NewLoader() + // IncludeOrigin defaults to false + + doc, err := loader.LoadFromFile("testdata/origin/required_sequence.yaml") + require.NoError(t, err) + + schema := doc.Paths.Find("/items").Post.RequestBody.Value.Content["application/json"].Schema.Value + require.Nil(t, schema.Origin) + require.Nil(t, doc.Info.Origin) + require.Nil(t, doc.Paths.Origin) } diff --git a/openapi3/parameter.go b/openapi3/parameter.go index 363094e5b..a5d244795 100644 --- a/openapi3/parameter.go +++ b/openapi3/parameter.go @@ -217,8 +217,6 @@ func (parameter *Parameter) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "name") delete(x.Extensions, "in") delete(x.Extensions, "description") @@ -237,7 +235,6 @@ func (parameter *Parameter) UnmarshalJSON(data []byte) error { } *parameter = Parameter(x) - parameter.Example = stripOriginFromAny(parameter.Example) return nil } @@ -421,6 +418,6 @@ func (parameter *Parameter) Validate(ctx context.Context, opts ...ValidationOpti // UnmarshalJSON sets ParametersMap to a copy of data. func (parametersMap *ParametersMap) UnmarshalJSON(data []byte) (err error) { - *parametersMap, _, err = unmarshalStringMapP[ParameterRef](data) + *parametersMap, err = unmarshalStringMapP[ParameterRef](data) return } diff --git a/openapi3/path_item.go b/openapi3/path_item.go index 8f8da8fb7..d14bbed54 100644 --- a/openapi3/path_item.go +++ b/openapi3/path_item.go @@ -99,8 +99,6 @@ func (pathItem *PathItem) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "$ref") delete(x.Extensions, "summary") delete(x.Extensions, "description") diff --git a/openapi3/race_test.go b/openapi3/race_test.go index 405942520..907ee65c2 100644 --- a/openapi3/race_test.go +++ b/openapi3/race_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestRaceyPatternSchemaValidateHindersIt(t *testing.T) { diff --git a/openapi3/request_body.go b/openapi3/request_body.go index e82f678bc..f95e31b19 100644 --- a/openapi3/request_body.go +++ b/openapi3/request_body.go @@ -109,8 +109,6 @@ func (requestBody *RequestBody) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "description") delete(x.Extensions, "required") delete(x.Extensions, "content") @@ -142,6 +140,6 @@ func (requestBody *RequestBody) Validate(ctx context.Context, opts ...Validation // UnmarshalJSON sets RequestBodies to a copy of data. func (requestBodies *RequestBodies) UnmarshalJSON(data []byte) (err error) { - *requestBodies, _, err = unmarshalStringMapP[RequestBodyRef](data) + *requestBodies, err = unmarshalStringMapP[RequestBodyRef](data) return } diff --git a/openapi3/response.go b/openapi3/response.go index 786726208..115c811a0 100644 --- a/openapi3/response.go +++ b/openapi3/response.go @@ -173,8 +173,6 @@ func (response *Response) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "description") delete(x.Extensions, "headers") delete(x.Extensions, "content") @@ -232,6 +230,6 @@ func (response *Response) Validate(ctx context.Context, opts ...ValidationOption // UnmarshalJSON sets ResponseBodies to a copy of data. func (responseBodies *ResponseBodies) UnmarshalJSON(data []byte) (err error) { - *responseBodies, _, err = unmarshalStringMapP[ResponseRef](data) + *responseBodies, err = unmarshalStringMapP[ResponseRef](data) return } diff --git a/openapi3/schema.go b/openapi3/schema.go index 3437c86b1..c59aefa95 100644 --- a/openapi3/schema.go +++ b/openapi3/schema.go @@ -413,8 +413,6 @@ func (schema *Schema) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "oneOf") delete(x.Extensions, "anyOf") delete(x.Extensions, "allOf") @@ -470,14 +468,8 @@ func (schema *Schema) UnmarshalJSON(data []byte) error { *schema = Schema(x) - for i, v := range schema.Enum { - schema.Enum[i] = stripOriginFromAny(v) - } - schema.Default = stripOriginFromAny(schema.Default) - schema.Example = stripOriginFromAny(schema.Example) - if schema.Format == "date" { - // This is a fix for: https://github.com/getkin/kin-openapi/issues/697 + // This is a fix for: https://github.com/oasdiff/kin-openapi/issues/697 if eg, ok := schema.Example.(string); ok { schema.Example = strings.TrimSuffix(eg, "T00:00:00Z") } @@ -1212,7 +1204,7 @@ func (schema *Schema) visitJSON(settings *schemaValidationSettings, value any) ( return schema.visitJSONArray(settings, value) case map[string]any: return schema.visitJSONObject(settings, value) - case map[any]any: // for YAML cf. issue https://github.com/getkin/kin-openapi/issues/444 + case map[any]any: // for YAML cf. issue https://github.com/oasdiff/kin-openapi/issues/444 values := make(map[string]any, len(value)) for key, v := range value { if k, ok := key.(string); ok { @@ -2282,6 +2274,6 @@ func unsupportedFormat(format string) error { // UnmarshalJSON sets Schemas to a copy of data. func (schemas *Schemas) UnmarshalJSON(data []byte) (err error) { - *schemas, _, err = unmarshalStringMapP[SchemaRef](data) + *schemas, err = unmarshalStringMapP[SchemaRef](data) return } diff --git a/openapi3/schema_validation_settings_test.go b/openapi3/schema_validation_settings_test.go index db52d3bdf..cc1100dc5 100644 --- a/openapi3/schema_validation_settings_test.go +++ b/openapi3/schema_validation_settings_test.go @@ -3,7 +3,7 @@ package openapi3_test import ( "fmt" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func ExampleSetSchemaErrorMessageCustomizer() { diff --git a/openapi3/security_requirements.go b/openapi3/security_requirements.go index 6af80e8b3..d5310d87a 100644 --- a/openapi3/security_requirements.go +++ b/openapi3/security_requirements.go @@ -52,6 +52,6 @@ func (security *SecurityRequirement) Validate(ctx context.Context, opts ...Valid // UnmarshalJSON sets SecurityRequirement to a copy of data. func (security *SecurityRequirement) UnmarshalJSON(data []byte) (err error) { - *security, _, err = unmarshalStringMap[[]string](data) + *security, err = unmarshalStringMap[[]string](data) return } diff --git a/openapi3/security_scheme.go b/openapi3/security_scheme.go index cb0fc86a6..df09bd468 100644 --- a/openapi3/security_scheme.go +++ b/openapi3/security_scheme.go @@ -101,8 +101,6 @@ func (ss *SecurityScheme) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "type") delete(x.Extensions, "description") delete(x.Extensions, "name") @@ -274,8 +272,6 @@ func (flows *OAuthFlows) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "implicit") delete(x.Extensions, "password") delete(x.Extensions, "clientCredentials") @@ -367,8 +363,6 @@ func (flow *OAuthFlow) UnmarshalJSON(data []byte) error { } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "authorizationUrl") delete(x.Extensions, "tokenUrl") delete(x.Extensions, "refreshUrl") @@ -440,6 +434,6 @@ func (flow *OAuthFlow) validate(ctx context.Context, typ oAuthFlowType, opts ... // UnmarshalJSON sets SecuritySchemes to a copy of data. func (securitySchemes *SecuritySchemes) UnmarshalJSON(data []byte) (err error) { - *securitySchemes, _, err = unmarshalStringMapP[SecuritySchemeRef](data) + *securitySchemes, err = unmarshalStringMapP[SecuritySchemeRef](data) return } diff --git a/openapi3/server.go b/openapi3/server.go index 40c8464f8..df0fafe9f 100644 --- a/openapi3/server.go +++ b/openapi3/server.go @@ -115,8 +115,6 @@ func (server *Server) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "url") delete(x.Extensions, "description") delete(x.Extensions, "variables") @@ -240,7 +238,7 @@ type ServerVariables map[string]*ServerVariable // UnmarshalJSON sets ServerVariables to a copy of data, stripping __origin__ metadata. func (serverVariables *ServerVariables) UnmarshalJSON(data []byte) (err error) { - *serverVariables, _, err = unmarshalStringMapP[ServerVariable](data) + *serverVariables, err = unmarshalStringMapP[ServerVariable](data) return } @@ -288,8 +286,6 @@ func (serverVariable *ServerVariable) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "enum") delete(x.Extensions, "default") delete(x.Extensions, "description") diff --git a/openapi3/stringmap.go b/openapi3/stringmap.go index 10e7e6de0..5cd68a5dc 100644 --- a/openapi3/stringmap.go +++ b/openapi3/stringmap.go @@ -7,56 +7,46 @@ type StringMap[V any] map[string]V // UnmarshalJSON sets StringMap to a copy of data. func (stringMap *StringMap[V]) UnmarshalJSON(data []byte) (err error) { - *stringMap, _, err = unmarshalStringMap[V](data) + *stringMap, err = unmarshalStringMap[V](data) return } // unmarshalStringMapP unmarshals given json into a map[string]*V -func unmarshalStringMapP[V any](data []byte) (map[string]*V, *Origin, error) { +func unmarshalStringMapP[V any](data []byte) (map[string]*V, error) { var m map[string]any if err := json.Unmarshal(data, &m); err != nil { - return nil, nil, err - } - - origin, err := popOrigin(m, originKey) - if err != nil { - return nil, nil, err + return nil, err } result := make(map[string]*V, len(m)) for k, v := range m { value, err := deepCast[V](v) if err != nil { - return nil, nil, err + return nil, err } result[k] = value } - return result, origin, nil + return result, nil } // unmarshalStringMap unmarshals given json into a map[string]V -func unmarshalStringMap[V any](data []byte) (map[string]V, *Origin, error) { +func unmarshalStringMap[V any](data []byte) (map[string]V, error) { var m map[string]any if err := json.Unmarshal(data, &m); err != nil { - return nil, nil, err - } - - origin, err := popOrigin(m, originKey) - if err != nil { - return nil, nil, err + return nil, err } result := make(map[string]V, len(m)) for k, v := range m { value, err := deepCast[V](v) if err != nil { - return nil, nil, err + return nil, err } result[k] = *value } - return result, origin, nil + return result, nil } // deepCast casts any value to a value of type V. @@ -72,17 +62,3 @@ func deepCast[V any](value any) (*V, error) { } return &result, nil } - -// popOrigin removes the origin from the map and returns it. -func popOrigin(m map[string]any, key string) (*Origin, error) { - if !IncludeOrigin { - return nil, nil - } - - origin, err := deepCast[Origin](m[key]) - if err != nil { - return nil, err - } - delete(m, key) - return origin, nil -} diff --git a/openapi3/tag.go b/openapi3/tag.go index 401893936..f5d6accbb 100644 --- a/openapi3/tag.go +++ b/openapi3/tag.go @@ -76,8 +76,6 @@ func (t *Tag) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "name") delete(x.Extensions, "description") delete(x.Extensions, "externalDocs") diff --git a/openapi3/testdata/origin/alias.yaml b/openapi3/testdata/origin/alias.yaml new file mode 100644 index 000000000..9ab85fe2f --- /dev/null +++ b/openapi3/testdata/origin/alias.yaml @@ -0,0 +1,25 @@ +openapi: 3.0.0 +info: + title: Alias Test + version: 1.0.0 +components: + schemas: + Base: &base + type: object + properties: + id: + type: integer + name: + type: string + Alias1: *base + Alias2: *base +paths: + /items: + get: + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Alias1" diff --git a/openapi3/testdata/origin/any_fields.yaml b/openapi3/testdata/origin/any_fields.yaml new file mode 100644 index 000000000..88d55b893 --- /dev/null +++ b/openapi3/testdata/origin/any_fields.yaml @@ -0,0 +1,42 @@ +openapi: 3.0.0 +info: + title: Any Fields Test + version: 1.0.0 +paths: + /items: + get: + parameters: + - name: filter + in: query + example: + env: production + region: us-east + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + example: + id: 1 + name: example + schema: + type: object + default: + status: active + count: 0 + example: + status: active + count: 42 + enum: + - status: active + count: 1 + - status: inactive + count: 0 + links: + self: + operationId: getItem + requestBody: + id: 1 + name: test diff --git a/openapi3/testdata/origin/components.yaml b/openapi3/testdata/origin/components.yaml new file mode 100644 index 000000000..6c4accbc3 --- /dev/null +++ b/openapi3/testdata/origin/components.yaml @@ -0,0 +1,80 @@ +openapi: 3.0.1 +info: + title: Test API + version: v1 +components: + schemas: + SomeObject: + type: object + properties: + code: + type: integer + text: + type: string + parameters: + SomeParameter: + name: some-parameter + in: query + schema: + type: string + headers: + SomeHeader: + description: Some header + schema: + type: string + requestBodies: + SomeRequestBody: + description: Some request body + content: + application/json: + schema: + type: object + properties: + code: + type: integer + text: + type: string + responses: + SomeResponse: + description: Some response + content: + application/json: + schema: + type: object + properties: + code: + type: integer + text: + type: string + securitySchemes: + SomeSecurityScheme: + type: http + scheme: basic + examples: + SomeExample: + summary: Some example + value: + code: 123 + text: Some text + links: + SomeLink: + description: Some link + operationId: someOperation + callbacks: + SomeCallback: + '{$request.query.callbackUrl}': + post: + requestBody: + description: Some callback request body + content: + application/json: + schema: + type: object + properties: + code: + type: integer + text: + type: string + responses: + "200": + description: OK \ No newline at end of file diff --git a/openapi3/testdata/origin/headers.yaml b/openapi3/testdata/origin/headers.yaml new file mode 100644 index 000000000..e92928ad3 --- /dev/null +++ b/openapi3/testdata/origin/headers.yaml @@ -0,0 +1,19 @@ +openapi: 3.0.0 +info: + title: Headers Test + version: 1.0.0 +paths: + /items: + get: + responses: + "200": + description: OK + headers: + X-Rate-Limit: + description: Rate limit per hour + schema: + type: integer + X-Request-Id: + description: Unique request ID + schema: + type: string diff --git a/openapi3/testdata/origin/required_sequence.yaml b/openapi3/testdata/origin/required_sequence.yaml new file mode 100644 index 000000000..778a32601 --- /dev/null +++ b/openapi3/testdata/origin/required_sequence.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.0 +info: + title: Required Sequence Test + version: 1.0.0 +paths: + /items: + post: + requestBody: + content: + application/json: + schema: + type: object + required: + - name + - age + properties: + name: + type: string + age: + type: integer + responses: + "200": + description: OK diff --git a/openapi3/unique_items_checker_test.go b/openapi3/unique_items_checker_test.go index 1c81180b4..7599cde11 100644 --- a/openapi3/unique_items_checker_test.go +++ b/openapi3/unique_items_checker_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestRegisterArrayUniqueItemsChecker(t *testing.T) { diff --git a/openapi3/validation_issue409_test.go b/openapi3/validation_issue409_test.go index 561594fca..cc522823a 100644 --- a/openapi3/validation_issue409_test.go +++ b/openapi3/validation_issue409_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func TestIssue409PatternIgnored(t *testing.T) { diff --git a/openapi3/xml.go b/openapi3/xml.go index 543b32def..4719c8ff8 100644 --- a/openapi3/xml.go +++ b/openapi3/xml.go @@ -59,8 +59,6 @@ func (xml *XML) UnmarshalJSON(data []byte) error { return unmarshalError(err) } _ = json.Unmarshal(data, &x.Extensions) - delete(x.Extensions, originKey) - stripExtensionsOrigin(x.Extensions) delete(x.Extensions, "name") delete(x.Extensions, "namespace") delete(x.Extensions, "prefix") diff --git a/openapi3filter/authentication_input.go b/openapi3filter/authentication_input.go index a53484b99..6ad34b4a1 100644 --- a/openapi3filter/authentication_input.go +++ b/openapi3filter/authentication_input.go @@ -3,7 +3,7 @@ package openapi3filter import ( "fmt" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) type AuthenticationInput struct { diff --git a/openapi3filter/csv_file_upload_test.go b/openapi3filter/csv_file_upload_test.go index 89efb96d9..c3e83beab 100644 --- a/openapi3filter/csv_file_upload_test.go +++ b/openapi3filter/csv_file_upload_test.go @@ -12,9 +12,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestValidateCsvFileUpload(t *testing.T) { diff --git a/openapi3filter/errors.go b/openapi3filter/errors.go index ea7c7c312..61a2b2ff0 100644 --- a/openapi3filter/errors.go +++ b/openapi3filter/errors.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) var _ error = &RequestError{} diff --git a/openapi3filter/issue1045_test.go b/openapi3filter/issue1045_test.go index 048dbd374..fa084b47d 100644 --- a/openapi3filter/issue1045_test.go +++ b/openapi3filter/issue1045_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue1045(t *testing.T) { diff --git a/openapi3filter/issue1110_test.go b/openapi3filter/issue1110_test.go index a3dfb475f..b821b578b 100644 --- a/openapi3filter/issue1110_test.go +++ b/openapi3filter/issue1110_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue1110(t *testing.T) { diff --git a/openapi3filter/issue201_test.go b/openapi3filter/issue201_test.go index ec0b2a1f1..dcc0c5ac9 100644 --- a/openapi3filter/issue201_test.go +++ b/openapi3filter/issue201_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue201(t *testing.T) { diff --git a/openapi3filter/issue267_test.go b/openapi3filter/issue267_test.go index 44e0cab10..907a90f75 100644 --- a/openapi3filter/issue267_test.go +++ b/openapi3filter/issue267_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue267(t *testing.T) { diff --git a/openapi3filter/issue436_test.go b/openapi3filter/issue436_test.go index fa106c5a1..f8ff942c3 100644 --- a/openapi3filter/issue436_test.go +++ b/openapi3filter/issue436_test.go @@ -9,9 +9,9 @@ import ( "net/textproto" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func Example_validateMultipartFormData() { diff --git a/openapi3filter/issue624_test.go b/openapi3filter/issue624_test.go index 1fdbdea34..c5c402969 100644 --- a/openapi3filter/issue624_test.go +++ b/openapi3filter/issue624_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue624(t *testing.T) { diff --git a/openapi3filter/issue625_test.go b/openapi3filter/issue625_test.go index d92906457..6cbed8114 100644 --- a/openapi3filter/issue625_test.go +++ b/openapi3filter/issue625_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue625(t *testing.T) { diff --git a/openapi3filter/issue639_test.go b/openapi3filter/issue639_test.go index 136967953..3482dc6d1 100644 --- a/openapi3filter/issue639_test.go +++ b/openapi3filter/issue639_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue639(t *testing.T) { diff --git a/openapi3filter/issue641_test.go b/openapi3filter/issue641_test.go index 845e3f7e1..ed565d18c 100644 --- a/openapi3filter/issue641_test.go +++ b/openapi3filter/issue641_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue641(t *testing.T) { diff --git a/openapi3filter/issue689_test.go b/openapi3filter/issue689_test.go index 592d53f74..08512b209 100644 --- a/openapi3filter/issue689_test.go +++ b/openapi3filter/issue689_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue689(t *testing.T) { diff --git a/openapi3filter/issue707_test.go b/openapi3filter/issue707_test.go index a7cbc39ed..b884a2f72 100644 --- a/openapi3filter/issue707_test.go +++ b/openapi3filter/issue707_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue707(t *testing.T) { diff --git a/openapi3filter/issue722_test.go b/openapi3filter/issue722_test.go index 73648e0fe..ba8d0ce48 100644 --- a/openapi3filter/issue722_test.go +++ b/openapi3filter/issue722_test.go @@ -10,9 +10,9 @@ import ( "strings" "testing" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestValidateMultipartFormDataContainingAllOf(t *testing.T) { diff --git a/openapi3filter/issue733_test.go b/openapi3filter/issue733_test.go index f43a826e8..9810ab958 100644 --- a/openapi3filter/issue733_test.go +++ b/openapi3filter/issue733_test.go @@ -12,9 +12,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIntMax(t *testing.T) { diff --git a/openapi3filter/issue743_test.go b/openapi3filter/issue743_test.go index 24122e104..60f079ed2 100644 --- a/openapi3filter/issue743_test.go +++ b/openapi3filter/issue743_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -72,7 +72,7 @@ security: AuthenticationFunc: func(ctx context.Context, ai *openapi3filter.AuthenticationInput) error { defer req.Body.Close() - // NOTE that reading from `req.Body` appears to trigger the underlying issue raised in https://github.com/getkin/kin-openapi/issues/743 + // NOTE that reading from `req.Body` appears to trigger the underlying issue raised in https://github.com/oasdiff/kin-openapi/issues/743 // this doesn't seem to occur when using `req.GetBody()`, but as that's less common to do, we should support both types body, err := io.ReadAll(ai.RequestValidationInput.Request.Body) assert.NoError(t, err) @@ -131,7 +131,7 @@ security: authenticatorFunc := func(ctx context.Context, ai *openapi3filter.AuthenticationInput) error { defer ai.RequestValidationInput.Request.Body.Close() - // NOTE that reading from `req.Body` appears to trigger the underlying issue raised in https://github.com/getkin/kin-openapi/issues/743 + // NOTE that reading from `req.Body` appears to trigger the underlying issue raised in https://github.com/oasdiff/kin-openapi/issues/743 // this doesn't seem to occur when using `req.GetBody()`, but as that's less common to do, we should support both types body, err := io.ReadAll(ai.RequestValidationInput.Request.Body) assert.NoError(t, err) diff --git a/openapi3filter/issue789_test.go b/openapi3filter/issue789_test.go index 79d471849..96fbd12f2 100644 --- a/openapi3filter/issue789_test.go +++ b/openapi3filter/issue789_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue789(t *testing.T) { diff --git a/openapi3filter/issue884_test.go b/openapi3filter/issue884_test.go index ea6e461c0..e91a0811a 100644 --- a/openapi3filter/issue884_test.go +++ b/openapi3filter/issue884_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue884(t *testing.T) { diff --git a/openapi3filter/issue949_test.go b/openapi3filter/issue949_test.go index f87fae378..0a5535dbe 100644 --- a/openapi3filter/issue949_test.go +++ b/openapi3filter/issue949_test.go @@ -12,9 +12,9 @@ import ( "strings" "testing" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" "github.com/stretchr/testify/require" ) diff --git a/openapi3filter/middleware.go b/openapi3filter/middleware.go index d20889ed9..da3bbef1c 100644 --- a/openapi3filter/middleware.go +++ b/openapi3filter/middleware.go @@ -7,7 +7,7 @@ import ( "log" "net/http" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/routers" ) // Validator provides HTTP request and response validation middleware. diff --git a/openapi3filter/middleware_test.go b/openapi3filter/middleware_test.go index d492bec0c..711fed1f7 100644 --- a/openapi3filter/middleware_test.go +++ b/openapi3filter/middleware_test.go @@ -16,9 +16,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) const validatorSpec = ` diff --git a/openapi3filter/options.go b/openapi3filter/options.go index b85f932b2..9520eb7c2 100644 --- a/openapi3filter/options.go +++ b/openapi3filter/options.go @@ -1,6 +1,6 @@ package openapi3filter -import "github.com/getkin/kin-openapi/openapi3" +import "github.com/oasdiff/kin-openapi/openapi3" // Options used by ValidateRequest and ValidateResponse type Options struct { diff --git a/openapi3filter/options_test.go b/openapi3filter/options_test.go index fd19329ff..8f4165638 100644 --- a/openapi3filter/options_test.go +++ b/openapi3filter/options_test.go @@ -6,9 +6,9 @@ import ( "net/http" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func ExampleOptions_WithCustomSchemaErrorFunc() { diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go index 3e71a8735..03543e306 100644 --- a/openapi3filter/req_resp_decoder.go +++ b/openapi3filter/req_resp_decoder.go @@ -19,7 +19,7 @@ import ( yaml "github.com/oasdiff/yaml3" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // ParseErrorKind describes a kind of ParseError. diff --git a/openapi3filter/req_resp_decoder_test.go b/openapi3filter/req_resp_decoder_test.go index ee59b11f3..f2359db42 100644 --- a/openapi3filter/req_resp_decoder_test.go +++ b/openapi3filter/req_resp_decoder_test.go @@ -17,8 +17,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) var ( diff --git a/openapi3filter/testdata/issue1100_test.go b/openapi3filter/testdata/issue1100_test.go index b5147dfe8..498cc852c 100644 --- a/openapi3filter/testdata/issue1100_test.go +++ b/openapi3filter/testdata/issue1100_test.go @@ -5,11 +5,11 @@ import ( "strings" "testing" - "github.com/getkin/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/openapi3filter" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestIssue1100(t *testing.T) { diff --git a/openapi3filter/unpack_errors_test.go b/openapi3filter/unpack_errors_test.go index 3ebe5c0bd..220ab649b 100644 --- a/openapi3filter/unpack_errors_test.go +++ b/openapi3filter/unpack_errors_test.go @@ -7,9 +7,9 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func Example() { diff --git a/openapi3filter/upload_arbitrary_file_test.go b/openapi3filter/upload_arbitrary_file_test.go index f0d771f04..744c1ce67 100644 --- a/openapi3filter/upload_arbitrary_file_test.go +++ b/openapi3filter/upload_arbitrary_file_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestValidateUploadArbitraryBinaryFile(t *testing.T) { diff --git a/openapi3filter/validate_readonly_test.go b/openapi3filter/validate_readonly_test.go index d640f274f..02d3c7dd5 100644 --- a/openapi3filter/validate_readonly_test.go +++ b/openapi3filter/validate_readonly_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestReadOnlyWriteOnlyPropertiesValidation(t *testing.T) { diff --git a/openapi3filter/validate_request.go b/openapi3filter/validate_request.go index b064de8ed..62cd15def 100644 --- a/openapi3filter/validate_request.go +++ b/openapi3filter/validate_request.go @@ -11,7 +11,7 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // ErrAuthenticationServiceMissing is returned when no authentication service diff --git a/openapi3filter/validate_request_example_test.go b/openapi3filter/validate_request_example_test.go index 653db3039..8e343b6ee 100644 --- a/openapi3filter/validate_request_example_test.go +++ b/openapi3filter/validate_request_example_test.go @@ -7,8 +7,8 @@ import ( "log" "net/http" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func ExampleAuthenticationFunc() { diff --git a/openapi3filter/validate_request_input.go b/openapi3filter/validate_request_input.go index c7565ebb7..c666eee37 100644 --- a/openapi3filter/validate_request_input.go +++ b/openapi3filter/validate_request_input.go @@ -4,8 +4,8 @@ import ( "net/http" "net/url" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) // A ContentParameterDecoder takes a parameter definition from the OpenAPI spec, diff --git a/openapi3filter/validate_request_test.go b/openapi3filter/validate_request_test.go index 82b091294..b5a8b3f20 100644 --- a/openapi3filter/validate_request_test.go +++ b/openapi3filter/validate_request_test.go @@ -13,10 +13,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" - "github.com/getkin/kin-openapi/routers/gorillamux" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/routers/gorillamux" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func setupTestRouter(t *testing.T, spec string) routers.Router { diff --git a/openapi3filter/validate_response.go b/openapi3filter/validate_response.go index 5fb330900..b05e77e3e 100644 --- a/openapi3filter/validate_response.go +++ b/openapi3filter/validate_response.go @@ -10,7 +10,7 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // ValidateResponse is used to validate the given input according to previous diff --git a/openapi3filter/validate_response_test.go b/openapi3filter/validate_response_test.go index e61a58192..7027f5a70 100644 --- a/openapi3filter/validate_response_test.go +++ b/openapi3filter/validate_response_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) func Test_validateResponseHeader(t *testing.T) { diff --git a/openapi3filter/validate_set_default_test.go b/openapi3filter/validate_set_default_test.go index 03c863388..af4e9b137 100644 --- a/openapi3filter/validate_set_default_test.go +++ b/openapi3filter/validate_set_default_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestValidatingRequestParameterAndSetDefault(t *testing.T) { diff --git a/openapi3filter/validation_discriminator_test.go b/openapi3filter/validation_discriminator_test.go index adabf409d..e439b46fd 100644 --- a/openapi3filter/validation_discriminator_test.go +++ b/openapi3filter/validation_discriminator_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestValidationWithDiscriminatorSelection(t *testing.T) { diff --git a/openapi3filter/validation_enum_test.go b/openapi3filter/validation_enum_test.go index aae3a1ffa..a3ce9a2cb 100644 --- a/openapi3filter/validation_enum_test.go +++ b/openapi3filter/validation_enum_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestValidationWithIntegerEnum(t *testing.T) { diff --git a/openapi3filter/validation_error_encoder.go b/openapi3filter/validation_error_encoder.go index 4369ca6b3..aa19d12ad 100644 --- a/openapi3filter/validation_error_encoder.go +++ b/openapi3filter/validation_error_encoder.go @@ -6,8 +6,8 @@ import ( "net/http" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) // ValidationErrorEncoder wraps a base ErrorEncoder to handle ValidationErrors diff --git a/openapi3filter/validation_error_test.go b/openapi3filter/validation_error_test.go index 8a1ff8262..c69feafdf 100644 --- a/openapi3filter/validation_error_test.go +++ b/openapi3filter/validation_error_test.go @@ -12,8 +12,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) func newPetstoreRequest(t *testing.T, method, path string, body io.Reader) *http.Request { diff --git a/openapi3filter/validation_handler.go b/openapi3filter/validation_handler.go index d4bb1efa0..1acd377d0 100644 --- a/openapi3filter/validation_handler.go +++ b/openapi3filter/validation_handler.go @@ -4,9 +4,9 @@ import ( "context" "net/http" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) // AuthenticationFunc allows for custom security requirement validation. diff --git a/openapi3filter/validation_test.go b/openapi3filter/validation_test.go index 865ffa254..16810a720 100644 --- a/openapi3filter/validation_test.go +++ b/openapi3filter/validation_test.go @@ -15,8 +15,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) type ExampleRequest struct { diff --git a/openapi3filter/zip_file_upload_test.go b/openapi3filter/zip_file_upload_test.go index a61804062..1182111d1 100644 --- a/openapi3filter/zip_file_upload_test.go +++ b/openapi3filter/zip_file_upload_test.go @@ -11,9 +11,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func TestValidateZipFileUpload(t *testing.T) { diff --git a/openapi3gen/openapi3gen.go b/openapi3gen/openapi3gen.go index 5d9b64abf..740cd5a15 100644 --- a/openapi3gen/openapi3gen.go +++ b/openapi3gen/openapi3gen.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // CycleError indicates that a type graph has one or more possible cycles. diff --git a/openapi3gen/openapi3gen_newschemarefforvalue_test.go b/openapi3gen/openapi3gen_newschemarefforvalue_test.go index ada3d8860..ef0965296 100644 --- a/openapi3gen/openapi3gen_newschemarefforvalue_test.go +++ b/openapi3gen/openapi3gen_newschemarefforvalue_test.go @@ -6,9 +6,9 @@ import ( "reflect" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3gen" - "github.com/getkin/kin-openapi/openapi3gen/internal/subpkg" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3gen" + "github.com/oasdiff/kin-openapi/openapi3gen/internal/subpkg" ) // Make sure that custom schema name generator is employed and results produced with it are properly used diff --git a/openapi3gen/openapi3gen_test.go b/openapi3gen/openapi3gen_test.go index e18d8619c..06171a5f9 100644 --- a/openapi3gen/openapi3gen_test.go +++ b/openapi3gen/openapi3gen_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3gen" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3gen" ) func ExampleGenerator_SchemaRefs() { @@ -330,7 +330,7 @@ func TestEmbeddedPointerStructs(t *testing.T) { require.Equal(t, true, ok) } -// See: https://github.com/getkin/kin-openapi/issues/500 +// See: https://github.com/oasdiff/kin-openapi/issues/500 func TestEmbeddedPointerStructsWithSchemaCustomizer(t *testing.T) { type EmbeddedStruct struct { ID string diff --git a/openapi3gen/simple_test.go b/openapi3gen/simple_test.go index 11b3b26a4..1702b59ef 100644 --- a/openapi3gen/simple_test.go +++ b/openapi3gen/simple_test.go @@ -5,7 +5,7 @@ import ( "fmt" "time" - "github.com/getkin/kin-openapi/openapi3gen" + "github.com/oasdiff/kin-openapi/openapi3gen" ) type ( diff --git a/routers/gorillamux/example_test.go b/routers/gorillamux/example_test.go index 9f949bdc5..43c61bb0b 100644 --- a/routers/gorillamux/example_test.go +++ b/routers/gorillamux/example_test.go @@ -5,9 +5,9 @@ import ( "fmt" "net/http" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/gorillamux" ) func Example() { diff --git a/routers/gorillamux/router.go b/routers/gorillamux/router.go index c73a70312..2b39a980b 100644 --- a/routers/gorillamux/router.go +++ b/routers/gorillamux/router.go @@ -15,8 +15,8 @@ import ( "github.com/gorilla/mux" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) var _ routers.Router = &Router{} @@ -151,7 +151,7 @@ func makeServers(in openapi3.Servers) ([]srv, error) { // then url.Parse() cannot parse "http://domain.tld:`bEncode({port})`/bla" // and mux is not able to set the {port} variable // So we just use the default value for this variable. - // See https://github.com/getkin/kin-openapi/issues/367 + // See https://github.com/oasdiff/kin-openapi/issues/367 var varsUpdater varsf if lhs := strings.Index(serverURL, ":{"); lhs > 0 { rest := serverURL[lhs+len(":{"):] diff --git a/routers/gorillamux/router_test.go b/routers/gorillamux/router_test.go index 4f40719b6..b29c65c81 100644 --- a/routers/gorillamux/router_test.go +++ b/routers/gorillamux/router_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) func TestRouter(t *testing.T) { diff --git a/routers/issue356_test.go b/routers/issue356_test.go index 100e0183d..cba550ff8 100644 --- a/routers/issue356_test.go +++ b/routers/issue356_test.go @@ -10,11 +10,11 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers" - "github.com/getkin/kin-openapi/routers/gorillamux" - "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/routers/gorillamux" + "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestIssue356(t *testing.T) { diff --git a/routers/legacy/issue444_test.go b/routers/legacy/issue444_test.go index c1e9b14f2..e0ef2f5e6 100644 --- a/routers/legacy/issue444_test.go +++ b/routers/legacy/issue444_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - legacyrouter "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + legacyrouter "github.com/oasdiff/kin-openapi/routers/legacy" ) func TestIssue444(t *testing.T) { diff --git a/routers/legacy/router.go b/routers/legacy/router.go index 306449d3c..ce5ddac16 100644 --- a/routers/legacy/router.go +++ b/routers/legacy/router.go @@ -13,9 +13,9 @@ import ( "net/http" "strings" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" - "github.com/getkin/kin-openapi/routers/legacy/pathpattern" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/routers/legacy/pathpattern" ) // Routers maps a HTTP request to a Router. diff --git a/routers/legacy/router_test.go b/routers/legacy/router_test.go index 2bc30ea83..0a2dedc18 100644 --- a/routers/legacy/router_test.go +++ b/routers/legacy/router_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/routers" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/routers" ) func TestRouter(t *testing.T) { diff --git a/routers/legacy/validate_request_test.go b/routers/legacy/validate_request_test.go index 77d8bc1de..e21f01ae5 100644 --- a/routers/legacy/validate_request_test.go +++ b/routers/legacy/validate_request_test.go @@ -6,9 +6,9 @@ import ( "fmt" "net/http" - "github.com/getkin/kin-openapi/openapi3" - "github.com/getkin/kin-openapi/openapi3filter" - "github.com/getkin/kin-openapi/routers/legacy" + "github.com/oasdiff/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3filter" + "github.com/oasdiff/kin-openapi/routers/legacy" ) const spec = ` diff --git a/routers/types.go b/routers/types.go index 93746cfe9..1a3ae9bbf 100644 --- a/routers/types.go +++ b/routers/types.go @@ -3,7 +3,7 @@ package routers import ( "net/http" - "github.com/getkin/kin-openapi/openapi3" + "github.com/oasdiff/kin-openapi/openapi3" ) // Router helps link http.Request.s and an OpenAPIv3 spec