diff --git a/checker/checker_not_breaking_test.go b/checker/checker_not_breaking_test.go index 840f68b7..c1876abe 100644 --- a/checker/checker_not_breaking_test.go +++ b/checker/checker_not_breaking_test.go @@ -167,21 +167,19 @@ func TestBreaking_NewRequiredResponseHeader(t *testing.T) { // BC: changing operation ID is not breaking func TestBreaking_OperationID(t *testing.T) { r := d(t, getConfig(), 3, 1) - require.Len(t, r, 4) + require.Len(t, r, 3) require.Equal(t, checker.RequestParameterMaxLengthDecreasedId, r[0].GetId()) require.Equal(t, checker.RequestParameterEnumValueRemovedId, r[1].GetId()) require.Equal(t, checker.RequestParameterPatternAddedId, r[2].GetId()) - require.Equal(t, checker.RequestParameterRemovedId, r[3].GetId()) } // BC: changing a link to operation ID is not breaking func TestBreaking_LinkOperationID(t *testing.T) { r := d(t, getConfig(), 3, 1) - require.Len(t, r, 4) + require.Len(t, r, 3) require.Equal(t, checker.RequestParameterMaxLengthDecreasedId, r[0].GetId()) require.Equal(t, checker.RequestParameterEnumValueRemovedId, r[1].GetId()) require.Equal(t, checker.RequestParameterPatternAddedId, r[2].GetId()) - require.Equal(t, checker.RequestParameterRemovedId, r[3].GetId()) } // BC: adding a media-type to response is not breaking diff --git a/data/param-inheritance/path_revision.yaml b/data/path-params/no_params.yaml similarity index 96% rename from data/param-inheritance/path_revision.yaml rename to data/path-params/no_params.yaml index 0da06466..6060d026 100644 --- a/data/param-inheritance/path_revision.yaml +++ b/data/path-params/no_params.yaml @@ -5,7 +5,7 @@ info: description: Some desc contact: name: '#onetwothree' - url: 'https://test.com22' + url: 'https://test.com' servers: - description: local url: 'http://localhost:8080' diff --git a/data/path-params/params_in_op.yaml b/data/path-params/params_in_op.yaml new file mode 100644 index 00000000..2eaf502e --- /dev/null +++ b/data/path-params/params_in_op.yaml @@ -0,0 +1,56 @@ +openapi: 3.0.0 +info: + title: Some API + version: 1.0.0 + description: Some desc + contact: + name: '#onetwothree' + url: 'https://test.com' +servers: + - description: local + url: 'http://localhost:8080' +tags: + - name: One + - name: Two +paths: + '/admin/v0/abc/{id}': + get: + parameters: + - $ref: '#/components/parameters/tenant_id' + - $ref: '#/components/parameters/id' + summary: Get abc + tags: + - Two + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/abc' +components: + schemas: + abc: + title: abc + x-stoplight: + id: lzwt7se3t6ab2 + type: object + properties: + details: + type: string + + parameters: + tenant_id: + schema: + type: string + in: header + required: true + name: tenant-id + description: 'Tenant IDs' + id: + name: id + in: path + required: true + schema: + type: string + description: 'The ID' \ No newline at end of file diff --git a/data/param-inheritance/path_base.yaml b/data/path-params/params_in_path.yaml similarity index 100% rename from data/param-inheritance/path_base.yaml rename to data/path-params/params_in_path.yaml diff --git a/diff/diff_test.go b/diff/diff_test.go index d6fa2d19..2336eb4d 100644 --- a/diff/diff_test.go +++ b/diff/diff_test.go @@ -7,6 +7,7 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/stretchr/testify/require" "github.com/tufin/oasdiff/diff" + "github.com/tufin/oasdiff/flatten/pathparams" "github.com/tufin/oasdiff/load" "github.com/tufin/oasdiff/utils" ) @@ -919,14 +920,16 @@ func TestDiff_DifferentComponentSameHeader(t *testing.T) { require.Empty(t, d) } -func TestDiff_MovedParam(t *testing.T) { +func TestDiff_PathParamsDeleted(t *testing.T) { loader := openapi3.NewLoader() - s1, err := loader.LoadFromFile("../data/param-inheritance/path_base.yaml") + s1, err := loader.LoadFromFile("../data/path-params/params_in_path.yaml") require.NoError(t, err) + pathparams.Inherit(s1) - s2, err := loader.LoadFromFile("../data/param-inheritance/path_revision.yaml") + s2, err := loader.LoadFromFile("../data/path-params/no_params.yaml") require.NoError(t, err) + pathparams.Inherit(s2) d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), &load.SpecInfo{ @@ -936,5 +939,49 @@ func TestDiff_MovedParam(t *testing.T) { Spec: s2, }) require.NoError(t, err) - require.NotEmpty(t, d.EndpointsDiff) + require.NotEmpty(t, d.EndpointsDiff.Modified[diff.Endpoint{Method: "GET", Path: "/admin/v0/abc/{id}"}].ParametersDiff.Deleted) +} + +func TestDiff_PathParamsMoved(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/path-params/params_in_path.yaml") + require.NoError(t, err) + pathparams.Inherit(s1) + + s2, err := loader.LoadFromFile("../data/path-params/params_in_op.yaml") + require.NoError(t, err) + pathparams.Inherit(s2) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s2, + }) + require.NoError(t, err) + require.Empty(t, d) +} + +func TestDiff_PathParamsAdded(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/path-params/no_params.yaml") + require.NoError(t, err) + pathparams.Inherit(s1) + + s2, err := loader.LoadFromFile("../data/path-params/params_in_path.yaml") + require.NoError(t, err) + pathparams.Inherit(s2) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s2, + }) + require.NoError(t, err) + require.NotEmpty(t, d.EndpointsDiff.Modified[diff.Endpoint{Method: "GET", Path: "/admin/v0/abc/{id}"}].ParametersDiff.Added) } diff --git a/diff/method_diff.go b/diff/method_diff.go index c2806230..1045f3da 100644 --- a/diff/method_diff.go +++ b/diff/method_diff.go @@ -36,10 +36,9 @@ func (methodDiff *MethodDiff) Empty() bool { return *methodDiff == MethodDiff{Base: methodDiff.Base, Revision: methodDiff.Revision} } -func getMethodDiff(config *Config, state *state, operation1, operation2 *openapi3.Operation, pathParamsMap PathParamsMap, - pathParams1, pathParams2 openapi3.Parameters) (*MethodDiff, error) { +func getMethodDiff(config *Config, state *state, operation1, operation2 *openapi3.Operation, pathParamsMap PathParamsMap) (*MethodDiff, error) { - diff, err := getMethodDiffInternal(config, state, operation1, operation2, pathParamsMap, pathParams1, pathParams2) + diff, err := getMethodDiffInternal(config, state, operation1, operation2, pathParamsMap) if err != nil { return nil, err @@ -52,8 +51,7 @@ func getMethodDiff(config *Config, state *state, operation1, operation2 *openapi return diff, nil } -func getMethodDiffInternal(config *Config, state *state, operation1, operation2 *openapi3.Operation, pathParamsMap PathParamsMap, - pathParams1, pathParams2 openapi3.Parameters) (*MethodDiff, error) { +func getMethodDiffInternal(config *Config, state *state, operation1, operation2 *openapi3.Operation, pathParamsMap PathParamsMap) (*MethodDiff, error) { result := newMethodDiff() var err error @@ -63,7 +61,7 @@ func getMethodDiffInternal(config *Config, state *state, operation1, operation2 result.SummaryDiff = getValueDiffConditional(config.IsExcludeSummary(), operation1.Summary, operation2.Summary) result.DescriptionDiff = getValueDiffConditional(config.IsExcludeDescription(), operation1.Description, operation2.Description) result.OperationIDDiff = getValueDiff(operation1.OperationID, operation2.OperationID) - result.ParametersDiff, err = getParametersDiffByLocation(config, state, paramsInherit(pathParams1, operation1.Parameters), paramsInherit(pathParams2, operation2.Parameters), pathParamsMap) + result.ParametersDiff, err = getParametersDiffByLocation(config, state, operation1.Parameters, operation2.Parameters, pathParamsMap) if err != nil { return nil, err } diff --git a/diff/operations_diff.go b/diff/operations_diff.go index f4c3ee85..d0f4ba9e 100644 --- a/diff/operations_diff.go +++ b/diff/operations_diff.go @@ -76,8 +76,7 @@ func getOperationsDiffInternal(config *Config, state *state, pathItemPair *pathI var err error for _, op := range operations { - err = result.diffOperation(config, state, pathItemPair.PathItem1.GetOperation(op), pathItemPair.PathItem2.GetOperation(op), op, pathItemPair.PathParamsMap, - pathItemPair.PathItem1.Parameters, pathItemPair.PathItem2.Parameters) + err = result.diffOperation(config, state, pathItemPair.PathItem1.GetOperation(op), pathItemPair.PathItem2.GetOperation(op), op, pathItemPair.PathParamsMap) if err != nil { return nil, err } @@ -86,8 +85,7 @@ func getOperationsDiffInternal(config *Config, state *state, pathItemPair *pathI return result, nil } -func (operationsDiff *OperationsDiff) diffOperation(config *Config, state *state, operation1, operation2 *openapi3.Operation, method string, pathParamsMap PathParamsMap, - pathParams1, pathParams2 openapi3.Parameters) error { +func (operationsDiff *OperationsDiff) diffOperation(config *Config, state *state, operation1, operation2 *openapi3.Operation, method string, pathParamsMap PathParamsMap) error { if operation1 == nil && operation2 == nil { return nil } @@ -102,7 +100,7 @@ func (operationsDiff *OperationsDiff) diffOperation(config *Config, state *state return nil } - diff, err := getMethodDiff(config, state, operation1, operation2, pathParamsMap, pathParams1, pathParams2) + diff, err := getMethodDiff(config, state, operation1, operation2, pathParamsMap) if err != nil { return err } diff --git a/diff/params_inherit.go b/diff/params_inherit.go deleted file mode 100644 index 0aec03ec..00000000 --- a/diff/params_inherit.go +++ /dev/null @@ -1,19 +0,0 @@ -package diff - -import "github.com/getkin/kin-openapi/openapi3" - -func paramsInherit(pathParams, opParams openapi3.Parameters) openapi3.Parameters { - for _, pathParam := range pathParams { - opParams = paramInherit(opParams, pathParam.Value) - } - return opParams -} - -func paramInherit(opParams openapi3.Parameters, pathParam *openapi3.Parameter) openapi3.Parameters { - if opParams.GetByInAndName(pathParam.In, pathParam.Name) == nil { - opParams = append(opParams, &openapi3.ParameterRef{ - Value: pathParam, - }) - } - return opParams -} diff --git a/flatten/allof/doc.go b/flatten/allof/doc.go new file mode 100644 index 00000000..ceed5019 --- /dev/null +++ b/flatten/allof/doc.go @@ -0,0 +1,5 @@ +/* +Package allof replaces allOf by a merged equivalent +This is helpful to improve breaking changes accuracy +*/ +package allof diff --git a/flatten/merge_allof.go b/flatten/allof/merge_allof.go similarity index 99% rename from flatten/merge_allof.go rename to flatten/allof/merge_allof.go index 6d20fda6..0bdac0fe 100644 --- a/flatten/merge_allof.go +++ b/flatten/allof/merge_allof.go @@ -1,4 +1,4 @@ -package flatten +package allof import ( "errors" diff --git a/flatten/merge_allof_spec.go b/flatten/allof/merge_allof_spec.go similarity index 99% rename from flatten/merge_allof_spec.go rename to flatten/allof/merge_allof_spec.go index fd1a357c..70b3fea9 100644 --- a/flatten/merge_allof_spec.go +++ b/flatten/allof/merge_allof_spec.go @@ -1,4 +1,4 @@ -package flatten +package allof import ( "github.com/getkin/kin-openapi/openapi3" diff --git a/flatten/merge_allof_spec_test.go b/flatten/allof/merge_allof_spec_test.go similarity index 83% rename from flatten/merge_allof_spec_test.go rename to flatten/allof/merge_allof_spec_test.go index 2d984204..f64de84a 100644 --- a/flatten/merge_allof_spec_test.go +++ b/flatten/allof/merge_allof_spec_test.go @@ -1,18 +1,18 @@ -package flatten_test +package allof_test import ( "testing" "github.com/getkin/kin-openapi/openapi3" "github.com/stretchr/testify/require" - "github.com/tufin/oasdiff/flatten" + "github.com/tufin/oasdiff/flatten/allof" ) func Test_MergeSpecOK(t *testing.T) { loader := openapi3.NewLoader() - s, err := loader.LoadFromFile("../data/allof/simple.yaml") + s, err := loader.LoadFromFile("../../data/allof/simple.yaml") require.NoError(t, err) - merged, err := flatten.MergeSpec(s) + merged, err := allof.MergeSpec(s) require.NoError(t, err) require.Equal(t, "string", merged.Components.Schemas["GroupView"].Value.Properties["created"].Value.Type) require.Equal(t, "string", merged.Components.Parameters["groupId"].Value.Schema.Value.Properties["prop1"].Value.Type) @@ -25,9 +25,9 @@ func Test_MergeSpecOK(t *testing.T) { func Test_MergeSpecInvalid(t *testing.T) { loader := openapi3.NewLoader() - s, err := loader.LoadFromFile("../data/allof/invalid.yaml") + s, err := loader.LoadFromFile("../../data/allof/invalid.yaml") require.NoError(t, err) - _, err = flatten.MergeSpec(s) + _, err = allof.MergeSpec(s) require.EqualError(t, err, "unable to resolve Type conflict: all Type values must be identical") } diff --git a/flatten/merge_allof_test.go b/flatten/allof/merge_allof_test.go similarity index 92% rename from flatten/merge_allof_test.go rename to flatten/allof/merge_allof_test.go index 2eb45e1c..41cf2248 100644 --- a/flatten/merge_allof_test.go +++ b/flatten/allof/merge_allof_test.go @@ -1,10 +1,10 @@ -package flatten_test +package allof_test import ( "context" "testing" - "github.com/tufin/oasdiff/flatten" + "github.com/tufin/oasdiff/flatten/allof" "github.com/getkin/kin-openapi/openapi3" "github.com/stretchr/testify/require" @@ -12,7 +12,7 @@ import ( // identical Default fields are merged successfully func TestMerge_Default(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Default: 10, @@ -22,7 +22,7 @@ func TestMerge_Default(t *testing.T) { require.NoError(t, err) require.Equal(t, 10, merged.Default) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -39,7 +39,7 @@ func TestMerge_Default(t *testing.T) { require.Nil(t, merged.AllOf) require.Equal(t, nil, merged.Default) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -57,7 +57,7 @@ func TestMerge_Default(t *testing.T) { require.Nil(t, merged.AllOf) require.Equal(t, 10, merged.Default) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -81,7 +81,7 @@ func TestMerge_Default(t *testing.T) { require.Nil(t, merged.AllOf) require.Equal(t, 10, merged.Default) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -108,7 +108,7 @@ func TestMerge_Default(t *testing.T) { // Conflicting Default values cannot be resolved func TestMerge_DefaultFailure(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -128,12 +128,12 @@ func TestMerge_DefaultFailure(t *testing.T) { }, }) - require.EqualError(t, err, flatten.DefaultErrorMessage) + require.EqualError(t, err, allof.DefaultErrorMessage) } // verify that if all ReadOnly fields are set to false, then the ReadOnly field in the merged schema is false. func TestMerge_ReadOnlyIsSetToFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -160,7 +160,7 @@ func TestMerge_ReadOnlyIsSetToFalse(t *testing.T) { // verify that if there exists a ReadOnly field which is true, then the ReadOnly field in the merged schema is true. func TestMerge_ReadOnlyIsSetToTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -185,7 +185,7 @@ func TestMerge_ReadOnlyIsSetToTrue(t *testing.T) { // verify that if all WriteOnly fields are set to false, then the WriteOnly field in the merged schema is false. func TestMerge_WriteOnlyIsSetToFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -210,7 +210,7 @@ func TestMerge_WriteOnlyIsSetToFalse(t *testing.T) { // verify that if there exists a WriteOnly field which is true, then the WriteOnly field in the merged schema is true. func TestMerge_WriteOnlyIsSetToTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -235,7 +235,7 @@ func TestMerge_WriteOnlyIsSetToTrue(t *testing.T) { // verify that if all nullable fields are set to true, then the nullable field in the merged schema is true. func TestMerge_NullableIsSetToTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -261,7 +261,7 @@ func TestMerge_NullableIsSetToTrue(t *testing.T) { // verify that if there exists a nullable field which is false, then the nullable field in the merged schema is false. func TestMerge_NullableIsSetToFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -286,7 +286,7 @@ func TestMerge_NullableIsSetToFalse(t *testing.T) { } func TestMerge_NestedAllOfInProperties(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Properties: openapi3.Schemas{ @@ -320,7 +320,7 @@ func TestMerge_NestedAllOfInProperties(t *testing.T) { } func TestMerge_NestedAllOfInNot(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Not: &openapi3.SchemaRef{ @@ -352,7 +352,7 @@ func TestMerge_NestedAllOfInNot(t *testing.T) { } func TestMerge_NestedAllOfInOneOf(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ OneOf: openapi3.SchemaRefs{ @@ -387,7 +387,7 @@ func TestMerge_NestedAllOfInOneOf(t *testing.T) { // AllOf is empty in base schema, but there is nested non-empty AllOf in base schema. func TestMerge_NestedAllOfInAnyOf(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AnyOf: openapi3.SchemaRefs{ @@ -422,7 +422,7 @@ func TestMerge_NestedAllOfInAnyOf(t *testing.T) { // identical numeric types are merged successfully func TestMerge_TypeNumeric(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -455,7 +455,7 @@ func TestMerge_TypeNumeric(t *testing.T) { require.NoError(t, err) require.Equal(t, "number", merged.Properties["prop1"].Value.Type) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -491,7 +491,7 @@ func TestMerge_TypeNumeric(t *testing.T) { // Conflicting numeric types are merged successfully func TestMerge_TypeNumericConflictResolved(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -527,7 +527,7 @@ func TestMerge_TypeNumericConflictResolved(t *testing.T) { // Conflicting types cannot be resolved func TestMerge_TypeFailure(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -558,12 +558,12 @@ func TestMerge_TypeFailure(t *testing.T) { }, }}) - require.EqualError(t, err, flatten.TypeErrorMessage) + require.EqualError(t, err, allof.TypeErrorMessage) } // if ExclusiveMax is true on the minimum Max value, then ExclusiveMax is true in the merged schema. func TestMerge_ExclusiveMaxIsTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -589,7 +589,7 @@ func TestMerge_ExclusiveMaxIsTrue(t *testing.T) { // if ExclusiveMax is false on the minimum Max value, then ExclusiveMax is false in the merged schema. func TestMerge_ExclusiveMaxIsFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -615,7 +615,7 @@ func TestMerge_ExclusiveMaxIsFalse(t *testing.T) { // if ExclusiveMin is false on the highest Min value, then ExclusiveMin is false in the merged schema. func TestMerge_ExclusiveMinIsFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -641,7 +641,7 @@ func TestMerge_ExclusiveMinIsFalse(t *testing.T) { // if ExclusiveMin is true on the highest Min value, then ExclusiveMin is true in the merged schema. func TestMerge_ExclusiveMinIsTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -667,7 +667,7 @@ func TestMerge_ExclusiveMinIsTrue(t *testing.T) { // merge multiple Not inside AllOf func TestMerge_Not(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -701,7 +701,7 @@ func TestMerge_Not(t *testing.T) { // merge multiple OneOf inside AllOf func TestMerge_OneOf(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -746,7 +746,7 @@ func TestMerge_OneOf(t *testing.T) { // merge multiple AnyOf inside AllOf func TestMerge_AnyOf(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -790,7 +790,7 @@ func TestMerge_AnyOf(t *testing.T) { // conflicting uniqueItems values are merged successfully func TestMerge_UniqueItemsTrue(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -814,7 +814,7 @@ func TestMerge_UniqueItemsTrue(t *testing.T) { // non-conflicting uniqueItems values are merged successfully func TestMerge_UniqueItemsFalse(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -838,7 +838,7 @@ func TestMerge_UniqueItemsFalse(t *testing.T) { // Item merge fails due to conflicting item types. func TestMerge_Items_Failure(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -878,12 +878,12 @@ func TestMerge_Items_Failure(t *testing.T) { }, }, }}) - require.EqualError(t, err, flatten.TypeErrorMessage) + require.EqualError(t, err, allof.TypeErrorMessage) } // items are merged successfully when there are no conflicts func TestMerge_Items(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -932,7 +932,7 @@ func TestMerge_Items(t *testing.T) { func TestMerge_MultipleOfContained(t *testing.T) { //todo - more tests - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -955,7 +955,7 @@ func TestMerge_MultipleOfContained(t *testing.T) { } func TestMerge_MultipleOfDecimal(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -978,7 +978,7 @@ func TestMerge_MultipleOfDecimal(t *testing.T) { } func TestMerge_EnumContained(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1002,7 +1002,7 @@ func TestMerge_EnumContained(t *testing.T) { // enum merge fails if the intersection of enum values is empty. func TestMerge_EnumNoIntersection(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1025,7 +1025,7 @@ func TestMerge_EnumNoIntersection(t *testing.T) { // Properties range is the most restrictive func TestMerge_RangeProperties(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1053,7 +1053,7 @@ func TestMerge_RangeProperties(t *testing.T) { // Items range is the most restrictive func TestMerge_RangeItems(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1079,7 +1079,7 @@ func TestMerge_RangeItems(t *testing.T) { } func TestMerge_Range(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1105,7 +1105,7 @@ func TestMerge_Range(t *testing.T) { } func TestMerge_MaxLength(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1128,7 +1128,7 @@ func TestMerge_MaxLength(t *testing.T) { } func TestMerge_MinLength(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1151,7 +1151,7 @@ func TestMerge_MinLength(t *testing.T) { } func TestMerge_Description(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Description: "desc0", @@ -1173,7 +1173,7 @@ func TestMerge_Description(t *testing.T) { require.NoError(t, err) require.Equal(t, "desc0", merged.Description) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1197,7 +1197,7 @@ func TestMerge_Description(t *testing.T) { // non-conflicting types are merged successfully func TestMerge_NonConflictingType(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1219,7 +1219,7 @@ func TestMerge_NonConflictingType(t *testing.T) { // schema cannot be merged if types are conflicting func TestMerge_FailsOnConflictingTypes(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1253,7 +1253,7 @@ func TestMerge_FailsOnConflictingTypes(t *testing.T) { } func TestMerge_Title(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Title: "base schema", @@ -1275,7 +1275,7 @@ func TestMerge_Title(t *testing.T) { require.NoError(t, err) require.Equal(t, "base schema", merged.Title) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1299,7 +1299,7 @@ func TestMerge_Title(t *testing.T) { // merge conflicting integer formats func TestMerge_FormatInteger(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1308,7 +1308,7 @@ func TestMerge_FormatInteger(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatInt32, + Format: allof.FormatInt32, }, }, }, @@ -1320,7 +1320,7 @@ func TestMerge_FormatInteger(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatInt64, + Format: allof.FormatInt64, }, }, }, @@ -1330,12 +1330,12 @@ func TestMerge_FormatInteger(t *testing.T) { }, }}) require.NoError(t, err) - require.Equal(t, flatten.FormatInt32, merged.Properties["prop1"].Value.Format) + require.Equal(t, allof.FormatInt32, merged.Properties["prop1"].Value.Format) } // merge conflicting float formats func TestMerge_FormatFloat(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1344,7 +1344,7 @@ func TestMerge_FormatFloat(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatFloat, + Format: allof.FormatFloat, }, }, }, @@ -1356,7 +1356,7 @@ func TestMerge_FormatFloat(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatDouble, + Format: allof.FormatDouble, }, }, }, @@ -1366,12 +1366,12 @@ func TestMerge_FormatFloat(t *testing.T) { }, }}) require.NoError(t, err) - require.Equal(t, flatten.FormatFloat, merged.Properties["prop1"].Value.Format) + require.Equal(t, allof.FormatFloat, merged.Properties["prop1"].Value.Format) } // merge conflicting integer and float formats func TestMerge_NumericFormat(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1380,7 +1380,7 @@ func TestMerge_NumericFormat(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatFloat, + Format: allof.FormatFloat, }, }, }, @@ -1392,7 +1392,7 @@ func TestMerge_NumericFormat(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatDouble, + Format: allof.FormatDouble, }, }, }, @@ -1404,7 +1404,7 @@ func TestMerge_NumericFormat(t *testing.T) { Properties: openapi3.Schemas{ "prop1": &openapi3.SchemaRef{ Value: &openapi3.Schema{ - Format: flatten.FormatInt32, + Format: allof.FormatInt32, }, }, }, @@ -1414,11 +1414,11 @@ func TestMerge_NumericFormat(t *testing.T) { }, }}) require.NoError(t, err) - require.Equal(t, flatten.FormatInt32, merged.Properties["prop1"].Value.Format) + require.Equal(t, allof.FormatInt32, merged.Properties["prop1"].Value.Format) } func TestMerge_Format(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1441,7 +1441,7 @@ func TestMerge_Format(t *testing.T) { } func TestMerge_Format_Failure(t *testing.T) { - _, err := flatten.Merge( + _, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1459,14 +1459,14 @@ func TestMerge_Format_Failure(t *testing.T) { }, }, }}) - require.EqualError(t, err, flatten.FormatErrorMessage) + require.EqualError(t, err, allof.FormatErrorMessage) } func TestMerge_EmptySchema(t *testing.T) { schema := openapi3.SchemaRef{ Value: &openapi3.Schema{}, } - merged, err := flatten.Merge(schema) + merged, err := allof.Merge(schema) require.NoError(t, err) require.Equal(t, schema.Value, merged) } @@ -1476,7 +1476,7 @@ func TestMerge_NoAllOf(t *testing.T) { Value: &openapi3.Schema{ Title: "test", }} - merged, err := flatten.Merge(schema) + merged, err := allof.Merge(schema) require.NoError(t, err) require.Equal(t, schema.Value, merged) } @@ -1517,7 +1517,7 @@ func TestMerge_TwoObjects(t *testing.T) { }, }} - merged, err := flatten.Merge(schema) + merged, err := allof.Merge(schema) require.NoError(t, err) require.Len(t, merged.AllOf, 0) require.Len(t, merged.Properties, 2) @@ -1547,7 +1547,7 @@ func TestMerge_OneObjectOneProp(t *testing.T) { }, }} - merged, err := flatten.Merge(schema) + merged, err := allof.Merge(schema) require.NoError(t, err) require.Len(t, merged.Properties, 1) require.Equal(t, object["description"].Value.Type, merged.Properties["description"].Value.Type) @@ -1555,7 +1555,7 @@ func TestMerge_OneObjectOneProp(t *testing.T) { func TestMerge_OneObjectNoProps(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1606,7 +1606,7 @@ func TestMerge_OverlappingProps(t *testing.T) { }, }, }} - merged, err := flatten.Merge(schema) + merged, err := allof.Merge(schema) require.NoError(t, err) require.Len(t, merged.AllOf, 0) require.Len(t, merged.Properties, 1) @@ -1626,7 +1626,7 @@ func TestMerge_AdditionalProperties_False(t *testing.T) { secondPropEnum = append(secondPropEnum, "1", "8", "7") thirdPropEnum = append(thirdPropEnum, "3", "8", "5") - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1697,7 +1697,7 @@ func TestMerge_AdditionalProperties_True(t *testing.T) { secondPropEnum = append(secondPropEnum, "1", "8", "7") thirdPropEnum = append(thirdPropEnum, "3", "8", "5") - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1757,7 +1757,7 @@ func TestMerge_AdditionalProperties_True(t *testing.T) { } func TestMergeAllOf_Pattern(t *testing.T) { - merged, err := flatten.Merge( + merged, err := allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ Pattern: "abc", @@ -1765,7 +1765,7 @@ func TestMergeAllOf_Pattern(t *testing.T) { require.NoError(t, err) require.Equal(t, "abc", merged.Pattern) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1780,7 +1780,7 @@ func TestMergeAllOf_Pattern(t *testing.T) { require.NoError(t, err) require.Equal(t, "abc", merged.Pattern) - merged, err = flatten.Merge( + merged, err = allof.Merge( openapi3.SchemaRef{ Value: &openapi3.Schema{ AllOf: openapi3.SchemaRefs{ @@ -1820,7 +1820,7 @@ func TestMerge_Required(t *testing.T) { require.NoError(t, err, "loading test file") err = doc.Validate(ctx) require.NoError(t, err, "validating spec") - merged, err := flatten.Merge(*doc.Paths.Value("/products").Get.Responses.Value("200").Value.Content["application/json"].Schema) + merged, err := allof.Merge(*doc.Paths.Value("/products").Get.Responses.Value("200").Value.Content["application/json"].Schema) require.NoError(t, err) props := merged.Properties @@ -1839,7 +1839,7 @@ func TestMerge_Required(t *testing.T) { func TestMerge_CircularAllOf(t *testing.T) { doc := loadSpec(t, "testdata/circular1.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["AWSEnvironmentSettings"]) + merged, err := allof.Merge(*doc.Components.Schemas["AWSEnvironmentSettings"]) require.NoError(t, err) require.Empty(t, merged.AllOf) require.Empty(t, merged.OneOf) @@ -1851,7 +1851,7 @@ func TestMerge_CircularAllOf(t *testing.T) { // A single OneOf field is pruned if it references it's parent schema func TestMerge_OneOfIsPruned(t *testing.T) { doc := loadSpec(t, "testdata/circular2.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["OneOf_Is_Pruned_B"]) + merged, err := allof.Merge(*doc.Components.Schemas["OneOf_Is_Pruned_B"]) require.NoError(t, err) require.Empty(t, merged.AllOf) require.Empty(t, merged.OneOf) @@ -1860,7 +1860,7 @@ func TestMerge_OneOfIsPruned(t *testing.T) { // A single OneOf field is not pruned if it does not reference it's parent schema func TestMerge_OneOfIsNotPruned(t *testing.T) { doc := loadSpec(t, "testdata/circular2.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["OneOf_Is_Not_Pruned_B"]) + merged, err := allof.Merge(*doc.Components.Schemas["OneOf_Is_Not_Pruned_B"]) require.NoError(t, err) require.Empty(t, merged.AllOf) require.NotEmpty(t, merged.OneOf) @@ -1869,7 +1869,7 @@ func TestMerge_OneOfIsNotPruned(t *testing.T) { // A single AnyOf field is pruned if it references it's parent schema func TestMerge_AnyOfIsPruned(t *testing.T) { doc := loadSpec(t, "testdata/circular2.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["AnyOf_Is_Pruned_B"]) + merged, err := allof.Merge(*doc.Components.Schemas["AnyOf_Is_Pruned_B"]) require.NoError(t, err) require.Empty(t, merged.AllOf) require.Empty(t, merged.AnyOf) @@ -1878,7 +1878,7 @@ func TestMerge_AnyOfIsPruned(t *testing.T) { // A single AnyOf field is not pruned if it does not reference it's parent schema func TestMerge_AnyOfIsNotPruned(t *testing.T) { doc := loadSpec(t, "testdata/circular2.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["AnyOf_Is_Not_Pruned_B"]) + merged, err := allof.Merge(*doc.Components.Schemas["AnyOf_Is_Not_Pruned_B"]) require.NoError(t, err) require.Empty(t, merged.AllOf) require.NotEmpty(t, merged.AnyOf) @@ -1886,24 +1886,24 @@ func TestMerge_AnyOfIsNotPruned(t *testing.T) { func TestMerge_ComplexOneOfIsPruned(t *testing.T) { doc := loadSpec(t, "testdata/prune-oneof.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["SchemaWithWithoutOneOf"]) + merged, err := allof.Merge(*doc.Components.Schemas["SchemaWithWithoutOneOf"]) require.NoError(t, err) require.Empty(t, merged.OneOf) } func TestMerge_ComplexOneOfIsNotPruned(t *testing.T) { doc := loadSpec(t, "testdata/prune-oneof.yaml") - merged, err := flatten.Merge(*doc.Components.Schemas["ThirdSchema"]) + merged, err := allof.Merge(*doc.Components.Schemas["ThirdSchema"]) require.NoError(t, err) require.NotEmpty(t, merged.OneOf) require.Len(t, merged.OneOf, 2) - merged, err = flatten.Merge(*doc.Components.Schemas["ComplexSchema"]) + merged, err = allof.Merge(*doc.Components.Schemas["ComplexSchema"]) require.NoError(t, err) require.NotEmpty(t, merged.OneOf) require.Len(t, merged.OneOf, 2) - merged, err = flatten.Merge(*doc.Components.Schemas["SchemaWithOneOf"]) + merged, err = allof.Merge(*doc.Components.Schemas["SchemaWithOneOf"]) require.NoError(t, err) require.NotEmpty(t, merged.OneOf) require.Len(t, merged.OneOf, 2) diff --git a/flatten/merge_allof_validation_test.go b/flatten/allof/merge_allof_validation_test.go similarity index 99% rename from flatten/merge_allof_validation_test.go rename to flatten/allof/merge_allof_validation_test.go index 70652937..c8d675ce 100644 --- a/flatten/merge_allof_validation_test.go +++ b/flatten/allof/merge_allof_validation_test.go @@ -1,4 +1,4 @@ -package flatten_test +package allof_test import ( "bytes" @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tufin/oasdiff/flatten" + "github.com/tufin/oasdiff/flatten/allof" "github.com/getkin/kin-openapi/openapi3" "github.com/getkin/kin-openapi/openapi3filter" @@ -1300,7 +1300,7 @@ func runTests(t *testing.T, spec string, tests []Test, shouldMerge bool) []error require.NoError(t, err) if shouldMerge { - doc, err = flatten.MergeSpec(doc) + doc, err = allof.MergeSpec(doc) require.NoError(t, err) } diff --git a/flatten/testdata/circular1.yaml b/flatten/allof/testdata/circular1.yaml similarity index 100% rename from flatten/testdata/circular1.yaml rename to flatten/allof/testdata/circular1.yaml diff --git a/flatten/testdata/circular2.yaml b/flatten/allof/testdata/circular2.yaml similarity index 100% rename from flatten/testdata/circular2.yaml rename to flatten/allof/testdata/circular2.yaml diff --git a/flatten/testdata/properties.yml b/flatten/allof/testdata/properties.yml similarity index 100% rename from flatten/testdata/properties.yml rename to flatten/allof/testdata/properties.yml diff --git a/flatten/testdata/prune-oneof.yaml b/flatten/allof/testdata/prune-oneof.yaml similarity index 100% rename from flatten/testdata/prune-oneof.yaml rename to flatten/allof/testdata/prune-oneof.yaml diff --git a/flatten/pathparams/doc.go b/flatten/pathparams/doc.go new file mode 100644 index 00000000..7d3a22ec --- /dev/null +++ b/flatten/pathparams/doc.go @@ -0,0 +1,5 @@ +/* +Package pathparams moves path-level params to the operations under it +This is helpful to improve breaking changes accuracy +*/ +package pathparams diff --git a/flatten/pathparams/params.go b/flatten/pathparams/params.go new file mode 100644 index 00000000..be2698b8 --- /dev/null +++ b/flatten/pathparams/params.go @@ -0,0 +1,32 @@ +package pathparams + +import "github.com/getkin/kin-openapi/openapi3" + +// Move moves path-level params to the operations under the path +func Move(spec *openapi3.T) { + moveParams(spec) +} + +func moveParams(spec *openapi3.T) { + for _, path := range spec.Paths.Map() { + for _, op := range path.Operations() { + addParams(op, path.Parameters) + } + path.Parameters = nil + } +} + +func addParams(op *openapi3.Operation, pathParams openapi3.Parameters) { + for _, pathParam := range pathParams { + op.Parameters = addParam(op.Parameters, pathParam.Value) + } +} + +func addParam(opParams openapi3.Parameters, pathParam *openapi3.Parameter) openapi3.Parameters { + if opParams.GetByInAndName(pathParam.In, pathParam.Name) == nil { + opParams = append(opParams, &openapi3.ParameterRef{ + Value: pathParam, + }) + } + return opParams +} diff --git a/internal/flatten.go b/internal/flatten.go index e3297dbd..4a78812e 100644 --- a/internal/flatten.go +++ b/internal/flatten.go @@ -6,7 +6,7 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/spf13/cobra" - "github.com/tufin/oasdiff/flatten" + "github.com/tufin/oasdiff/flatten/allof" "github.com/tufin/oasdiff/formatters" "github.com/tufin/oasdiff/load" ) @@ -59,7 +59,7 @@ func runFlatten(flags *FlattenFlags, stdout io.Writer) *ReturnError { // TODO: get the original format of the spec format := flags.format - flatSpec, err := flatten.MergeSpec(spec.Spec) + flatSpec, err := allof.MergeSpec(spec.Spec) if err != nil { return getErrFailedToFlattenSpec("original", flags.spec, err) } diff --git a/load/doc.go b/load/doc.go index 53032eab..1b549cca 100644 --- a/load/doc.go +++ b/load/doc.go @@ -1,2 +1,2 @@ -// Package load provides a function to load an OpenAPI spec from a URL or a Path. +// Package load loads OpenAPI specs from different sources like URL, Path, stdin package load diff --git a/report/example_test.go b/report/example_test.go index 9a90e9a7..004fde38 100644 --- a/report/example_test.go +++ b/report/example_test.go @@ -70,7 +70,6 @@ func ExampleGetTextReportAsString() { // - Deleted response: 400 // // GET /api/{domain}/{project}/install-command - // - New header param: name // - Deleted header param: network-policies // - Modified path param: project // - Schema changed @@ -194,7 +193,6 @@ func ExampleGetHTMLReportAsString() { // //
GET /api/{domain}/{project}/install-command
//