From f40f59541205e2003bc59f0b6e978a1615320e40 Mon Sep 17 00:00:00 2001 From: Reuven Harrison Date: Wed, 2 Aug 2023 19:36:02 +0300 Subject: [PATCH] dedicated diff for components.params (#354) --- checker/checker.go | 2 +- ...ifferent_component_modified_parameter.yaml | 25 +++++ data/different_component_same_header.yaml | 20 ++++ data/different_component_same_parameter.yaml | 25 +++++ data/different_component_same_schema.yaml | 10 ++ data/param-rename/op-base-ref.yaml | 51 ++++++++++ data/param-rename/op-revision-ref.yaml | 51 ++++++++++ diff/components_diff.go | 2 +- diff/diff_test.go | 98 ++++++++++++++++++- diff/headers_diff.go | 6 +- diff/method_diff.go | 4 +- diff/parameter_diff.go | 2 + diff/parameters_aux.go | 16 --- ...diff.go => parameters_diff_by_location.go} | 64 ++++++------ diff/parametes_diff.go | 93 ++++++++++++++++++ diff/path_diff.go | 20 ++-- report/report.go | 2 +- 17 files changed, 424 insertions(+), 67 deletions(-) create mode 100755 data/different_component_modified_parameter.yaml create mode 100755 data/different_component_same_header.yaml create mode 100755 data/different_component_same_parameter.yaml create mode 100755 data/different_component_same_schema.yaml create mode 100644 data/param-rename/op-base-ref.yaml create mode 100644 data/param-rename/op-revision-ref.yaml delete mode 100644 diff/parameters_aux.go rename diff/{parameters_diff.go => parameters_diff_by_location.go} (64%) create mode 100644 diff/parametes_diff.go diff --git a/checker/checker.go b/checker/checker.go index a3de5156..c8952101 100644 --- a/checker/checker.go +++ b/checker/checker.go @@ -231,7 +231,7 @@ func (d *BCDiff) AddModifiedPath(path string) *diff.PathDiff { func (diffBC *BCDiff) AddModifiedParameter(path string, operation string, paramLocation string, paramName string) *diff.ParameterDiff { opDiff := diffBC.AddModifiedOperation(path, operation) if opDiff.ParametersDiff == nil { - opDiff.ParametersDiff = &diff.ParametersDiff{} + opDiff.ParametersDiff = &diff.ParametersDiffByLocation{} } if opDiff.ParametersDiff.Modified == nil { opDiff.ParametersDiff.Modified = make(diff.ParamDiffByLocation) diff --git a/data/different_component_modified_parameter.yaml b/data/different_component_modified_parameter.yaml new file mode 100755 index 00000000..1fbb93e1 --- /dev/null +++ b/data/different_component_modified_parameter.yaml @@ -0,0 +1,25 @@ +openapi: 3.0.3 + +components: + parameters: + differentComponentName_A: + name: sameParamName + in: query + required: true + schema: + type: string + enum: + - option_1 + - option_2 + default: option_1 + description: Let's mention both options, option_1 and option_2. + differentComponentName_B: + name: sameParamName + in: query + required: false + schema: + type: string + enum: + - option_1 + default: option_1 + description: Let's mention the only option, option_1. diff --git a/data/different_component_same_header.yaml b/data/different_component_same_header.yaml new file mode 100755 index 00000000..3366bba4 --- /dev/null +++ b/data/different_component_same_header.yaml @@ -0,0 +1,20 @@ +openapi: 3.0.3 + +components: + headers: + differentComponentName_A: + schema: + type: string + enum: + - option_1 + - option_2 + default: option_1 + description: Let's mention both options, option_1 and option_2. + differentComponentName_B: + schema: + type: string + enum: + - option_1 + default: option_1 + description: Let's mention the only option, option_1. + \ No newline at end of file diff --git a/data/different_component_same_parameter.yaml b/data/different_component_same_parameter.yaml new file mode 100755 index 00000000..7d412b03 --- /dev/null +++ b/data/different_component_same_parameter.yaml @@ -0,0 +1,25 @@ +openapi: 3.0.3 + +components: + parameters: + differentComponentName_A: + name: sameParamName + in: header + required: true + schema: + type: string + enum: + - option_1 + - option_2 + default: option_1 + description: Let's mention both options, option_1 and option_2. + differentComponentName_B: + name: sameParamName + in: query + required: false + schema: + type: string + enum: + - option_1 + default: option_1 + description: Let's mention the only option, option_1. diff --git a/data/different_component_same_schema.yaml b/data/different_component_same_schema.yaml new file mode 100755 index 00000000..45f959da --- /dev/null +++ b/data/different_component_same_schema.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.3 + +components: + schemas: + differentComponentName_A: + name: sameParamName + type: string + differentComponentName_B: + name: sameParamName + type: string diff --git a/data/param-rename/op-base-ref.yaml b/data/param-rename/op-base-ref.yaml new file mode 100644 index 00000000..2dcfe11b --- /dev/null +++ b/data/param-rename/op-base-ref.yaml @@ -0,0 +1,51 @@ +openapi: 3.0.0 + +info: + title: My API + version: '0.1' + +paths: + /books/{bookId}: + + get: + summary: get book details + description: get details for a book + + parameters: + - $ref: "#/components/parameters/bookId" + + responses: + '200': + description: successfully retrieved book details + + content: + application/json: + schema: + title: book details + type: object + + required: + - author + - title + + properties: + author: + title: book author name + type: string + + title: + title: book title + type: string + +components: + parameters: + bookId: + in: path + name: bookId + description: book ID + required: true + + schema: + title: ID + type: string + \ No newline at end of file diff --git a/data/param-rename/op-revision-ref.yaml b/data/param-rename/op-revision-ref.yaml new file mode 100644 index 00000000..8ea802f9 --- /dev/null +++ b/data/param-rename/op-revision-ref.yaml @@ -0,0 +1,51 @@ +openapi: 3.0.0 + +info: + title: My API + version: '0.1' + +paths: + /books/{id}: + + get: + summary: get book details + description: get details for a book + + parameters: + - $ref: "#/components/parameters/id" + + responses: + '200': + description: successfully retrieved book details + + content: + application/json: + schema: + title: book details + type: object + + required: + - author + - title + + properties: + author: + title: book author name + type: string + + title: + title: book title + type: string + +components: + parameters: + id: + in: path + name: id + description: book ID + required: true + + schema: + title: ID + type: string + \ No newline at end of file diff --git a/diff/components_diff.go b/diff/components_diff.go index 5d5c28bc..cf297fa2 100644 --- a/diff/components_diff.go +++ b/diff/components_diff.go @@ -36,7 +36,7 @@ func getComponentsDiffInternal(config *Config, state *state, s1, s2 openapi3.Com return result, err } - result.ParametersDiff, err = getParametersDiff(config, state, toParameters(s1.Parameters), toParameters(s2.Parameters), PathParamsMap{}) + result.ParametersDiff, err = getParametersDiff(config, state, s1.Parameters, s2.Parameters, PathParamsMap{}) if err != nil { return result, err } diff --git a/diff/diff_test.go b/diff/diff_test.go index e9e19bcb..cf20a7ca 100644 --- a/diff/diff_test.go +++ b/diff/diff_test.go @@ -41,7 +41,7 @@ func TestDiff_Empty(t *testing.T) { require.True(t, (*diff.ExtensionsDiff)(nil).Empty()) require.True(t, (*diff.HeadersDiff)(nil).Empty()) require.True(t, (*diff.OperationsDiff)(nil).Empty()) - require.True(t, (*diff.ParametersDiff)(nil).Empty()) + require.True(t, (*diff.ParametersDiffByLocation)(nil).Empty()) require.True(t, (*diff.RequestBodiesDiff)(nil).Empty()) require.True(t, (*diff.ResponsesDiff)(nil).Empty()) require.True(t, (*diff.SchemasDiff)(nil).Empty()) @@ -772,6 +772,29 @@ func TestDiff_PathParamInOperationRenamed(t *testing.T) { require.Equal(t, "id", dd.To) } +func TestDiff_PathParamRefInOperationRenamed(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/param-rename/op-base.yaml") + require.NoError(t, err) + + s2, err := loader.LoadFromFile("../data/param-rename/op-revision-ref.yaml") + require.NoError(t, err) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s2, + }) + require.NoError(t, err) + + dd := d.PathsDiff.Modified["/books/{bookId}"].OperationsDiff.Modified["GET"].ParametersDiff.Modified["path"]["bookId"].NameDiff + require.Equal(t, "bookId", dd.From) + require.Equal(t, "id", dd.To) +} + func TestDiff_TwoPathParamsRenamed(t *testing.T) { loader := openapi3.NewLoader() @@ -821,3 +844,76 @@ func TestDiff_TwoPathParamsOneRenamed(t *testing.T) { require.Equal(t, "libraryId", dd.From) require.Equal(t, "otherId", dd.To) } + +func TestDiff_DifferentComponentSameParam(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/different_component_same_parameter.yaml") + require.NoError(t, err) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s1, + }) + require.NoError(t, err) + require.Empty(t, d) +} + +func TestDiff_DifferentComponentModifiedParam(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/different_component_same_parameter.yaml") + require.NoError(t, err) + + s2, err := loader.LoadFromFile("../data/different_component_modified_parameter.yaml") + require.NoError(t, err) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s2, + }) + require.NoError(t, err) + dd := d.ComponentsDiff.ParametersDiff.Modified["differentComponentName_A"].InDiff + require.Equal(t, "header", dd.From) + require.Equal(t, "query", dd.To) +} + +func TestDiff_DifferentComponentSameSchema(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/different_component_same_schema.yaml") + require.NoError(t, err) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s1, + }) + require.NoError(t, err) + require.Empty(t, d) +} + +func TestDiff_DifferentComponentSameHeader(t *testing.T) { + loader := openapi3.NewLoader() + + s1, err := loader.LoadFromFile("../data/different_component_same_header.yaml") + require.NoError(t, err) + + d, _, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), + &load.SpecInfo{ + Spec: s1, + }, + &load.SpecInfo{ + Spec: s1, + }) + require.NoError(t, err) + require.Empty(t, d) +} diff --git a/diff/headers_diff.go b/diff/headers_diff.go index 979fcfcc..c591257f 100644 --- a/diff/headers_diff.go +++ b/diff/headers_diff.go @@ -78,9 +78,9 @@ func getHeadersDiffInternal(config *Config, state *state, headers1, headers2 ope } } - for headerValue2 := range headers2 { - if _, ok := headers1[headerValue2]; !ok { - result.Added = append(result.Added, headerValue2) + for headerName2 := range headers2 { + if _, ok := headers1[headerName2]; !ok { + result.Added = append(result.Added, headerName2) } } diff --git a/diff/method_diff.go b/diff/method_diff.go index 7288327e..1045f3da 100644 --- a/diff/method_diff.go +++ b/diff/method_diff.go @@ -11,7 +11,7 @@ type MethodDiff struct { SummaryDiff *ValueDiff `json:"summary,omitempty" yaml:"summary,omitempty"` DescriptionDiff *ValueDiff `json:"description,omitempty" yaml:"description,omitempty"` OperationIDDiff *ValueDiff `json:"operationID,omitempty" yaml:"operationID,omitempty"` - ParametersDiff *ParametersDiff `json:"parameters,omitempty" yaml:"parameters,omitempty"` + ParametersDiff *ParametersDiffByLocation `json:"parameters,omitempty" yaml:"parameters,omitempty"` RequestBodyDiff *RequestBodyDiff `json:"requestBody,omitempty" yaml:"requestBody,omitempty"` ResponsesDiff *ResponsesDiff `json:"responses,omitempty" yaml:"responses,omitempty"` CallbacksDiff *CallbacksDiff `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` @@ -61,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 = getParametersDiff(config, state, operation1.Parameters, operation2.Parameters, pathParamsMap) + result.ParametersDiff, err = getParametersDiffByLocation(config, state, operation1.Parameters, operation2.Parameters, pathParamsMap) if err != nil { return nil, err } diff --git a/diff/parameter_diff.go b/diff/parameter_diff.go index a1252809..039bc978 100644 --- a/diff/parameter_diff.go +++ b/diff/parameter_diff.go @@ -7,6 +7,7 @@ import ( // ParameterDiff describes the changes between a pair of parameter objects: https://swagger.io/specification/#parameter-object type ParameterDiff struct { NameDiff *ValueDiff `json:"name,omitempty" yaml:"name,omitempty"` + InDiff *ValueDiff `json:"in,omitempty" yaml:"in,omitempty"` ExtensionsDiff *ExtensionsDiff `json:"extensions,omitempty" yaml:"extensions,omitempty"` DescriptionDiff *ValueDiff `json:"description,omitempty" yaml:"description,omitempty"` StyleDiff *ValueDiff `json:"style,omitempty" yaml:"style,omitempty"` @@ -47,6 +48,7 @@ func getParameterDiffInternal(config *Config, state *state, param1, param2 *open var err error result.NameDiff = getValueDiff(param1.Name, param2.Name) + result.InDiff = getValueDiff(param1.In, param2.In) result.ExtensionsDiff = getExtensionsDiff(config, state, param1.Extensions, param2.Extensions) result.DescriptionDiff = getValueDiffConditional(config.IsExcludeDescription(), param1.Description, param2.Description) result.StyleDiff = getValueDiff(param1.Style, param2.Style) diff --git a/diff/parameters_aux.go b/diff/parameters_aux.go deleted file mode 100644 index 7b38a982..00000000 --- a/diff/parameters_aux.go +++ /dev/null @@ -1,16 +0,0 @@ -package diff - -import "github.com/getkin/kin-openapi/openapi3" - -func toParameters(parametersMap openapi3.ParametersMap) openapi3.Parameters { - - result := make(openapi3.Parameters, len(parametersMap)) - - i := 0 - for _, v := range parametersMap { - result[i] = v - i++ - } - - return result -} diff --git a/diff/parameters_diff.go b/diff/parameters_diff_by_location.go similarity index 64% rename from diff/parameters_diff.go rename to diff/parameters_diff_by_location.go index 9b7d1dac..b0555779 100644 --- a/diff/parameters_diff.go +++ b/diff/parameters_diff_by_location.go @@ -7,22 +7,22 @@ import ( "github.com/tufin/oasdiff/utils" ) -// ParametersDiff describes the changes between a pair of lists of parameter objects: https://swagger.io/specification/#parameter-object -type ParametersDiff struct { +// ParametersDiffByLocation describes the changes, grouped by param location, between a pair of lists of parameter objects: https://swagger.io/specification/#parameter-object +type ParametersDiffByLocation struct { Added ParamNamesByLocation `json:"added,omitempty" yaml:"added,omitempty"` Deleted ParamNamesByLocation `json:"deleted,omitempty" yaml:"deleted,omitempty"` Modified ParamDiffByLocation `json:"modified,omitempty" yaml:"modified,omitempty"` } // Empty indicates whether a change was found in this element -func (parametersDiff *ParametersDiff) Empty() bool { - if parametersDiff == nil { +func (diff *ParametersDiffByLocation) Empty() bool { + if diff == nil { return true } - return len(parametersDiff.Added) == 0 && - len(parametersDiff.Deleted) == 0 && - len(parametersDiff.Modified) == 0 + return len(diff.Added) == 0 && + len(diff.Deleted) == 0 && + len(diff.Modified) == 0 } // ParamLocations are the four possible locations of parameters: path, query, header or cookie @@ -34,8 +34,8 @@ type ParamNamesByLocation map[string]utils.StringList // ParamDiffByLocation maps param location (path, query, header or cookie) to param diffs in this location type ParamDiffByLocation map[string]ParamDiffs -func newParametersDiff() *ParametersDiff { - return &ParametersDiff{ +func newParametersDiffByLocation() *ParametersDiffByLocation { + return &ParametersDiffByLocation{ Added: ParamNamesByLocation{}, Deleted: ParamNamesByLocation{}, Modified: ParamDiffByLocation{}, @@ -45,35 +45,35 @@ func newParametersDiff() *ParametersDiff { // ParamDiffs is map of parameter names to their respective diffs type ParamDiffs map[string]*ParameterDiff -func (parametersDiff *ParametersDiff) addAddedParam(param *openapi3.Parameter) { +func (diff *ParametersDiffByLocation) addAddedParam(param *openapi3.Parameter) { - if paramNames, ok := parametersDiff.Added[param.In]; ok { - parametersDiff.Added[param.In] = append(paramNames, param.Name) + if paramNames, ok := diff.Added[param.In]; ok { + diff.Added[param.In] = append(paramNames, param.Name) } else { - parametersDiff.Added[param.In] = utils.StringList{param.Name} + diff.Added[param.In] = utils.StringList{param.Name} } } -func (parametersDiff *ParametersDiff) addDeletedParam(param *openapi3.Parameter) { +func (diff *ParametersDiffByLocation) addDeletedParam(param *openapi3.Parameter) { - if paramNames, ok := parametersDiff.Deleted[param.In]; ok { - parametersDiff.Deleted[param.In] = append(paramNames, param.Name) + if paramNames, ok := diff.Deleted[param.In]; ok { + diff.Deleted[param.In] = append(paramNames, param.Name) } else { - parametersDiff.Deleted[param.In] = utils.StringList{param.Name} + diff.Deleted[param.In] = utils.StringList{param.Name} } } -func (parametersDiff *ParametersDiff) addModifiedParam(param *openapi3.Parameter, diff *ParameterDiff) { +func (diff *ParametersDiffByLocation) addModifiedParam(param *openapi3.Parameter, paramDiff *ParameterDiff) { - if paramDiffs, ok := parametersDiff.Modified[param.In]; ok { - paramDiffs[param.Name] = diff + if paramDiffs, ok := diff.Modified[param.In]; ok { + paramDiffs[param.Name] = paramDiff } else { - parametersDiff.Modified[param.In] = ParamDiffs{param.Name: diff} + diff.Modified[param.In] = ParamDiffs{param.Name: paramDiff} } } -func getParametersDiff(config *Config, state *state, params1, params2 openapi3.Parameters, pathParamsMap PathParamsMap) (*ParametersDiff, error) { - diff, err := getParametersDiffInternal(config, state, params1, params2, pathParamsMap) +func getParametersDiffByLocation(config *Config, state *state, params1, params2 openapi3.Parameters, pathParamsMap PathParamsMap) (*ParametersDiffByLocation, error) { + diff, err := getParametersDiffByLocationInternal(config, state, params1, params2, pathParamsMap) if err != nil { return nil, err } @@ -85,9 +85,9 @@ func getParametersDiff(config *Config, state *state, params1, params2 openapi3.P return diff, nil } -func getParametersDiffInternal(config *Config, state *state, params1, params2 openapi3.Parameters, pathParamsMap PathParamsMap) (*ParametersDiff, error) { +func getParametersDiffByLocationInternal(config *Config, state *state, params1, params2 openapi3.Parameters, pathParamsMap PathParamsMap) (*ParametersDiffByLocation, error) { - result := newParametersDiff() + result := newParametersDiffByLocation() for _, paramRef1 := range params1 { param1, err := derefParam(paramRef1) @@ -179,22 +179,22 @@ func equalParams(param1 *openapi3.Parameter, param2 *openapi3.Parameter, pathPar return pathParamsMap.find(param1.Name, param2.Name), nil } -func (parametersDiff *ParametersDiff) getSummary() *SummaryDetails { +func (diff *ParametersDiffByLocation) getSummary() *SummaryDetails { return &SummaryDetails{ - Added: len(parametersDiff.Added), - Deleted: len(parametersDiff.Deleted), - Modified: len(parametersDiff.Modified), + Added: len(diff.Added), + Deleted: len(diff.Deleted), + Modified: len(diff.Modified), } } // Patch applies the patch to parameters -func (parametersDiff *ParametersDiff) Patch(parameters openapi3.Parameters) error { +func (diff *ParametersDiffByLocation) Patch(parameters openapi3.Parameters) error { - if parametersDiff.Empty() { + if diff.Empty() { return nil } - for location, paramDiffs := range parametersDiff.Modified { + for location, paramDiffs := range diff.Modified { for name, parameterDiff := range paramDiffs { err := parameterDiff.Patch(parameters.GetByInAndName(location, name)) if err != nil { diff --git a/diff/parametes_diff.go b/diff/parametes_diff.go new file mode 100644 index 00000000..c6622cbb --- /dev/null +++ b/diff/parametes_diff.go @@ -0,0 +1,93 @@ +package diff + +import ( + "github.com/getkin/kin-openapi/openapi3" + "github.com/tufin/oasdiff/utils" +) + +// ParametersDiff describes the changes between a pair of lists of parameter objects: https://swagger.io/specification/#parameter-object +type ParametersDiff struct { + Added utils.StringList `json:"added,omitempty" yaml:"added,omitempty"` + Deleted utils.StringList `json:"deleted,omitempty" yaml:"deleted,omitempty"` + Modified ParamDiffs `json:"modified,omitempty" yaml:"modified,omitempty"` +} + +// Empty indicates whether a change was found in this element +func (diff *ParametersDiff) Empty() bool { + if diff == nil { + return true + } + + return len(diff.Added) == 0 && + len(diff.Deleted) == 0 && + len(diff.Modified) == 0 +} + +func newParametersDiff() *ParametersDiff { + return &ParametersDiff{ + Added: utils.StringList{}, + Deleted: utils.StringList{}, + Modified: ParamDiffs{}, + } +} + +func getParametersDiff(config *Config, state *state, params1, params2 openapi3.ParametersMap, pathParamsMap PathParamsMap) (*ParametersDiff, error) { + diff, err := getParametersDiffInternal(config, state, params1, params2, pathParamsMap) + if err != nil { + return nil, err + } + + if diff.Empty() { + return nil, nil + } + + return diff, nil +} + +func getParametersDiffInternal(config *Config, state *state, params1, params2 openapi3.ParametersMap, pathParamsMap PathParamsMap) (*ParametersDiff, error) { + + result := newParametersDiff() + + for paramName1, paramRef1 := range params1 { + + if paramRef2, ok := params2[paramName1]; ok { + + param1, err := derefParam(paramRef1) + if err != nil { + return nil, err + } + + param2, err := derefParam(paramRef2) + if err != nil { + return nil, err + } + + diff, err := getParameterDiff(config, state, param1, param2) + if err != nil { + return nil, err + } + + if !diff.Empty() { + result.Modified[paramName1] = diff + } + } else { + result.Deleted = append(result.Deleted, paramName1) + } + } + + for paramName2 := range params2 { + if _, ok := params1[paramName2]; !ok { + result.Added = append(result.Added, paramName2) + } + } + + return result, nil +} + +func (diff *ParametersDiff) getSummary() *SummaryDetails { + return &SummaryDetails{ + Added: len(diff.Added), + Deleted: len(diff.Deleted), + Modified: len(diff.Modified), + } +} diff --git a/diff/path_diff.go b/diff/path_diff.go index 889e6af5..e84a0f37 100644 --- a/diff/path_diff.go +++ b/diff/path_diff.go @@ -8,15 +8,15 @@ import ( // PathDiff describes the changes between a pair of path item objects: https://swagger.io/specification/#path-item-object type PathDiff struct { - ExtensionsDiff *ExtensionsDiff `json:"extensions,omitempty" yaml:"extensions,omitempty"` - RefDiff *ValueDiff `json:"ref,omitempty" yaml:"ref,omitempty"` - SummaryDiff *ValueDiff `json:"summary,omitempty" yaml:"summary,omitempty"` - DescriptionDiff *ValueDiff `json:"description,omitempty" yaml:"description,omitempty"` - OperationsDiff *OperationsDiff `json:"operations,omitempty" yaml:"operations,omitempty"` - ServersDiff *ServersDiff `json:"servers,omitempty" yaml:"servers,omitempty"` - ParametersDiff *ParametersDiff `json:"parameters,omitempty" yaml:"parameters,omitempty"` - Base *openapi3.PathItem `json:"-" yaml:"-"` - Revision *openapi3.PathItem `json:"-" yaml:"-"` + ExtensionsDiff *ExtensionsDiff `json:"extensions,omitempty" yaml:"extensions,omitempty"` + RefDiff *ValueDiff `json:"ref,omitempty" yaml:"ref,omitempty"` + SummaryDiff *ValueDiff `json:"summary,omitempty" yaml:"summary,omitempty"` + DescriptionDiff *ValueDiff `json:"description,omitempty" yaml:"description,omitempty"` + OperationsDiff *OperationsDiff `json:"operations,omitempty" yaml:"operations,omitempty"` + ServersDiff *ServersDiff `json:"servers,omitempty" yaml:"servers,omitempty"` + ParametersDiff *ParametersDiffByLocation `json:"parameters,omitempty" yaml:"parameters,omitempty"` + Base *openapi3.PathItem `json:"-" yaml:"-"` + Revision *openapi3.PathItem `json:"-" yaml:"-"` } func newPathDiff() *PathDiff { @@ -65,7 +65,7 @@ func getPathDiffInternal(config *Config, state *state, pathItemPair *pathItemPai } result.ServersDiff = getServersDiff(config, state, &pathItem1.Servers, &pathItem2.Servers) - result.ParametersDiff, err = getParametersDiff(config, state, pathItem1.Parameters, pathItem2.Parameters, pathItemPair.PathParamsMap) + result.ParametersDiff, err = getParametersDiffByLocation(config, state, pathItem1.Parameters, pathItem2.Parameters, pathItemPair.PathParamsMap) result.Base = pathItem1 result.Revision = pathItem2 if err != nil { diff --git a/report/report.go b/report/report.go index 7a3329b2..ce082798 100644 --- a/report/report.go +++ b/report/report.go @@ -149,7 +149,7 @@ func (r *report) printMethod(d *diff.MethodDiff) { } } -func (r *report) printParams(d *diff.ParametersDiff) { +func (r *report) printParams(d *diff.ParametersDiffByLocation) { if d.Empty() { return }