From 3a7f6463b095236c6215b1f227a145b433394260 Mon Sep 17 00:00:00 2001 From: blva <40155621+blva@users.noreply.github.com> Date: Mon, 31 Jul 2023 21:41:53 +0100 Subject: [PATCH] Changelog: Request properties changed (#345) --- BREAKING-CHANGES-EXAMPLES.md | 19 +++ ...ck-request-property-enum-value-updated.go} | 28 +++- ...equest-property-enum-value-updated_test.go | 61 ++++++++ ...ck-request-property-max-length-updated.go} | 47 +++++-- ...equest-property-max-length-updated_test.go | 119 ++++++++++++++++ ... => check-request-property-max-updated.go} | 49 +++++-- ...check-request-property-max-updated_test.go | 117 ++++++++++++++++ ...eck-request-property-min-length-updated.go | 95 +++++++++++++ ...equest-property-min-length-updated_test.go | 109 +++++++++++++++ ... => check-request-property-min-updated.go} | 44 ++++-- ...check-request-property-min-updated_test.go | 55 ++++++++ .../check-request-property-type-changed.go | 12 +- ...heck-request-property-type-changed_test.go | 132 ++++++++++++++++++ checker/config.go | 8 ++ checker/default_checks.go | 4 +- checker/localizations/localizations.go | 28 +++- checker/localizations_src/en/messages.yaml | 13 ++ checker/localizations_src/ru/messages.yaml | 13 ++ ...equest_body_max_length_decreased_base.yaml | 29 ++++ ...uest_property_enum_value_updated_base.yaml | 43 ++++++ .../request_property_max_decreased_base.yaml | 23 +++ .../request_property_min_increased_base.yaml | 23 +++ ...quest_property_min_increased_revision.yaml | 23 +++ ...st_property_min_length_decreased_base.yaml | 31 ++++ .../request_property_type_changed_base.yaml | 24 ++++ ...equest_property_type_changed_revision.yaml | 24 ++++ 26 files changed, 1116 insertions(+), 57 deletions(-) rename checker/{check-request-property-enum-value-removed.go => check-request-property-enum-value-updated.go} (66%) create mode 100644 checker/check-request-property-enum-value-updated_test.go rename checker/{check-request-property-max-length-decreased.go => check-request-property-max-length-updated.go} (52%) create mode 100644 checker/check-request-property-max-length-updated_test.go rename checker/{check-request-property-max-decreased.go => check-request-property-max-updated.go} (55%) create mode 100644 checker/check-request-property-max-updated_test.go create mode 100644 checker/check-request-property-min-length-updated.go create mode 100644 checker/check-request-property-min-length-updated_test.go rename checker/{check-request-property-min-increased.go => check-request-property-min-updated.go} (56%) create mode 100644 checker/check-request-property-min-updated_test.go create mode 100644 checker/check-request-property-type-changed_test.go create mode 100644 data/checker/request_body_max_length_decreased_base.yaml create mode 100644 data/checker/request_property_enum_value_updated_base.yaml create mode 100644 data/checker/request_property_max_decreased_base.yaml create mode 100644 data/checker/request_property_min_increased_base.yaml create mode 100644 data/checker/request_property_min_increased_revision.yaml create mode 100644 data/checker/request_property_min_length_decreased_base.yaml create mode 100644 data/checker/request_property_type_changed_base.yaml create mode 100644 data/checker/request_property_type_changed_revision.yaml diff --git a/BREAKING-CHANGES-EXAMPLES.md b/BREAKING-CHANGES-EXAMPLES.md index b29052e3..f0748f4a 100644 --- a/BREAKING-CHANGES-EXAMPLES.md +++ b/BREAKING-CHANGES-EXAMPLES.md @@ -167,6 +167,7 @@ These examples are automatically generated from unit tests. [adding an enum value to request parameter](checker/check-request-parameter-enum-value-updated_test.go?plain=1#L34) [adding an optional write-only property to a response](checker/check-response-optional-property-updated_test.go?plain=1#L34) [adding pattern to request parameters](checker/check-request-parameter-pattern-added-or-changed_test.go?plain=1#L35) +[adding request property enum values](checker/check-request-property-enum-value-updated_test.go?plain=1#L37) [adding request property pattern](checker/check-request-property-pattern-added-or-changed_test.go?plain=1#L36) [adding response property pattern](checker/check-response-pattern-added-or-changed_test.go?plain=1#L37) [changing a response property schema format](checker/check-response-property-type-changed_test.go?plain=1#L59) @@ -182,13 +183,16 @@ These examples are automatically generated from unit tests. [changing optional response property to write-only](checker/check-response-optional-property-write-only-read-only_test.go?plain=1#L11) [changing optional response write-only property to required](checker/check-response-property-became-required_test.go?plain=1#L33) [changing pattern of request parameters](checker/check-request-parameter-pattern-added-or-changed_test.go?plain=1#L11) +[changing request body type](checker/check-request-property-type-changed_test.go?plain=1#L11) [changing request header parameter format](checker/check-request-parameters-type-changed_test.go?plain=1#L136) [changing request header parameter type](checker/check-request-parameters-type-changed_test.go?plain=1#L61) [changing request parameter default value](checker/check-request-parameters-default-value-changed_test.go?plain=1#L11) [changing request parameter type to enum](checker/check-request-parameter-became-enum_test.go?plain=1#L11) [changing request path parameter format](checker/check-request-parameters-type-changed_test.go?plain=1#L86) [changing request path parameter type](checker/check-request-parameters-type-changed_test.go?plain=1#L11) +[changing request property format](checker/check-request-property-type-changed_test.go?plain=1#L84) [changing request property pattern](checker/check-request-property-pattern-added-or-changed_test.go?plain=1#L11) +[changing request property type](checker/check-request-property-type-changed_test.go?plain=1#L61) [changing request query parameter format](checker/check-request-parameters-type-changed_test.go?plain=1#L111) [changing request query parameter type](checker/check-request-parameters-type-changed_test.go?plain=1#L36) [changing request's body to optional](checker/check-request-body-required-value-updated_test.go?plain=1#L36) @@ -204,19 +208,33 @@ These examples are automatically generated from unit tests. [changing security component oauth's url](checker/check-components-security-updated_test.go?plain=1#L11) [changing security component type](checker/check-components-security-updated_test.go?plain=1#L33) [changing write-only required response property to optional](checker/check-response-property-became-optional_test.go?plain=1#L33) +[decreasing max length of request body](checker/check-request-property-max-length-updated_test.go?plain=1#L39) +[decreasing max length of request property](checker/check-request-property-max-length-updated_test.go?plain=1#L67) [decreasing maxItems of request parameters](checker/check-request-parameters-max-items-updated_test.go?plain=1#L34) [decreasing maxLength of request parameters](checker/check-request-parameters-max-length-updated_test.go?plain=1#L33) [decreasing maximum value of request parameter](checker/check-request-parameters-max-updated_test.go?plain=1#L33) [decreasing minItems value of request parameter](checker/check-request-parameters-min-items-updated_test.go?plain=1#L33) +[decreasing minLength of request body](checker/check-request-property-min-length-updated_test.go?plain=1#L86) +[decreasing minLength of request property](checker/check-request-property-min-length-updated_test.go?plain=1#L11) [decreasing minLength value of request parameter](checker/check-request-parameters-min-length-updated_test.go?plain=1#L34) [decreasing minimum value of request parameter](checker/check-request-parameters-min-updated_test.go?plain=1#L33) +[decreasing minimum value of request property](checker/check-request-property-min-updated_test.go?plain=1#L34) +[decreasing request body maximum value](checker/check-request-property-max-updated_test.go?plain=1#L91) +[decreasing request property maximum value](checker/check-request-property-max-updated_test.go?plain=1#L11) [deprecating an operation with sunset greater than min](checker/checker_not_breaking_test.go?plain=1#L199) +[increasing max length of request body](checker/check-request-property-max-length-updated_test.go?plain=1#L11) +[increasing max length of request property](checker/check-request-property-max-length-updated_test.go?plain=1#L94) [increasing maxItems of request parameters](checker/check-request-parameters-max-items-updated_test.go?plain=1#L11) [increasing maxLength of request parameters](checker/check-request-parameters-max-length-updated_test.go?plain=1#L11) [increasing maximum value of request parameter](checker/check-request-parameters-max-updated_test.go?plain=1#L11) [increasing minItems value of request parameter](checker/check-request-parameters-min-items-updated_test.go?plain=1#L11) +[increasing minLength of request body](checker/check-request-property-min-length-updated_test.go?plain=1#L61) +[increasing minLength of request property](checker/check-request-property-min-length-updated_test.go?plain=1#L36) [increasing minLength value of request parameter](checker/check-request-parameters-min-length-updated_test.go?plain=1#L11) [increasing minimum value of request parameter](checker/check-request-parameters-min-updated_test.go?plain=1#L11) +[increasing minimum value of request property](checker/check-request-property-min-updated_test.go?plain=1#L11) +[increasing request body maximum value](checker/check-request-property-max-updated_test.go?plain=1#L63) +[increasing request property maximum value](checker/check-request-property-max-updated_test.go?plain=1#L37) [new header, query and cookie request params](checker/check-new-request-non-path-parameter_test.go?plain=1#L11) [new paths or path operations](checker/check-api-added_test.go?plain=1#L11) [path operations that became deprecated](checker/checker_deprecation_test.go?plain=1#L324) @@ -245,6 +263,7 @@ These examples are automatically generated from unit tests. [removing an optional write-only property from a response](checker/check-response-optional-property-updated_test.go?plain=1#L11) [removing media type from request body](checker/check-request-body-mediatype-updated_test.go?plain=1#L34) [removing pattern from request parameters](checker/check-request-parameter-pattern-added-or-changed_test.go?plain=1#L58) +[removing request property enum values](checker/check-request-property-enum-value-updated_test.go?plain=1#L11) [removing request property pattern](checker/check-request-property-pattern-added-or-changed_test.go?plain=1#L59) [removing response property pattern](checker/check-response-pattern-added-or-changed_test.go?plain=1#L63) [updating an existing operation id](checker/check-api-operation-id-updated_test.go?plain=1#L36) diff --git a/checker/check-request-property-enum-value-removed.go b/checker/check-request-property-enum-value-updated.go similarity index 66% rename from checker/check-request-property-enum-value-removed.go rename to checker/check-request-property-enum-value-updated.go index 64e2540c..a6b8c464 100644 --- a/checker/check-request-property-enum-value-removed.go +++ b/checker/check-request-property-enum-value-updated.go @@ -6,7 +6,7 @@ import ( "github.com/tufin/oasdiff/diff" ) -func RequestPropertyEnumValueRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config Config) Changes { +func RequestPropertyEnumValueUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config Config) Changes { result := make(Changes, 0) if diffReport.PathsDiff == nil { return result @@ -28,17 +28,19 @@ func RequestPropertyEnumValueRemovedCheck(diffReport *diff.Diff, operationsSourc CheckModifiedPropertiesDiff( mediaTypeDiff.SchemaDiff, func(propertyPath string, propertyName string, propertyDiff *diff.SchemaDiff, parent *diff.SchemaDiff) { - enumDiff := mediaTypeDiff.SchemaDiff.EnumDiff - if enumDiff == nil || enumDiff.Deleted == nil { - return - } - if propertyDiff.Revision.Value.ReadOnly { + enumDiff := propertyDiff.EnumDiff + if enumDiff == nil { return } + for _, enumVal := range enumDiff.Deleted { + level := ERR + if propertyDiff.Revision.Value.ReadOnly { + level = INFO + } result = append(result, ApiChange{ Id: "request-property-enum-value-removed", - Level: ERR, + Level: level, Text: fmt.Sprintf(config.i18n("request-property-enum-value-removed"), enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -46,6 +48,18 @@ func RequestPropertyEnumValueRemovedCheck(diffReport *diff.Diff, operationsSourc Source: source, }) } + + for _, enumVal := range enumDiff.Added { + result = append(result, ApiChange{ + Id: "request-property-enum-value-added", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-property-enum-value-added"), ColorizedValue(enumVal), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } }) } } diff --git a/checker/check-request-property-enum-value-updated_test.go b/checker/check-request-property-enum-value-updated_test.go new file mode 100644 index 00000000..9e0de824 --- /dev/null +++ b/checker/check-request-property-enum-value-updated_test.go @@ -0,0 +1,61 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: removing request property enum values +func TestRequestPropertyEnumValueRemovedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_enum_value_updated_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_enum_value_updated_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"} + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyEnumValueUpdatedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + + require.Equal(t, checker.ApiChange{ + Id: "request-property-enum-value-removed", + Level: checker.ERR, + Text: "removed the enum value bird of the request property 'category'", + Operation: "POST", + OperationId: "updatePet", + Path: "/pets", + Source: "../data/checker/request_property_enum_value_updated_base.yaml", + }, errs[0]) +} + +// CL: adding request property enum values +func TestRequestPropertyEnumValueAddedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_enum_value_updated_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_enum_value_updated_base.yaml") + require.NoError(t, err) + + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"} + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyEnumValueUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + + require.Equal(t, checker.ApiChange{ + Id: "request-property-enum-value-added", + Level: checker.INFO, + Text: "added the new 'bird' enum value to the request property 'category'", + Operation: "POST", + OperationId: "updatePet", + Path: "/pets", + Source: "../data/checker/request_property_enum_value_updated_base.yaml", + }, errs[0]) +} diff --git a/checker/check-request-property-max-length-decreased.go b/checker/check-request-property-max-length-updated.go similarity index 52% rename from checker/check-request-property-max-length-decreased.go rename to checker/check-request-property-max-length-updated.go index 3367988c..258f3cbc 100644 --- a/checker/check-request-property-max-length-decreased.go +++ b/checker/check-request-property-max-length-updated.go @@ -6,7 +6,7 @@ import ( "github.com/tufin/oasdiff/diff" ) -func RequestPropertyMaxLengthDecreasedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config Config) Changes { +func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config Config) Changes { result := make(Changes, 0) if diffReport.PathsDiff == nil { return result @@ -39,6 +39,16 @@ func RequestPropertyMaxLengthDecreasedCheck(diffReport *diff.Diff, operationsSou Path: path, Source: source, }) + } else { + result = append(result, ApiChange{ + Id: "request-body-max-length-increased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-body-max-length-increased"), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } } } @@ -54,22 +64,29 @@ func RequestPropertyMaxLengthDecreasedCheck(diffReport *diff.Diff, operationsSou maxLengthDiff.To == nil { return } - if propertyDiff.Revision.Value.ReadOnly { - return - } - if !IsDecreasedValue(maxLengthDiff) { - return + + if IsDecreasedValue(maxLengthDiff) { + result = append(result, ApiChange{ + Id: "request-property-max-length-decreased", + Level: ConditionalError(!propertyDiff.Revision.Value.ReadOnly), + Text: fmt.Sprintf(config.i18n("request-property-max-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } else { + result = append(result, ApiChange{ + Id: "request-property-max-length-increased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-property-max-length-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } - result = append(result, ApiChange{ - Id: "request-property-max-length-decreased", - Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-max-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: source, - }) }) } } diff --git a/checker/check-request-property-max-length-updated_test.go b/checker/check-request-property-max-length-updated_test.go new file mode 100644 index 00000000..f4daf5d6 --- /dev/null +++ b/checker/check-request-property-max-length-updated_test.go @@ -0,0 +1,119 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: increasing max length of request body +func TestRequestBodyMaxLengthDecreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + + maxLength := uint64(50) + newMaxLength := uint64(100) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-max-length-increased", + Text: "the request's body maxLength was increased from '50' to '100'", + Level: checker.INFO, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_body_max_length_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: decreasing max length of request body +func TestRequestBodyMaxLengthIncreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + + maxLength := uint64(100) + newMaxLength := uint64(50) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-max-length-decreased", + Text: "the request's body maxLength was decreased to '50'", + Level: checker.ERR, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_body_max_length_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: decreasing max length of request property +func TestRequestPropertyMaxLengthDecreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + + maxLength := uint64(100) + newMaxLength := uint64(50) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-max-length-decreased", + Text: "the 'description' request property's maxLength was decreased to '50'", + Level: checker.ERR, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_body_max_length_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: increasing max length of request property +func TestRequestPropertyMaxLengthIncreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_body_max_length_decreased_base.yaml") + require.NoError(t, err) + + maxLength := uint64(50) + newMaxLength := uint64(100) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-max-length-increased", + Text: "the 'description' request property's maxLength was increased from '50' to '100'", + Level: checker.INFO, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_body_max_length_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} diff --git a/checker/check-request-property-max-decreased.go b/checker/check-request-property-max-updated.go similarity index 55% rename from checker/check-request-property-max-decreased.go rename to checker/check-request-property-max-updated.go index 0aebee30..106efe0c 100644 --- a/checker/check-request-property-max-decreased.go +++ b/checker/check-request-property-max-updated.go @@ -39,6 +39,16 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * Path: path, Source: source, }) + } else { + result = append(result, ApiChange{ + Id: "request-body-max-increased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-body-max-increased"), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } } } @@ -54,22 +64,33 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * maxDiff.To == nil { return } - if propertyDiff.Revision.Value.ReadOnly { - return - } - if !IsDecreasedValue(maxDiff) { - return + if IsDecreasedValue(maxDiff) { + level := ERR + if propertyDiff.Revision.Value.ReadOnly { + level = INFO + } + + result = append(result, ApiChange{ + Id: "request-property-max-decreased", + Level: level, + Text: fmt.Sprintf(config.i18n("request-property-max-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } else { + result = append(result, ApiChange{ + Id: "request-property-max-increased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-property-max-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } - result = append(result, ApiChange{ - Id: "request-property-max-decreased", - Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-max-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: source, - }) }) } } diff --git a/checker/check-request-property-max-updated_test.go b/checker/check-request-property-max-updated_test.go new file mode 100644 index 00000000..e16dc3b9 --- /dev/null +++ b/checker/check-request-property-max-updated_test.go @@ -0,0 +1,117 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: decreasing request property maximum value +func TestRequestPropertyMaxDecreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + + max := float64(10) + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-max-decreased", + Level: checker.ERR, + Text: "the 'name' request property's max was decreased to '10.00'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_max_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: increasing request property maximum value +func TestRequestPropertyMaxIncreasingCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + + max := float64(20) + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-max-increased", + Level: checker.INFO, + Text: "the 'name' request property's max was increased from '15.00' to '20.00'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_max_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: increasing request body maximum value +func TestRequestBodyMaxIncreasingCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + + max := float64(20) + newMax := float64(25) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-max-increased", + Level: checker.INFO, + Text: "the request's body max was increased from '20.00' to '25.00'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_max_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: decreasing request body maximum value +func TestRequestBodyMaxDecreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_max_decreased_base.yaml") + require.NoError(t, err) + + max := float64(25) + newMax := float64(20) + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-max-decreased", + Level: checker.ERR, + Text: "the request's body max was decreased to '20.00'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_max_decreased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} diff --git a/checker/check-request-property-min-length-updated.go b/checker/check-request-property-min-length-updated.go new file mode 100644 index 00000000..c51cb3c5 --- /dev/null +++ b/checker/check-request-property-min-length-updated.go @@ -0,0 +1,95 @@ +package checker + +import ( + "fmt" + + "github.com/tufin/oasdiff/diff" +) + +func RequestPropertyMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config Config) Changes { + result := make(Changes, 0) + if diffReport.PathsDiff == nil { + return result + } + for path, pathItem := range diffReport.PathsDiff.Modified { + if pathItem.OperationsDiff == nil { + continue + } + for operation, operationItem := range pathItem.OperationsDiff.Modified { + if operationItem.RequestBodyDiff == nil || + operationItem.RequestBodyDiff.ContentDiff == nil || + operationItem.RequestBodyDiff.ContentDiff.MediaTypeModified == nil { + continue + } + source := (*operationsSources)[operationItem.Revision] + + modifiedMediaTypes := operationItem.RequestBodyDiff.ContentDiff.MediaTypeModified + for _, mediaTypeDiff := range modifiedMediaTypes { + if mediaTypeDiff.SchemaDiff != nil && mediaTypeDiff.SchemaDiff.MinLengthDiff != nil { + minLengthDiff := mediaTypeDiff.SchemaDiff.MinLengthDiff + if minLengthDiff.From != nil && + minLengthDiff.To != nil { + if IsIncreasedValue(minLengthDiff) { + result = append(result, ApiChange{ + Id: "request-body-min-length-increased", + Level: ERR, + Text: fmt.Sprintf(config.i18n("request-body-min-length-increased"), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } else { + result = append(result, ApiChange{ + Id: "request-body-min-length-decreased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-body-min-length-decreased"), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } + } + } + + CheckModifiedPropertiesDiff( + mediaTypeDiff.SchemaDiff, + func(propertyPath string, propertyName string, propertyDiff *diff.SchemaDiff, parent *diff.SchemaDiff) { + minLengthDiff := propertyDiff.MinLengthDiff + if minLengthDiff == nil { + return + } + if minLengthDiff.From == nil || + minLengthDiff.To == nil { + return + } + + if IsDecreasedValue(minLengthDiff) { + result = append(result, ApiChange{ + Id: "request-property-min-length-decreased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-property-min-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } else { + result = append(result, ApiChange{ + Id: "request-property-min-length-increased", + Level: ERR, + Text: fmt.Sprintf(config.i18n("request-property-min-length-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } + + }) + } + } + } + return result +} diff --git a/checker/check-request-property-min-length-updated_test.go b/checker/check-request-property-min-length-updated_test.go new file mode 100644 index 00000000..5a5c01df --- /dev/null +++ b/checker/check-request-property-min-length-updated_test.go @@ -0,0 +1,109 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: decreasing minLength of request property +func TestRequestPropertyMinLengthDecreased(t *testing.T) { + s1, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.MinLength = uint64(2) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-min-length-decreased", + Text: "the 'name' request property's minLength was decreased from '3' to '2'", + Comment: "", + Level: checker.INFO, + Operation: "POST", + Path: "/products", + Source: "../data/checker/request_property_min_length_decreased_base.yaml", + OperationId: "addProduct", + }, errs[0]) +} + +// CL: increasing minLength of request property +func TestRequestPropertyMinLengthIncreased(t *testing.T) { + s1, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.MinLength = uint64(5) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-min-length-increased", + Text: "the 'name' request property's minLength was increased from '3' to '5'", + Comment: "", + Level: checker.ERR, + Operation: "POST", + Path: "/products", + Source: "../data/checker/request_property_min_length_decreased_base.yaml", + OperationId: "addProduct", + }, errs[0]) +} + +// CL: increasing minLength of request body +func TestRequestBodyMinLengthIncreased(t *testing.T) { + s1, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MinLength = uint64(100) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-min-length-increased", + Text: "the request's body minLength was increased from '10' to '100'", + Comment: "", + Level: checker.ERR, + Operation: "POST", + Path: "/products", + Source: "../data/checker/request_property_min_length_decreased_base.yaml", + OperationId: "addProduct", + }, errs[0]) +} + +// CL: decreasing minLength of request body +func TestRequestBodyMinLengthDecreased(t *testing.T) { + s1, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_length_decreased_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MinLength = uint64(1) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-min-length-decreased", + Text: "the request's body minLength was decreased from '10' to '1'", + Comment: "", + Level: checker.INFO, + Operation: "POST", + Path: "/products", + Source: "../data/checker/request_property_min_length_decreased_base.yaml", + OperationId: "addProduct", + }, errs[0]) +} diff --git a/checker/check-request-property-min-increased.go b/checker/check-request-property-min-updated.go similarity index 56% rename from checker/check-request-property-min-increased.go rename to checker/check-request-property-min-updated.go index c8b7cf44..87242a77 100644 --- a/checker/check-request-property-min-increased.go +++ b/checker/check-request-property-min-updated.go @@ -39,6 +39,16 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * Path: path, Source: source, }) + } else { + result = append(result, ApiChange{ + Id: "request-body-min-decreased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-body-min-decreased"), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } } } @@ -54,22 +64,28 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * minDiff.To == nil { return } - if propertyDiff.Revision.Value.ReadOnly { - return - } - if !IsIncreasedValue(minDiff) { - return + if IsIncreasedValue(minDiff) { + result = append(result, ApiChange{ + Id: "request-property-min-increased", + Level: ConditionalError(!propertyDiff.Revision.Value.ReadOnly), + Text: fmt.Sprintf(config.i18n("request-property-min-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) + } else { + result = append(result, ApiChange{ + Id: "request-property-min-decreased", + Level: INFO, + Text: fmt.Sprintf(config.i18n("request-property-min-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Operation: operation, + OperationId: operationItem.Revision.OperationID, + Path: path, + Source: source, + }) } - result = append(result, ApiChange{ - Id: "request-property-min-increased", - Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-min-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), - Operation: operation, - OperationId: operationItem.Revision.OperationID, - Path: path, - Source: source, - }) }) } } diff --git a/checker/check-request-property-min-updated_test.go b/checker/check-request-property-min-updated_test.go new file mode 100644 index 00000000..266b6d3a --- /dev/null +++ b/checker/check-request-property-min-updated_test.go @@ -0,0 +1,55 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: increasing minimum value of request property +func TestRequestPropertyMinIncreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_min_increased_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_increased_revision.yaml") + require.NoError(t, err) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinIncreasedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-min-increased", + Text: "the 'age' request property's min was increased to '15.00'", + Level: checker.ERR, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_min_increased_revision.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: decreasing minimum value of request property +func TestRequestPropertyMinDecreasedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_min_increased_revision.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_min_increased_base.yaml") + require.NoError(t, err) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinIncreasedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-min-decreased", + Text: "the 'age' request property's min was decreased from '15.00' to '10.00'", + Level: checker.INFO, + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_min_increased_base.yaml", + OperationId: "addPet", + }, errs[0]) +} diff --git a/checker/check-request-property-type-changed.go b/checker/check-request-property-type-changed.go index cd408cab..ea9c5f9b 100644 --- a/checker/check-request-property-type-changed.go +++ b/checker/check-request-property-type-changed.go @@ -29,17 +29,20 @@ func RequestPropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources *d schemaDiff := mediaTypeDiff.SchemaDiff typeDiff := schemaDiff.TypeDiff formatDiff := schemaDiff.FormatDiff - if breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff) { + + if !typeDiff.Empty() || !formatDiff.Empty() { typeDiff, formatDiff = fillEmptyTypeAndFormatDiffs(typeDiff, schemaDiff, formatDiff) + result = append(result, ApiChange{ Id: "request-body-type-changed", - Level: ERR, + Level: ConditionalError(breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff)), Text: fmt.Sprintf(config.i18n("request-body-type-changed"), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, Source: source, }) + } } @@ -52,11 +55,12 @@ func RequestPropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources *d schemaDiff := propertyDiff typeDiff := schemaDiff.TypeDiff formatDiff := schemaDiff.FormatDiff - if breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff) { + + if !typeDiff.Empty() || !formatDiff.Empty() { typeDiff, formatDiff = fillEmptyTypeAndFormatDiffs(typeDiff, schemaDiff, formatDiff) result = append(result, ApiChange{ Id: "request-property-type-changed", - Level: ERR, + Level: ConditionalError(breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff)), Text: fmt.Sprintf(config.i18n("request-property-type-changed"), ColorizedValue(propertyFullName(propertyPath, propertyName)), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, diff --git a/checker/check-request-property-type-changed_test.go b/checker/check-request-property-type-changed_test.go new file mode 100644 index 00000000..b5b2f546 --- /dev/null +++ b/checker/check-request-property-type-changed_test.go @@ -0,0 +1,132 @@ +package checker_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" +) + +// CL: changing request body type +func TestRequestBodyTypeChangedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Type = "array" + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyTypeChangedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-type-changed", + Level: checker.ERR, + Text: "the request's body type/format changed from 'object'/'none' to 'array'/'none'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_type_changed_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: changing request body type +func TestRequestBodyFormatChangedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Format = "uuid" + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyTypeChangedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-body-type-changed", + Level: checker.ERR, + Text: "the request's body type/format changed from 'object'/'none' to 'object'/'uuid'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_type_changed_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: changing request property type +func TestRequestPropertyTypeChangedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_type_changed_revision.yaml") + require.NoError(t, err) + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyTypeChangedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-type-changed", + Level: checker.ERR, + Text: "the 'age' request property type/format changed from 'integer'/'int32' to 'string'/'string'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_type_changed_revision.yaml", + OperationId: "addPet", + }, errs[0]) +} + +// CL: changing request property format +func TestRequestPropertyFormatChangedCheck(t *testing.T) { + s1, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["age"].Value.Format = "uuid" + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyTypeChangedCheck), d, osm, checker.ERR) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-type-changed", + Level: checker.ERR, + Text: "the 'age' request property type/format changed from 'integer'/'int32' to 'integer'/'uuid'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_type_changed_base.yaml", + OperationId: "addPet", + }, errs[0]) +} + +func TestRequestPropertyFormatChangedCheckNonBreaking(t *testing.T) { + s1, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + s2, err := open("../data/checker/request_property_type_changed_base.yaml") + require.NoError(t, err) + + s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["age"].Value.Type = "integer" + s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["age"].Value.Type = "number" + + d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2) + require.NoError(t, err) + + errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyTypeChangedCheck), d, osm, checker.INFO) + require.Len(t, errs, 1) + require.Equal(t, checker.ApiChange{ + Id: "request-property-type-changed", + Level: checker.INFO, + Text: "the 'age' request property type/format changed from 'integer'/'int32' to 'number'/'int32'", + Operation: "POST", + Path: "/pets", + Source: "../data/checker/request_property_type_changed_base.yaml", + OperationId: "addPet", + }, errs[0]) +} diff --git a/checker/config.go b/checker/config.go index e4d415a4..fdcaf549 100644 --- a/checker/config.go +++ b/checker/config.go @@ -20,3 +20,11 @@ func (c *Config) getLogLevel(checkerId string, defaultLevel Level) Level { } return defaultLevel } + +func ConditionalError(isConditionSatisfied bool) Level { + if isConditionSatisfied { + return ERR + } + + return INFO +} diff --git a/checker/default_checks.go b/checker/default_checks.go index efee0c0f..a09712a5 100644 --- a/checker/default_checks.go +++ b/checker/default_checks.go @@ -92,8 +92,8 @@ func defaultChecks() []BackwardCompatibilityCheck { RequestPropertyMaxLengthSetCheck, RequestParameterMaxLengthSetCheck, ResponsePropertyMaxLengthUnsetCheck, + RequestPropertyMaxLengthUpdatedCheck, RequestParameterMaxLengthUpdatedCheck, - RequestPropertyMaxLengthDecreasedCheck, ResponsePropertyMaxLengthIncreasedCheck, ResponsePropertyMinLengthDecreasedCheck, RequestPropertyMaxSetCheck, @@ -110,8 +110,8 @@ func defaultChecks() []BackwardCompatibilityCheck { RequestPropertyMinItemsIncreasedCheck, ResponsePropertyMinItemsUnsetCheck, ResponsePropertyMinItemsDecreasedCheck, + RequestPropertyEnumValueUpdatedCheck, RequestParameterEnumValueUpdatedCheck, - RequestPropertyEnumValueRemovedCheck, ResponsePropertyEnumValueAddedCheck, RequestParameterXExtensibleEnumValueRemovedCheck, RequestPropertyXExtensibleEnumValueRemovedCheck, diff --git a/checker/localizations/localizations.go b/checker/localizations/localizations.go index 2f316d3d..ccd0fad6 100644 --- a/checker/localizations/localizations.go +++ b/checker/localizations/localizations.go @@ -1,6 +1,6 @@ // Code generated by go-localize; DO NOT EDIT. // This file was generated by robots at -// 2023-07-27 00:53:53.787203 +0100 IST m=+0.006411417 +// 2023-07-31 11:03:40.448119 +0100 IST m=+0.005217418 package localizations @@ -65,17 +65,23 @@ var localizations = map[string]string{ "en.messages.request-body-became-required": "request body became required", "en.messages.request-body-enum-value-removed": "request body enum value removed %s", "en.messages.request-body-max-decreased": "the request's body max was decreased to %s", + "en.messages.request-body-max-increased": "the request's body max was increased from %s to %s", "en.messages.request-body-max-length-decreased": "the request's body maxLength was decreased to %s", + "en.messages.request-body-max-length-increased": "the request's body maxLength was increased from %s to %s", "en.messages.request-body-max-length-set": "the request's body maxLength was set to %s", "en.messages.request-body-max-length-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", "en.messages.request-body-max-set": "the request's body max was set to %s", "en.messages.request-body-max-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", "en.messages.request-body-media-type-added": "added the media type %s to the request body", "en.messages.request-body-media-type-removed": "removed the media type %s from the request body", + "en.messages.request-body-min-decreased": "the request's body min was decreased to from %s to %s", "en.messages.request-body-min-increased": "the request's body min was increased to %s", + "en.messages.request-body-min-items-decreased": "the request's body minItems was decreased from %s to %s", "en.messages.request-body-min-items-increased": "the request's body minItems was increased to %s", "en.messages.request-body-min-items-set": "the request's body minItems was set to %s", "en.messages.request-body-min-items-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", + "en.messages.request-body-min-length-decreased": "the request's body minLength was decreased from %s to %s", + "en.messages.request-body-min-length-increased": "the request's body minLength was increased from %s to %s", "en.messages.request-body-min-set": "the request's body min was set to %s", "en.messages.request-body-min-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", "en.messages.request-body-one-of-added": "added %s to the request body 'oneOf' list", @@ -122,17 +128,24 @@ var localizations = map[string]string{ "en.messages.request-property-became-enum": "request property %s was restricted to a list of enum values", "en.messages.request-property-became-not-nullable": "the request property %s became not nullable", "en.messages.request-property-became-required": "the request property %s became required", + "en.messages.request-property-enum-value-added": "added the new %s enum value to the request property %s", "en.messages.request-property-enum-value-removed": "removed the enum value %s of the request property %s", "en.messages.request-property-max-decreased": "the %s request property's max was decreased to %s", + "en.messages.request-property-max-increased": "the %s request property's max was increased from %s to %s", "en.messages.request-property-max-length-decreased": "the %s request property's maxLength was decreased to %s", + "en.messages.request-property-max-length-increased": "the %s request property's maxLength was increased from %s to %s", "en.messages.request-property-max-length-set": "the %s request property's maxLength was set to %s", "en.messages.request-property-max-length-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", "en.messages.request-property-max-set": "the %s request property's max was set to %s", "en.messages.request-property-max-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", + "en.messages.request-property-min-decreased": "the %s request property's min was decreased from %s to %s", "en.messages.request-property-min-increased": "the %s request property's min was increased to %s", + "en.messages.request-property-min-items-decreased": "the %s request property's minItems was decreased from %s to %s", "en.messages.request-property-min-items-increased": "the %s request property's minItems was increased to %s", "en.messages.request-property-min-items-set": "the %s request property's minItems was set to %s", "en.messages.request-property-min-items-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", + "en.messages.request-property-min-length-decreased": "the %s request property's minLength was decreased from %s to %s", + "en.messages.request-property-min-length-increased": "the %s request property's minLength was increased from %s to %s", "en.messages.request-property-min-set": "the %s request property's min was set to %s", "en.messages.request-property-min-set-comment": "This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification.", "en.messages.request-property-one-of-added": "added %s to the %s request property 'oneOf' list", @@ -268,17 +281,23 @@ var localizations = map[string]string{ "ru.messages.request-body-became-required": "тело запроса стало обязательным", "ru.messages.request-body-enum-value-removed": "значение перечисления тела запроса удалено %s", "ru.messages.request-body-max-decreased": "значение max у тела запроса уменьшено до %s", + "ru.messages.request-body-max-increased": "максимум тела запроса был увеличен с %s до %s", "ru.messages.request-body-max-length-decreased": "значение maxLength у тела запроса уменьшено до %s", + "ru.messages.request-body-max-length-increased": "максимальная длина тела запроса была увеличена с %s до %s", "ru.messages.request-body-max-length-set": "у тела запроса задано значение maxLength в %s", "ru.messages.request-body-max-length-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", "ru.messages.request-body-max-set": "у тела запроса задано значение max в %s", "ru.messages.request-body-max-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", "ru.messages.request-body-media-type-added": "добавлен тип медиа для тела запроса %s", "ru.messages.request-body-media-type-removed": "удален тип медиа для тела запроса %s", + "ru.messages.request-body-min-decreased": "минимум тела запроса был уменьшен с %s до %s", "ru.messages.request-body-min-increased": "значение min у тела запроса увеличено до %s", + "ru.messages.request-body-min-items-decreased": "минимальное количество элементов тела запроса было уменьшено с %s до %s", "ru.messages.request-body-min-items-increased": "значение minItems у тела запроса увеличено до %s", "ru.messages.request-body-min-items-set": "задано значение minItems у тела запроса в %s", "ru.messages.request-body-min-items-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", + "ru.messages.request-body-min-length-decreased": "минимальная длина тела запроса была уменьшена с %s до %s", + "ru.messages.request-body-min-length-increased": "минимальная длина тела запроса была увеличена с %s до %s", "ru.messages.request-body-min-set": "задано значение min у тела запроса в %s", "ru.messages.request-body-min-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", "ru.messages.request-body-one-of-added": "добавлено %s в список 'oneOf' тела запроса", @@ -325,17 +344,24 @@ var localizations = map[string]string{ "ru.messages.request-property-became-enum": "свойство запроса %s было ограничено списком значений перечисления", "ru.messages.request-property-became-not-nullable": "свойство запроса %s стало недействительным", "ru.messages.request-property-became-required": "поле запроса %s стало обязательным", + "ru.messages.request-property-enum-value-added": "добавлено enum значение %s у поля запроса %s", "ru.messages.request-property-enum-value-removed": "удалено enum значение %s у поля запроса %s", "ru.messages.request-property-max-decreased": "значение max у поля запроса %s уменьшено до %s", + "ru.messages.request-property-max-increased": "максимум свойства запроса %s был увеличен с %s до %s", "ru.messages.request-property-max-length-decreased": "значение maxLength у поля запроса %s уменьшено до %s", + "ru.messages.request-property-max-length-increased": "максимальная длина свойства запроса %s была увеличена с %s до %s", "ru.messages.request-property-max-length-set": "у поля запроса %s задано значение maxLength в %s", "ru.messages.request-property-max-length-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", "ru.messages.request-property-max-set": "у поля запроса %s задано значение max в %s", "ru.messages.request-property-max-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", + "ru.messages.request-property-min-decreased": "минимум свойства запроса %s был уменьшен с %s до %s", "ru.messages.request-property-min-increased": "у поля запроса %s, увеличено значение min до %s", + "ru.messages.request-property-min-items-decreased": "минимальное количество элементов свойства запроса %s было уменьшено с %s до %s", "ru.messages.request-property-min-items-increased": "значение minItems у поля запроса %s увеличено до %s", "ru.messages.request-property-min-items-set": "у поля запроса %s задано значение minItems в %s", "ru.messages.request-property-min-items-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", + "ru.messages.request-property-min-length-decreased": "минимальная длина свойства запроса %s была уменьшена с %s до %s", + "ru.messages.request-property-min-length-increased": "минимальная длина свойства запроса %s была увеличена с %s до %s", "ru.messages.request-property-min-set": "у поля запроса %s задано значение min в %s", "ru.messages.request-property-min-set-comment": "Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию.", "ru.messages.request-property-one-of-added": "добавлено %s в список 'oneOf' свойства запроса %s", diff --git a/checker/localizations_src/en/messages.yaml b/checker/localizations_src/en/messages.yaml index 24aa7809..4700fa71 100644 --- a/checker/localizations_src/en/messages.yaml +++ b/checker/localizations_src/en/messages.yaml @@ -72,10 +72,19 @@ request-property-became-not-nullable: the request property %s became not nullabl request-body-became-not-nullable: the request's body became not nullable request-property-became-enum: request property %s was restricted to a list of enum values request-property-enum-value-removed: removed the enum value %s of the request property %s +request-property-enum-value-added: added the new %s enum value to the request property %s request-body-max-decreased: the request's body max was decreased to %s request-property-max-decreased: the %s request property's max was decreased to %s request-body-max-length-decreased: the request's body maxLength was decreased to %s request-property-max-length-decreased: the %s request property's maxLength was decreased to %s +request-body-min-length-increased: the request's body minLength was increased from %s to %s +request-property-min-length-increased: the %s request property's minLength was increased from %s to %s +request-body-min-length-decreased: the request's body minLength was decreased from %s to %s +request-property-min-length-decreased: the %s request property's minLength was decreased from %s to %s +request-body-max-increased: the request's body max was increased from %s to %s +request-property-max-increased: the %s request property's max was increased from %s to %s +request-body-max-length-increased: the request's body maxLength was increased from %s to %s +request-property-max-length-increased: the %s request property's maxLength was increased from %s to %s request-body-max-length-set: the request's body maxLength was set to %s request-body-max-length-set-comment: This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification. request-property-max-length-set: the %s request property's maxLength was set to %s @@ -88,6 +97,10 @@ request-body-min-increased: the request's body min was increased to %s request-property-min-increased: the %s request property's min was increased to %s request-body-min-items-increased: the request's body minItems was increased to %s request-property-min-items-increased: the %s request property's minItems was increased to %s +request-body-min-decreased: the request's body min was decreased to from %s to %s +request-property-min-decreased: the %s request property's min was decreased from %s to %s +request-body-min-items-decreased: the request's body minItems was decreased from %s to %s +request-property-min-items-decreased: the %s request property's minItems was decreased from %s to %s request-body-min-items-set: the request's body minItems was set to %s request-body-min-items-set-comment: This is a warning because sometimes it is required to be set. But good clients should be checked to support this restriction before such change in specification. request-property-min-items-set: the %s request property's minItems was set to %s diff --git a/checker/localizations_src/ru/messages.yaml b/checker/localizations_src/ru/messages.yaml index 5159063b..970e60a6 100644 --- a/checker/localizations_src/ru/messages.yaml +++ b/checker/localizations_src/ru/messages.yaml @@ -72,6 +72,15 @@ request-property-became-not-nullable: свойство запроса %s ста request-body-became-not-nullable: тело запроса стало недействительным request-property-became-enum: свойство запроса %s было ограничено списком значений перечисления request-property-enum-value-removed: удалено enum значение %s у поля запроса %s +request-property-enum-value-added: добавлено enum значение %s у поля запроса %s +request-body-min-length-increased: минимальная длина тела запроса была увеличена с %s до %s +request-property-min-length-increased: минимальная длина свойства запроса %s была увеличена с %s до %s +request-body-min-length-decreased: минимальная длина тела запроса была уменьшена с %s до %s +request-property-min-length-decreased: минимальная длина свойства запроса %s была уменьшена с %s до %s +request-body-max-increased: максимум тела запроса был увеличен с %s до %s +request-property-max-increased: максимум свойства запроса %s был увеличен с %s до %s +request-body-max-length-increased: максимальная длина тела запроса была увеличена с %s до %s +request-property-max-length-increased: максимальная длина свойства запроса %s была увеличена с %s до %s request-body-max-decreased: значение max у тела запроса уменьшено до %s request-property-max-decreased: значение max у поля запроса %s уменьшено до %s request-body-max-length-decreased: значение maxLength у тела запроса уменьшено до %s @@ -88,6 +97,10 @@ request-body-min-increased: значение min у тела запроса ув request-property-min-increased: у поля запроса %s, увеличено значение min до %s request-body-min-items-increased: значение minItems у тела запроса увеличено до %s request-property-min-items-increased: значение minItems у поля запроса %s увеличено до %s +request-body-min-decreased: минимум тела запроса был уменьшен с %s до %s +request-property-min-decreased: минимум свойства запроса %s был уменьшен с %s до %s +request-body-min-items-decreased: минимальное количество элементов тела запроса было уменьшено с %s до %s +request-property-min-items-decreased: минимальное количество элементов свойства запроса %s было уменьшено с %s до %s request-body-min-items-set: задано значение minItems у тела запроса в %s request-body-min-items-set-comment: Это предупреждение, потому что иногда его требуется установить из соображений безопасности или из-за текущей ошибки в спецификации. Но хорошие клиенты должны быть проверены на поддержку этого ограничения перед внесением таких изменений в спецификацию. request-property-min-items-set: у поля запроса %s задано значение minItems в %s diff --git a/data/checker/request_body_max_length_decreased_base.yaml b/data/checker/request_body_max_length_decreased_base.yaml new file mode 100644 index 00000000..de412a5b --- /dev/null +++ b/data/checker/request_body_max_length_decreased_base.yaml @@ -0,0 +1,29 @@ +openapi: 3.0.1 +info: + title: Pet Store API + version: "1.0" +servers: + - url: https://api.example.com/v1 +paths: + /pets: + post: + operationId: addPet + requestBody: + content: + application/json: + schema: + type: object + properties: + id: + type: integer + name: + type: string + maxLength: 100 + description: + type: string + maxLength: 100 + required: true + responses: + "200": + description: OK +components: {} diff --git a/data/checker/request_property_enum_value_updated_base.yaml b/data/checker/request_property_enum_value_updated_base.yaml new file mode 100644 index 00000000..6345cbbc --- /dev/null +++ b/data/checker/request_property_enum_value_updated_base.yaml @@ -0,0 +1,43 @@ +openapi: 3.0.1 +info: + title: Pet Store + version: 1.0.0 +paths: + /pets: + post: + operationId: updatePet + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + description: Update an existing pet + responses: + "200": + description: OK +components: + schemas: + Pet: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + status: + type: string + enum: + - available + - pending + - sold + category: + type: string + enum: + - dog + - cat + - bird + required: + - name + - status + - category diff --git a/data/checker/request_property_max_decreased_base.yaml b/data/checker/request_property_max_decreased_base.yaml new file mode 100644 index 00000000..4b743bcc --- /dev/null +++ b/data/checker/request_property_max_decreased_base.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.1 +info: + title: Test API + version: 1.0.0 +paths: + /pets: + post: + operationId: addPet + requestBody: + content: + application/json: + schema: + type: object + properties: + name: + type: string + maximum: 15 + required: + - name + responses: + "200": + description: OK + diff --git a/data/checker/request_property_min_increased_base.yaml b/data/checker/request_property_min_increased_base.yaml new file mode 100644 index 00000000..a8c335b1 --- /dev/null +++ b/data/checker/request_property_min_increased_base.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.1 +info: + title: Test API + version: 1.0.0 +paths: + /pets: + post: + operationId: addPet + requestBody: + content: + application/json: + schema: + type: object + properties: + age: + type: integer + minimum: 10 + required: + - age + responses: + "200": + description: OK + diff --git a/data/checker/request_property_min_increased_revision.yaml b/data/checker/request_property_min_increased_revision.yaml new file mode 100644 index 00000000..ce064936 --- /dev/null +++ b/data/checker/request_property_min_increased_revision.yaml @@ -0,0 +1,23 @@ +openapi: 3.0.1 +info: + title: Test API + version: 1.0.0 +paths: + /pets: + post: + operationId: addPet + requestBody: + content: + application/json: + schema: + type: object + properties: + age: + type: integer + minimum: 15 + required: + - age + responses: + "200": + description: OK + diff --git a/data/checker/request_property_min_length_decreased_base.yaml b/data/checker/request_property_min_length_decreased_base.yaml new file mode 100644 index 00000000..b84faabd --- /dev/null +++ b/data/checker/request_property_min_length_decreased_base.yaml @@ -0,0 +1,31 @@ +openapi: 3.0.1 +info: + title: Product API + version: "1.0" +servers: + - url: https://api.example.com/v1 +paths: + /products: + post: + operationId: addProduct + requestBody: + content: + application/json: + schema: + type: object + minLength: 10 + properties: + id: + type: integer + name: + type: string + minLength: 3 + description: + type: string + minLength: 10 + required: true + + responses: + "200": + description: OK +components: {} diff --git a/data/checker/request_property_type_changed_base.yaml b/data/checker/request_property_type_changed_base.yaml new file mode 100644 index 00000000..7565cd4d --- /dev/null +++ b/data/checker/request_property_type_changed_base.yaml @@ -0,0 +1,24 @@ +openapi: 3.0.1 +info: + title: Sample API + version: 1.0.0 +paths: + /pets: + post: + summary: Add a new pet + operationId: addPet + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + format: string + age: + type: integer + format: int32 + required: + - name diff --git a/data/checker/request_property_type_changed_revision.yaml b/data/checker/request_property_type_changed_revision.yaml new file mode 100644 index 00000000..452285d0 --- /dev/null +++ b/data/checker/request_property_type_changed_revision.yaml @@ -0,0 +1,24 @@ +openapi: 3.0.1 +info: + title: Sample API + version: 1.0.0 +paths: + /pets: + post: + summary: Add a new pet + operationId: addPet + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + format: string + age: + type: string + format: string + required: + - name