diff --git a/checker/check_api_deprecation_test.go b/checker/check_api_deprecation_test.go index a6a2877c..5acf8dbd 100644 --- a/checker/check_api_deprecation_test.go +++ b/checker/check_api_deprecation_test.go @@ -23,7 +23,11 @@ func getDeprecationFile(file string) string { } func singleCheckConfig(c checker.BackwardCompatibilityCheck) *checker.Config { - return checker.NewConfig().WithSingleCheck(c) + return checker.NewConfig(checker.BackwardCompatibilityChecks{c}).WithSingleCheck(c) +} + +func allChecksConfig() *checker.Config { + return checker.NewConfig(checker.GetAllChecks()) } // BC: deleting an operation after sunset date is not breaking diff --git a/checker/check_breaking_min_max_test.go b/checker/check_breaking_min_max_test.go index d2c79a2b..dbfe69a4 100644 --- a/checker/check_breaking_min_max_test.go +++ b/checker/check_breaking_min_max_test.go @@ -22,7 +22,7 @@ func TestBreaking_RequestMaxLengthSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterMaxLengthDecreasedId, errs[0].GetId()) @@ -41,7 +41,7 @@ func TestBreaking_ResponseMaxLengthSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -55,7 +55,7 @@ func TestBreaking_RequestMinLengthSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -69,7 +69,7 @@ func TestBreaking_MinLengthSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Equal(t, checker.ResponseBodyMinLengthDecreasedId, errs[0].GetId()) } @@ -86,7 +86,7 @@ func TestBreaking_RequestMaxLengthGreater(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -103,7 +103,7 @@ func TestBreaking_ResponseMaxLengthGreater(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) } @@ -119,7 +119,7 @@ func TestBreaking_MaxLengthFromNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterMaxLengthSetId, errs[0].GetId()) @@ -137,7 +137,7 @@ func TestBreaking_ResponseMaxLengthFromNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -153,7 +153,7 @@ func TestBreaking_RequestMaxLengthToNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -169,7 +169,7 @@ func TestBreaking_ResponseMaxLengthToNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyMaxLengthUnsetId, errs[0].GetId()) @@ -185,7 +185,7 @@ func TestBreaking_MaxLengthBothNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -199,7 +199,7 @@ func TestBreaking_ResponseMaxLengthBothNil(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -213,7 +213,7 @@ func TestBreaking_RequestMinItemsSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -227,7 +227,7 @@ func TestBreaking_ResponseMinItemsSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyMinItemsDecreasedId, errs[0].GetId()) @@ -243,7 +243,7 @@ func TestBreaking_RequeatMinItemsGreater(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) } @@ -257,7 +257,7 @@ func TestBreaking_ResponseMinItemsGreater(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -274,7 +274,7 @@ func TestBreaking_MaxSmaller(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) } @@ -291,6 +291,6 @@ func TestBreaking_MaxSmallerInResponse(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } diff --git a/checker/check_breaking_property_test.go b/checker/check_breaking_property_test.go index 4d8e8d59..f1df2f99 100644 --- a/checker/check_breaking_property_test.go +++ b/checker/check_breaking_property_test.go @@ -30,7 +30,7 @@ func TestBreaking_NewRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.NewRequiredRequestHeaderPropertyId, errs[0].GetId()) @@ -50,7 +50,7 @@ func TestBreaking_NewNonRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -74,7 +74,7 @@ func TestBreaking_PropertyRequiredEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestHeaderPropertyBecameRequiredId, errs[0].GetId()) @@ -100,7 +100,7 @@ func TestBreaking_PropertyRequiredDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -114,7 +114,7 @@ func TestBreaking_RespBodyRequiredPropertyDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponsePropertyBecameOptionalId, errs[0].GetId()) @@ -130,7 +130,7 @@ func TestBreaking_ReqBodyBecameEnum(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyBecameEnumId, errs[0].GetId()) @@ -146,7 +146,7 @@ func TestBreaking_ReqBodyEnumValueAdded(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -160,7 +160,7 @@ func TestBreaking_ReqBodyBecameEnumAndTypeChanged(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 2) require.Equal(t, checker.RequestBodyBecameEnumId, errs[0].GetId()) require.Equal(t, checker.RequestBodyTypeChangedId, errs[1].GetId()) @@ -176,7 +176,7 @@ func TestBreaking_ReqPropertyBecameEnum(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameEnumId, errs[0].GetId()) @@ -192,7 +192,7 @@ func TestBreaking_ReqParameterBecameEnum(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterBecameEnumId, errs[0].GetId()) @@ -208,7 +208,7 @@ func TestBreaking_ReqParameterHeaderPropertyBecameEnum(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestHeaderPropertyBecameEnumId, errs[0].GetId()) @@ -224,7 +224,7 @@ func TestBreaking_RespBodyNullable(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyBecameNullableId, errs[0].GetId()) @@ -240,7 +240,7 @@ func TestBreaking_ReqBodyPropertyNotNullable(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecomeNotNullableId, errs[0].GetId()) @@ -256,7 +256,7 @@ func TestBreaking_RespBodyPropertyNullable(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponsePropertyBecameNullableId, errs[0].GetId()) @@ -272,7 +272,7 @@ func TestBreaking_RespBodyEmbeddedPropertyNullable(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponsePropertyBecameNullableId, errs[0].GetId()) @@ -288,7 +288,7 @@ func TestBreaking_RespBodyDeleteAndDisableRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) } @@ -302,7 +302,7 @@ func TestBreaking_ReqBodyNewRequiredPropertyNew(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -316,7 +316,7 @@ func TestBreaking_RespBodyRequiredPropertyEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -330,7 +330,7 @@ func TestBreaking_ReqBodyRequiredPropertyDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -344,7 +344,7 @@ func TestBreaking_ReqBodyRequiredPropertyEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameRequiredId, errs[0].GetId()) @@ -360,7 +360,7 @@ func TestBreaking_ReqBodyNewRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.NewRequiredRequestPropertyId, errs[0].GetId()) @@ -376,7 +376,7 @@ func TestBreaking_ReqBodyDeleteRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyRemovedId, errs[0].GetId()) @@ -393,7 +393,7 @@ func TestBreaking_ReqBodyDeleteRequiredProperty2(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Contains(t, errs, checker.ApiChange{ Id: checker.RequestPropertyRemovedId, Args: []any{"roleAssignments/items/role"}, @@ -414,7 +414,7 @@ func TestBreaking_RespBodyNewRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -428,7 +428,7 @@ func TestBreaking_RespBodyDeleteRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseRequiredPropertyRemovedId, errs[0].GetId()) @@ -444,7 +444,7 @@ func TestBreaking_RespBodyNewAllOfRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -458,7 +458,7 @@ func TestBreaking_RespBodyDeleteAllOfRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseRequiredPropertyRemovedId, errs[0].GetId()) @@ -474,7 +474,7 @@ func TestBreaking_ReadOnlyNewRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -488,7 +488,7 @@ func TestBreaking_ReadOnlyPropertyRequiredEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -502,7 +502,7 @@ func TestBreaking_WriteOnlyDeleteRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyRemovedId, errs[0].GetId()) @@ -519,7 +519,7 @@ func TestBreaking_WriteOnlyDeleteNonRequiredProperty(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 3) require.Equal(t, checker.RequestPropertyRemovedId, errs[0].GetId()) @@ -540,7 +540,7 @@ func TestBreaking_WriteOnlyPropertyRequiredDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -554,7 +554,7 @@ func TestBreaking_RequiredPropertyWriteOnlyEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -568,7 +568,7 @@ func TestBreaking_RequiredPropertyWriteOnlyDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 2) require.Equal(t, checker.ResponseRequiredPropertyBecameNonWriteOnlyId, errs[0].GetId()) @@ -587,7 +587,7 @@ func TestBreaking_Body(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameRequiredId, errs[0].GetId()) @@ -604,7 +604,7 @@ func TestBreaking_Items(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameRequiredId, errs[0].GetId()) @@ -621,7 +621,7 @@ func TestBreaking_ItemsWithDefault(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -635,7 +635,7 @@ func TestBreaking_AnyOf(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameRequiredId, errs[0].GetId()) @@ -651,7 +651,7 @@ func TestBreaking_NestedProp(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyBecameRequiredId, errs[0].GetId()) @@ -667,6 +667,6 @@ func TestBreaking_OneOf(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 3) } diff --git a/checker/check_breaking_request_type_changed_test.go b/checker/check_breaking_request_type_changed_test.go index 2794aa44..dbe3658a 100644 --- a/checker/check_breaking_request_type_changed_test.go +++ b/checker/check_breaking_request_type_changed_test.go @@ -23,7 +23,7 @@ func TestBreaking_ReqTypeStringToNumber(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the request's body type/format changed from 'string'/'' to 'number'/''", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -43,7 +43,7 @@ func TestBreaking_ReqTypeNumberToString(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the request's body type/format changed from 'number'/'' to 'string'/''", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -63,7 +63,7 @@ func TestBreaking_ReqTypeNumberToInteger(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the request's body type/format changed from 'number'/'' to 'integer'/''", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -83,7 +83,7 @@ func TestBreaking_ReqTypeIntegerToNumber(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibilityUntilLevel(checker.NewConfig(), d, osm, checker.INFO) + errs := checker.CheckBackwardCompatibilityUntilLevel(allChecksConfig(), d, osm, checker.INFO) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyTypeGeneralizedId, errs[0].GetId()) require.Equal(t, "the request's body type/format was generalized from 'integer'/'' to 'number'/''", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -104,7 +104,7 @@ func TestBreaking_ReqTypeNumberToInt32(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the request's body type/format changed from 'number'/'' to 'integer'/'int32'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) diff --git a/checker/check_breaking_response_type_changed_test.go b/checker/check_breaking_response_type_changed_test.go index dc120df1..2c6cb178 100644 --- a/checker/check_breaking_response_type_changed_test.go +++ b/checker/check_breaking_response_type_changed_test.go @@ -23,7 +23,7 @@ func TestBreaking_RespTypeStringToNumber(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the response's body type/format changed from 'string'/'' to 'number'/'' for status '200'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -43,7 +43,7 @@ func TestBreaking_RespTypeNumberToString(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the response's body type/format changed from 'number'/'' to 'string'/'' for status '200'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -63,7 +63,7 @@ func TestBreaking_RespTypeNumberToInteger(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -81,7 +81,7 @@ func TestBreaking_RespTypeIntegerToNumber(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.ResponseBodyTypeChangedId, errs[0].GetId()) require.Equal(t, "the response's body type/format changed from 'integer'/'' to 'number'/'' for status '200'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -102,7 +102,7 @@ func TestBreaking_RespTypeNumberToInt32(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -116,7 +116,7 @@ func TestBreaking_RespTypeChanged(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, "response-property-type-changed", errs[0].GetId()) require.Equal(t, "the '/items/testField' response's property type/format changed from 'string'/'' to 'integer'/'int32' for status '200'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) diff --git a/checker/check_breaking_test.go b/checker/check_breaking_test.go index c0928c73..a48dc683 100644 --- a/checker/check_breaking_test.go +++ b/checker/check_breaking_test.go @@ -30,7 +30,7 @@ func d(t *testing.T, config *diff.Config, v1, v2 int) checker.Changes { l2 := l(t, v2) d, osm, err := diff.GetWithOperationsSourcesMap(config, l1, l2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) return errs } @@ -51,7 +51,7 @@ func TestBreaking_DeletedOp(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.APIRemovedWithoutDeprecationId, errs[0].GetId()) @@ -69,7 +69,7 @@ func TestBreaking_AddingRequiredRequestBody(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.AddedRequiredRequestBodyId, errs[0].GetId()) @@ -91,7 +91,7 @@ func TestBreaking_RequestBodyRequiredEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestBodyBecameRequiredId, errs[0].GetId()) @@ -148,7 +148,7 @@ func TestBreaking_PathParamRename(t *testing.T) { &load.SpecInfo{Spec: s2}, ) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -163,7 +163,7 @@ func TestBreaking_NewPathParam(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.NewRequestPathParameterId, errs[0].GetId()) @@ -180,7 +180,7 @@ func TestBreaking_NewRequiredHeaderParam(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.NewRequiredRequestParameterId, errs[0].GetId()) @@ -197,7 +197,7 @@ func TestBreaking_HeaderParamRequiredEnabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.ApiChange{ @@ -221,7 +221,7 @@ func TestBreaking_ResponseHeaderParamRequiredDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseHeaderBecameOptionalId, errs[0].GetId()) @@ -238,7 +238,7 @@ func TestBreaking_ResponseHeaderRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -257,7 +257,7 @@ func TestBreaking_ResponseSuccessStatusUpdated(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -276,7 +276,7 @@ func TestBreaking_ResponseNonSuccessStatusUpdated(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.ResponseNonSuccessStatusRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.ResponseNonSuccessStatusRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -296,7 +296,7 @@ func TestBreaking_OperationIdRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.APIOperationIdRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.APIOperationIdRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -320,7 +320,7 @@ func TestBreaking_RequestBodyEnumRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.RequestBodyEnumValueRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.RequestBodyEnumValueRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -338,7 +338,7 @@ func TestBreaking_ResponsePropertyEnumRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.ResponsePropertyEnumValueRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.ResponsePropertyEnumValueRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -357,7 +357,7 @@ func TestBreaking_TagRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.APITagRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.APITagRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -377,7 +377,7 @@ func TestBreaking_ResponseMediaTypeEnumRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.ResponseMediaTypeEnumValueRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.ResponseMediaTypeEnumValueRemovedId), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -396,7 +396,7 @@ func TestBreaking_ResponseUnparseableStatusRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -412,7 +412,7 @@ func TestBreaking_ResponseErrorStatusRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) } @@ -429,7 +429,7 @@ func TestBreaking_OptionalResponseHeaderRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) for _, err := range errs { require.Equal(t, checker.WARN, err.GetLevel()) } @@ -449,7 +449,7 @@ func TestBreaking_ResponseDeleteMediaType(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.ResponseMediaTypeRemovedId, errs[0].GetId()) @@ -466,7 +466,7 @@ func TestBreaking_DeletePatten(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -480,7 +480,7 @@ func TestBreaking_AddPattern(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, "request-property-pattern-added", errs[0].GetId()) @@ -497,7 +497,7 @@ func TestBreaking_AddPatternRecursive(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, "request-property-pattern-added", errs[0].GetId()) @@ -514,7 +514,7 @@ func TestBreaking_ModifyPattern(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestPropertyPatternChangedId, errs[0].GetId()) @@ -532,7 +532,7 @@ func TestBreaking_GeneralizedPattern(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -546,7 +546,7 @@ func TestBreaking_ModifyParameterPattern(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterPatternChangedId, errs[0].GetId()) @@ -563,7 +563,7 @@ func TestBreaking_ModifyPatternToAnyString(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -579,7 +579,7 @@ func TestBreaking_ModifyRequiredOptionalParamDefaultValue(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterDefaultValueChangedId, errs[0].GetId()) require.Equal(t, "for the 'header' request parameter 'network-policies', default value was changed from 'X' to 'Y'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -597,7 +597,7 @@ func TestBreaking_SettingOptionalParamDefaultValue(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.RequestParameterDefaultValueAddedId, errs[0].GetId()) require.Equal(t, "for the 'header' request parameter 'network-policies', default value 'Y' was added", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -615,7 +615,7 @@ func TestBreaking_RemovingOptionalParamDefaultValue(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, "request-parameter-default-value-removed", errs[0].GetId()) require.Equal(t, "for the 'header' request parameter 'network-policies', default value 'Y' was removed", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -636,7 +636,7 @@ func TestBreaking_ModifyRequiredRequiredParamDefaultValue(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -653,7 +653,7 @@ func TestBreaking_SchemaRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - checks := checker.NewConfig().WithOptionalCheck(checker.APISchemasRemovedId) + checks := allChecksConfig().WithOptionalCheck(checker.APISchemasRemovedId) errs := checker.CheckBackwardCompatibility(checks, d, osm) for _, err := range errs { require.Equal(t, checker.ERR, err.GetLevel()) @@ -675,7 +675,7 @@ func TestBreaking_RequestBodyMediaTypeRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.NotEmpty(t, errs) require.Equal(t, "request-body-media-type-removed", errs[0].GetId()) require.Equal(t, "removed the media type 'application/json' from the request body", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -690,7 +690,7 @@ func TestBreaking_RequestPropertyAnyOfRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 2) @@ -712,7 +712,7 @@ func TestBreaking_RequestPropertyOneOfRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 2) require.Equal(t, checker.RequestBodyOneOfRemovedId, errs[0].GetId()) @@ -733,7 +733,7 @@ func TestBreaking_RequestPropertyAllOfAdded(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 2) @@ -755,7 +755,7 @@ func TestBreaking_RequestPropertyAllOfRemoved(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 2) diff --git a/checker/check_not_breaking_test.go b/checker/check_not_breaking_test.go index 487fe42c..69dcacbb 100644 --- a/checker/check_not_breaking_test.go +++ b/checker/check_not_breaking_test.go @@ -15,10 +15,10 @@ func verifyNonBreakingChangeIsChangelogEntry(t *testing.T, d *diff.Diff, osm *di t.Helper() // Check no breaking change is detected - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) // Check changelog captures the change - errs = checker.CheckBackwardCompatibilityUntilLevel(checker.NewConfig(), d, osm, checker.INFO) + errs = checker.CheckBackwardCompatibilityUntilLevel(allChecksConfig(), d, osm, checker.INFO) require.Len(t, errs, 1) require.Equal(t, checker.INFO, errs[0].GetLevel()) require.Equal(t, changeId, errs[0].GetId()) @@ -31,7 +31,7 @@ func TestBreaking_Same(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -46,7 +46,7 @@ func TestBreaking_AddingOptionalRequestBody(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -125,7 +125,7 @@ func TestBreaking_NewOptionalHeaderParam(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -139,7 +139,7 @@ func TestBreaking_HeaderParamRequiredDisabled(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - changes := checker.CheckBackwardCompatibilityUntilLevel(checker.NewConfig(), d, osm, checker.INFO) + changes := checker.CheckBackwardCompatibilityUntilLevel(allChecksConfig(), d, osm, checker.INFO) require.NotEmpty(t, changes) require.Equal(t, checker.RequestParameterBecomeOptionalId, changes[0].GetId()) require.Len(t, changes, 1) @@ -159,7 +159,7 @@ func TestBreaking_NewRequiredResponseHeader(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -191,7 +191,7 @@ func TestBreaking_ResponseAddMediaType(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -205,7 +205,7 @@ func TestBreaking_DeprecatedOperation(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibilityUntilLevel(checker.NewConfig(), d, osm, checker.INFO) + errs := checker.CheckBackwardCompatibilityUntilLevel(allChecksConfig(), d, osm, checker.INFO) require.Len(t, errs, 1) require.Equal(t, errs[0].GetLevel(), checker.INFO) } @@ -219,7 +219,7 @@ func TestBreaking_DeprecatedParameter(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -232,7 +232,7 @@ func TestBreaking_DeprecatedHeader(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -245,7 +245,7 @@ func TestBreaking_DeprecatedSchema(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -259,7 +259,7 @@ func TestBreaking_Servers(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } diff --git a/checker/checker_test.go b/checker/checker_test.go index 075ba9b9..6bad706e 100644 --- a/checker/checker_test.go +++ b/checker/checker_test.go @@ -19,7 +19,7 @@ func TestBreaking_StabilityLevelDecreased(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.IsType(t, checker.ApiChange{}, errs[0]) @@ -41,7 +41,7 @@ func TestBreaking_StabilityLevelIncreased(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Empty(t, errs) } @@ -55,7 +55,7 @@ func TestBreaking_InvalidStabilityLevelInRevision(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.APIInvalidStabilityLevelId, errs[0].GetId()) require.Equal(t, "failed to parse stability level: 'value is not one of draft, alpha, beta or stable: \"invalid\"'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -72,7 +72,7 @@ func TestBreaking_InvalidStabilityLevelInBase(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.APIInvalidStabilityLevelId, errs[0].GetId()) require.Equal(t, "failed to parse stability level: 'value is not one of draft, alpha, beta or stable: \"invalid\"'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) @@ -89,7 +89,7 @@ func TestBreaking_InvalidNonJsonStabilityLevel(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Len(t, errs, 1) require.Equal(t, checker.APIInvalidStabilityLevelId, errs[0].GetId()) require.Equal(t, "failed to parse stability level: 'x-stability-level isn't a string nor valid json'", errs[0].GetUncolorizedText(checker.NewDefaultLocalizer())) diff --git a/checker/config.go b/checker/config.go index 17f8754d..b8c877a8 100644 --- a/checker/config.go +++ b/checker/config.go @@ -15,13 +15,10 @@ const ( ) // NewConfig creates a new configuration with default values. -func NewConfig() *Config { - - rules := GetAllRules() - +func NewConfig(checks BackwardCompatibilityChecks) *Config { return &Config{ - Checks: rulesToChecks(rules), - LogLevels: rulesToLevels(rules), + Checks: checks, + LogLevels: GetCheckLevels(), MinSunsetBetaDays: DefaultBetaDeprecationDays, MinSunsetStableDays: DefaultStableDeprecationDays, } @@ -40,6 +37,14 @@ func (config *Config) WithOptionalChecks(ids []string) *Config { return config } +func (config *Config) WithSeverityLevels(severityLevels map[string]Level) *Config { + for id, level := range severityLevels { + config.LogLevels[id] = level + } + + return config +} + // WithDeprecation sets the number of days before sunset for deprecation warnings. func (config *Config) WithDeprecation(deprecationDaysBeta uint, deprecationDaysStable uint) *Config { config.MinSunsetBetaDays = deprecationDaysBeta diff --git a/checker/config_test.go b/checker/config_test.go index e4d3c93a..014d27e0 100644 --- a/checker/config_test.go +++ b/checker/config_test.go @@ -13,7 +13,7 @@ const ( ) func TestNewConfig(t *testing.T) { - config := checker.NewConfig() + config := allChecksConfig() require.Len(t, config.Checks, numOfChecks) require.Len(t, config.LogLevels, numOfIds) require.Equal(t, checker.DefaultBetaDeprecationDays, config.MinSunsetBetaDays) @@ -21,7 +21,7 @@ func TestNewConfig(t *testing.T) { } func TestNewConfigWithDeprecation(t *testing.T) { - config := checker.NewConfig().WithDeprecation(10, 20) + config := allChecksConfig().WithDeprecation(10, 20) require.Len(t, config.Checks, numOfChecks) require.Len(t, config.LogLevels, numOfIds) require.Equal(t, uint(10), config.MinSunsetBetaDays) @@ -29,6 +29,11 @@ func TestNewConfigWithDeprecation(t *testing.T) { } func TestNewConfigWithOptionalCheck(t *testing.T) { - config := checker.NewConfig().WithOptionalCheck("id") + config := allChecksConfig().WithOptionalCheck("id") + require.Equal(t, checker.ERR, config.LogLevels["id"]) +} + +func TestNewConfigWithSeverityLevels(t *testing.T) { + config := allChecksConfig().WithSeverityLevels(map[string]checker.Level{"id": checker.ERR}) require.Equal(t, checker.ERR, config.LogLevels["id"]) } diff --git a/checker/example_test.go b/checker/example_test.go new file mode 100644 index 00000000..cffc8397 --- /dev/null +++ b/checker/example_test.go @@ -0,0 +1,76 @@ +package checker_test + +import ( + "fmt" + "os" + "strings" + + "github.com/getkin/kin-openapi/openapi3" + "github.com/tufin/oasdiff/checker" + "github.com/tufin/oasdiff/diff" + "github.com/tufin/oasdiff/load" +) + +func ExampleCheckBackwardCompatibility() { + loader := openapi3.NewLoader() + loader.IsExternalRefsAllowed = true + + s1, err := load.NewSpecInfo(loader, load.NewSource("../data/openapi-test1.yaml")) + if err != nil { + fmt.Fprintf(os.Stderr, "failed to load spec: %v", err) + return + } + + s2, err := load.NewSpecInfo(loader, load.NewSource("../data/openapi-test3.yaml")) + if err != nil { + fmt.Fprintf(os.Stderr, "failed to load spec: %v", err) + return + } + + diffRes, operationsSources, err := diff.GetPathsDiff(diff.NewConfig(), + []*load.SpecInfo{s1}, + []*load.SpecInfo{s2}, + ) + + if err != nil { + fmt.Fprintf(os.Stderr, "diff failed with %v", err) + return + } + + errs := checker.CheckBackwardCompatibility(checker.NewConfig(checker.GetAllChecks()), diffRes, operationsSources) + + // process configuration file for ignoring errors + errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example.txt", checker.NewDefaultLocalizer()) + if err != nil { + fmt.Fprintf(os.Stderr, "ignore errors failed with %v", err) + return + } + + // process configuration file for ignoring warnings + errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.WARN, errs, "../data/ignore-warn-example.txt", checker.NewDefaultLocalizer()) + if err != nil { + fmt.Fprintf(os.Stderr, "ignore warnings failed with %v", err) + return + } + + // pretty print breaking changes errors + if len(errs) > 0 { + localizer := checker.NewDefaultLocalizer() + count := errs.GetLevelCount() + fmt.Print(localizer("total-errors", len(errs), count[checker.ERR], "error", count[checker.WARN], "warning")) + for _, bcerr := range errs { + fmt.Printf("%s\n\n", strings.TrimRight(bcerr.SingleLineError(localizer, checker.ColorNever), " ")) + } + } + + // Output: + // 4 breaking changes: 1 error, 3 warning + // error at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score removed the success response with the status '201' [response-success-status-removed]. + // + // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'cookie' request parameter 'test' [request-parameter-removed]. + // + // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'header' request parameter 'user' [request-parameter-removed]. + // + // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'query' request parameter 'filter' [request-parameter-removed]. + // +} diff --git a/checker/ignore_test.go b/checker/ignore_test.go index 6de1062a..c5327d87 100644 --- a/checker/ignore_test.go +++ b/checker/ignore_test.go @@ -14,7 +14,7 @@ func TestIgnore(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Equal(t, 6, len(errs)) errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example.txt", checker.NewDefaultLocalizer()) @@ -28,7 +28,7 @@ func TestIgnoreSubpath(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Equal(t, 3, len(errs)) errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example-2.txt", checker.NewDefaultLocalizer()) @@ -42,7 +42,7 @@ func TestIgnoreOnlyIncludedSubpaths(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig(), d, osm) require.Equal(t, 2, len(errs)) // detect new and newest were deleted errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example-3.txt", checker.NewDefaultLocalizer()) @@ -59,7 +59,7 @@ func TestIgnoreComponent(t *testing.T) { d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2) require.NoError(t, err) - errs := checker.CheckBackwardCompatibility(checker.NewConfig().WithOptionalCheck(checker.APISchemasRemovedId), d, osm) + errs := checker.CheckBackwardCompatibility(allChecksConfig().WithOptionalCheck(checker.APISchemasRemovedId), d, osm) require.Equal(t, 8, len(errs)) errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example.txt", checker.NewDefaultLocalizer()) diff --git a/checker/level.go b/checker/level.go index 1d2258c4..26933c43 100644 --- a/checker/level.go +++ b/checker/level.go @@ -1,9 +1,14 @@ package checker import ( + "bufio" "fmt" + "io" + "os" + "strings" "github.com/TwiN/go-color" + "github.com/tufin/oasdiff/utils" ) type Level int @@ -16,11 +21,11 @@ const ( func NewLevel(level string) (Level, error) { switch level { - case "ERR": + case "ERR", "err": return ERR, nil - case "WARN": + case "WARN", "warn": return WARN, nil - case "INFO": + case "INFO", "info": return INFO, nil } return INFO, fmt.Errorf("invalid level %s", level) @@ -63,3 +68,49 @@ func (level Level) PrettyString() string { func (level Level) IsBreaking() bool { return level == ERR || level == WARN } + +// ProcessSeverityLevels reads a file with severity levels and returns a map of severity levels +func ProcessSeverityLevels(file string) (map[string]Level, error) { + f, err := os.Open(file) + if err != nil { + return nil, err + } + defer f.Close() + + return GetSeverityLevels(f) +} + +// GetSeverityLevels reads severity levels from a reader and returns a map of severity levels +func GetSeverityLevels(source io.Reader) (map[string]Level, error) { + + result := map[string]Level{} + + validIds := utils.StringList(GetAllRuleIds()).ToStringSet() + + scanner := bufio.NewScanner(source) + + lineNum := 0 + for scanner.Scan() { + lineNum++ + line := scanner.Text() + frags := strings.Fields(line) + + if len(frags) != 2 { + return nil, fmt.Errorf("invalid line #%d: %s", lineNum, line) + } + + id := frags[0] + if !validIds.Contains(id) { + return nil, fmt.Errorf("invalid rule id %q on line %d", id, lineNum) + } + + level, err := NewLevel(frags[1]) + if err != nil { + return nil, fmt.Errorf("invalid level %q on line %d", frags[1], lineNum) + } + + result[id] = level + } + + return result, nil +} diff --git a/checker/level_test.go b/checker/level_test.go new file mode 100644 index 00000000..1ba58a54 --- /dev/null +++ b/checker/level_test.go @@ -0,0 +1,66 @@ +package checker_test + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/require" + "github.com/tufin/oasdiff/checker" +) + +func TestStringCond_Info(t *testing.T) { + level := checker.INFO + require.Equal(t, level.PrettyString(), level.StringCond(checker.ColorAlways)) + require.Equal(t, level.String(), level.StringCond(checker.ColorNever)) + require.Equal(t, level.String(), level.StringCond(checker.ColorAuto)) + require.Equal(t, level.String(), level.StringCond(checker.ColorInvalid)) +} + +func TestPrettyString(t *testing.T) { + require.Equal(t, "\x1b[36minfo\x1b[0m", checker.INFO.PrettyString()) + require.Equal(t, "\x1b[35mwarning\x1b[0m", checker.WARN.PrettyString()) + require.Equal(t, "\x1b[31merror\x1b[0m", checker.ERR.PrettyString()) + require.Equal(t, "\x1b[37missue\x1b[0m", checker.Level(4).PrettyString()) +} + +func TestProcessSeverityLevels_InvalidFile(t *testing.T) { + m, err := checker.ProcessSeverityLevels("../data/invalid.txt") + require.Nil(t, m) + require.EqualError(t, err, "open ../data/invalid.txt: no such file or directory") +} + +func TestProcessSeverityLevels_OK(t *testing.T) { + m, err := checker.ProcessSeverityLevels("../data/severity-levels.txt") + require.Equal(t, map[string]checker.Level{"api-security-removed": 2, "request-parameter-enum-value-added": 3}, m) + require.NoError(t, err) +} + +func TestProcessSeverityLevels_WrongFlags(t *testing.T) { + m, err := checker.ProcessSeverityLevels("../data/severity-levels.txt") + require.Equal(t, map[string]checker.Level{"api-security-removed": 2, "request-parameter-enum-value-added": 3}, m) + require.NoError(t, err) +} + +func TestGetSeverityLevels_InvalidLine(t *testing.T) { + m, err := checker.GetSeverityLevels(strings.NewReader("invalid")) + require.Nil(t, m) + require.EqualError(t, err, "invalid line #1: invalid") +} + +func TestGetSeverityLevels_InvalidRuleId(t *testing.T) { + m, err := checker.GetSeverityLevels(strings.NewReader("invalid_id err")) + require.Nil(t, m) + require.EqualError(t, err, "invalid rule id \"invalid_id\" on line 1") +} + +func TestGetSeverityLevels_InvalidLevel(t *testing.T) { + m, err := checker.GetSeverityLevels(strings.NewReader("request-parameter-enum-value-added invalid_level")) + require.Nil(t, m) + require.EqualError(t, err, "invalid level \"invalid_level\" on line 1") +} + +func TestGetSeverityLevels_Duplicate(t *testing.T) { + m, err := checker.GetSeverityLevels(strings.NewReader("request-parameter-enum-value-added info\nrequest-parameter-enum-value-added warn")) + require.Equal(t, map[string]checker.Level{"request-parameter-enum-value-added": checker.WARN}, m) + require.NoError(t, err) +} diff --git a/checker/rules.go b/checker/rules.go index c837e731..b5edad6c 100644 --- a/checker/rules.go +++ b/checker/rules.go @@ -10,16 +10,14 @@ type BackwardCompatibilityRule struct { Id string Level Level Description string - Required bool Handler BackwardCompatibilityCheck `json:"-" yaml:"-"` } -func newBackwardCompatibilityRule(id string, level Level, required bool, handler BackwardCompatibilityCheck) BackwardCompatibilityRule { +func newBackwardCompatibilityRule(id string, level Level, handler BackwardCompatibilityCheck) BackwardCompatibilityRule { return BackwardCompatibilityRule{ Id: id, Level: level, Description: descriptionId(id), - Required: required, Handler: handler, } } @@ -29,381 +27,381 @@ type BackwardCompatibilityRules []BackwardCompatibilityRule func GetAllRules() BackwardCompatibilityRules { return BackwardCompatibilityRules{ // APIAddedCheck - newBackwardCompatibilityRule(EndpointAddedId, INFO, true, APIAddedCheck), + newBackwardCompatibilityRule(EndpointAddedId, INFO, APIAddedCheck), // APIComponentsSecurityUpdatedCheck - newBackwardCompatibilityRule(APIComponentsSecurityRemovedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentsSecurityAddedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentsSecurityComponentOauthUrlUpdatedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentsSecurityTypeUpdatedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentsSecurityOauthTokenUrlUpdatedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentSecurityOauthScopeAddedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentSecurityOauthScopeRemovedId, INFO, true, APIComponentsSecurityUpdatedCheck), - newBackwardCompatibilityRule(APIComponentSecurityOauthScopeUpdatedId, INFO, true, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentsSecurityRemovedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentsSecurityAddedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentsSecurityComponentOauthUrlUpdatedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentsSecurityTypeUpdatedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentsSecurityOauthTokenUrlUpdatedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentSecurityOauthScopeAddedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentSecurityOauthScopeRemovedId, INFO, APIComponentsSecurityUpdatedCheck), + newBackwardCompatibilityRule(APIComponentSecurityOauthScopeUpdatedId, INFO, APIComponentsSecurityUpdatedCheck), // APISecurityUpdatedCheck - newBackwardCompatibilityRule(APISecurityRemovedCheckId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APISecurityAddedCheckId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APISecurityScopeAddedId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APISecurityScopeRemovedId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APIGlobalSecurityRemovedCheckId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APIGlobalSecurityAddedCheckId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APIGlobalSecurityScopeAddedId, INFO, true, APISecurityUpdatedCheck), - newBackwardCompatibilityRule(APIGlobalSecurityScopeRemovedId, INFO, true, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APISecurityRemovedCheckId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APISecurityAddedCheckId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APISecurityScopeAddedId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APISecurityScopeRemovedId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APIGlobalSecurityRemovedCheckId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APIGlobalSecurityAddedCheckId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APIGlobalSecurityScopeAddedId, INFO, APISecurityUpdatedCheck), + newBackwardCompatibilityRule(APIGlobalSecurityScopeRemovedId, INFO, APISecurityUpdatedCheck), // Stability Descreased Check is run as part of CheckBackwardCompatibility - newBackwardCompatibilityRule(APIStabilityDecreasedId, ERR, true, nil), + newBackwardCompatibilityRule(APIStabilityDecreasedId, ERR, nil), // APIDeprecationCheck - newBackwardCompatibilityRule(EndpointReactivatedId, INFO, true, APIDeprecationCheck), - newBackwardCompatibilityRule(APIDeprecatedSunsetParseId, ERR, true, APIDeprecationCheck), - newBackwardCompatibilityRule(APIDeprecatedSunsetMissingId, ERR, true, APIDeprecationCheck), - newBackwardCompatibilityRule(APIInvalidStabilityLevelId, ERR, true, APIDeprecationCheck), - newBackwardCompatibilityRule(APISunsetDateTooSmallId, ERR, true, APIDeprecationCheck), - newBackwardCompatibilityRule(EndpointDeprecatedId, INFO, true, APIDeprecationCheck), + newBackwardCompatibilityRule(EndpointReactivatedId, INFO, APIDeprecationCheck), + newBackwardCompatibilityRule(APIDeprecatedSunsetParseId, ERR, APIDeprecationCheck), + newBackwardCompatibilityRule(APIDeprecatedSunsetMissingId, ERR, APIDeprecationCheck), + newBackwardCompatibilityRule(APIInvalidStabilityLevelId, ERR, APIDeprecationCheck), + newBackwardCompatibilityRule(APISunsetDateTooSmallId, ERR, APIDeprecationCheck), + newBackwardCompatibilityRule(EndpointDeprecatedId, INFO, APIDeprecationCheck), // APIRemovedCheck - newBackwardCompatibilityRule(APIPathRemovedWithoutDeprecationId, ERR, true, APIRemovedCheck), - newBackwardCompatibilityRule(APIPathSunsetParseId, ERR, true, APIRemovedCheck), - newBackwardCompatibilityRule(APIPathRemovedBeforeSunsetId, ERR, true, APIRemovedCheck), - newBackwardCompatibilityRule(APIRemovedWithoutDeprecationId, ERR, true, APIRemovedCheck), - newBackwardCompatibilityRule(APIRemovedBeforeSunsetId, ERR, true, APIRemovedCheck), + newBackwardCompatibilityRule(APIPathRemovedWithoutDeprecationId, ERR, APIRemovedCheck), + newBackwardCompatibilityRule(APIPathSunsetParseId, ERR, APIRemovedCheck), + newBackwardCompatibilityRule(APIPathRemovedBeforeSunsetId, ERR, APIRemovedCheck), + newBackwardCompatibilityRule(APIRemovedWithoutDeprecationId, ERR, APIRemovedCheck), + newBackwardCompatibilityRule(APIRemovedBeforeSunsetId, ERR, APIRemovedCheck), // APISunsetChangedCheck - newBackwardCompatibilityRule(APISunsetDeletedId, ERR, true, APISunsetChangedCheck), - newBackwardCompatibilityRule(APISunsetDateChangedTooSmallId, ERR, true, APISunsetChangedCheck), + newBackwardCompatibilityRule(APISunsetDeletedId, ERR, APISunsetChangedCheck), + newBackwardCompatibilityRule(APISunsetDateChangedTooSmallId, ERR, APISunsetChangedCheck), // AddedRequiredRequestBodyCheck - newBackwardCompatibilityRule(AddedRequiredRequestBodyId, ERR, true, AddedRequestBodyCheck), - newBackwardCompatibilityRule(AddedOptionalRequestBodyId, INFO, true, AddedRequestBodyCheck), + newBackwardCompatibilityRule(AddedRequiredRequestBodyId, ERR, AddedRequestBodyCheck), + newBackwardCompatibilityRule(AddedOptionalRequestBodyId, INFO, AddedRequestBodyCheck), // NewRequestNonPathDefaultParameterCheck - newBackwardCompatibilityRule(NewRequiredRequestDefaultParameterToExistingPathId, ERR, true, NewRequestNonPathDefaultParameterCheck), - newBackwardCompatibilityRule(NewOptionalRequestDefaultParameterToExistingPathId, INFO, true, NewRequestNonPathDefaultParameterCheck), + newBackwardCompatibilityRule(NewRequiredRequestDefaultParameterToExistingPathId, ERR, NewRequestNonPathDefaultParameterCheck), + newBackwardCompatibilityRule(NewOptionalRequestDefaultParameterToExistingPathId, INFO, NewRequestNonPathDefaultParameterCheck), // NewRequestNonPathParameterCheck - newBackwardCompatibilityRule(NewRequiredRequestParameterId, ERR, true, NewRequestNonPathParameterCheck), - newBackwardCompatibilityRule(NewOptionalRequestParameterId, INFO, true, NewRequestNonPathParameterCheck), + newBackwardCompatibilityRule(NewRequiredRequestParameterId, ERR, NewRequestNonPathParameterCheck), + newBackwardCompatibilityRule(NewOptionalRequestParameterId, INFO, NewRequestNonPathParameterCheck), // NewRequestPathParameterCheck - newBackwardCompatibilityRule(NewRequestPathParameterId, ERR, true, NewRequestPathParameterCheck), + newBackwardCompatibilityRule(NewRequestPathParameterId, ERR, NewRequestPathParameterCheck), // NewRequiredRequestHeaderPropertyCheck - newBackwardCompatibilityRule(NewRequiredRequestHeaderPropertyId, ERR, true, NewRequiredRequestHeaderPropertyCheck), + newBackwardCompatibilityRule(NewRequiredRequestHeaderPropertyId, ERR, NewRequiredRequestHeaderPropertyCheck), // RequestBodyBecameEnumCheck - newBackwardCompatibilityRule(RequestBodyBecameEnumId, ERR, true, RequestBodyBecameEnumCheck), + newBackwardCompatibilityRule(RequestBodyBecameEnumId, ERR, RequestBodyBecameEnumCheck), // RequestBodyMediaTypeChangedCheck - newBackwardCompatibilityRule(RequestBodyMediaTypeAddedId, INFO, true, RequestBodyMediaTypeChangedCheck), - newBackwardCompatibilityRule(RequestBodyMediaTypeRemovedId, ERR, true, RequestBodyMediaTypeChangedCheck), + newBackwardCompatibilityRule(RequestBodyMediaTypeAddedId, INFO, RequestBodyMediaTypeChangedCheck), + newBackwardCompatibilityRule(RequestBodyMediaTypeRemovedId, ERR, RequestBodyMediaTypeChangedCheck), // RequestBodyRequiredUpdatedCheck - newBackwardCompatibilityRule(RequestBodyBecameOptionalId, INFO, true, RequestBodyRequiredUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyBecameRequiredId, ERR, true, RequestBodyRequiredUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyBecameOptionalId, INFO, RequestBodyRequiredUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyBecameRequiredId, ERR, RequestBodyRequiredUpdatedCheck), // RequestDiscriminatorUpdatedCheck - newBackwardCompatibilityRule(RequestBodyDiscriminatorAddedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyDiscriminatorRemovedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyDiscriminatorPropertyNameChangedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingAddedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingDeletedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingChangedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorAddedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorRemovedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorPropertyNameChangedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingAddedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingDeletedId, INFO, true, RequestDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingChangedId, INFO, true, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorAddedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorRemovedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorPropertyNameChangedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingAddedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingDeletedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyDiscriminatorMappingChangedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorAddedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorRemovedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorPropertyNameChangedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingAddedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingDeletedId, INFO, RequestDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyDiscriminatorMappingChangedId, INFO, RequestDiscriminatorUpdatedCheck), // RequestHeaderPropertyBecameEnumCheck - newBackwardCompatibilityRule(RequestHeaderPropertyBecameEnumId, ERR, true, RequestHeaderPropertyBecameEnumCheck), + newBackwardCompatibilityRule(RequestHeaderPropertyBecameEnumId, ERR, RequestHeaderPropertyBecameEnumCheck), // RequestHeaderPropertyBecameRequiredCheck - newBackwardCompatibilityRule(RequestHeaderPropertyBecameRequiredId, ERR, true, RequestHeaderPropertyBecameRequiredCheck), + newBackwardCompatibilityRule(RequestHeaderPropertyBecameRequiredId, ERR, RequestHeaderPropertyBecameRequiredCheck), // RequestParameterBecameEnumCheck - newBackwardCompatibilityRule(RequestParameterBecameEnumId, ERR, true, RequestParameterBecameEnumCheck), + newBackwardCompatibilityRule(RequestParameterBecameEnumId, ERR, RequestParameterBecameEnumCheck), // RequestParameterDefaultValueChangedCheck - newBackwardCompatibilityRule(RequestParameterDefaultValueChangedId, ERR, true, RequestParameterDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestParameterDefaultValueAddedId, ERR, true, RequestParameterDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestParameterDefaultValueRemovedId, ERR, true, RequestParameterDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestParameterDefaultValueChangedId, ERR, RequestParameterDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestParameterDefaultValueAddedId, ERR, RequestParameterDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestParameterDefaultValueRemovedId, ERR, RequestParameterDefaultValueChangedCheck), // RequestParameterEnumValueUpdatedCheck - newBackwardCompatibilityRule(RequestParameterEnumValueAddedId, INFO, true, RequestParameterEnumValueUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterEnumValueRemovedId, ERR, true, RequestParameterEnumValueUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterEnumValueAddedId, INFO, RequestParameterEnumValueUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterEnumValueRemovedId, ERR, RequestParameterEnumValueUpdatedCheck), // RequestParameterMaxItemsUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMaxItemsIncreasedId, INFO, true, RequestParameterMaxItemsUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMaxItemsDecreasedId, ERR, true, RequestParameterMaxItemsUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxItemsIncreasedId, INFO, RequestParameterMaxItemsUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxItemsDecreasedId, ERR, RequestParameterMaxItemsUpdatedCheck), // RequestParameterMaxLengthSetCheck - newBackwardCompatibilityRule(RequestParameterMaxLengthSetId, WARN, true, RequestParameterMaxLengthSetCheck), + newBackwardCompatibilityRule(RequestParameterMaxLengthSetId, WARN, RequestParameterMaxLengthSetCheck), // RequestParameterMaxLengthUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMaxLengthIncreasedId, INFO, true, RequestParameterMaxLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMaxLengthDecreasedId, ERR, true, RequestParameterMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxLengthIncreasedId, INFO, RequestParameterMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxLengthDecreasedId, ERR, RequestParameterMaxLengthUpdatedCheck), // RequestParameterMaxSetCheck - newBackwardCompatibilityRule(RequestParameterMaxSetId, WARN, true, RequestParameterMaxSetCheck), + newBackwardCompatibilityRule(RequestParameterMaxSetId, WARN, RequestParameterMaxSetCheck), // RequestParameterMaxUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMaxIncreasedId, INFO, true, RequestParameterMaxUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMaxDecreasedId, ERR, true, RequestParameterMaxUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxIncreasedId, INFO, RequestParameterMaxUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMaxDecreasedId, ERR, RequestParameterMaxUpdatedCheck), // RequestParameterMinItemsSetCheck - newBackwardCompatibilityRule(RequestParameterMinItemsSetId, WARN, true, RequestParameterMinItemsSetCheck), + newBackwardCompatibilityRule(RequestParameterMinItemsSetId, WARN, RequestParameterMinItemsSetCheck), // RequestParameterMinItemsUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMinItemsIncreasedId, ERR, true, RequestParameterMinItemsUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMinItemsDecreasedId, INFO, true, RequestParameterMinItemsUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinItemsIncreasedId, ERR, RequestParameterMinItemsUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinItemsDecreasedId, INFO, RequestParameterMinItemsUpdatedCheck), // RequestParameterMinLengthUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMinLengthIncreasedId, ERR, true, RequestParameterMinLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMinLengthDecreasedId, INFO, true, RequestParameterMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinLengthIncreasedId, ERR, RequestParameterMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinLengthDecreasedId, INFO, RequestParameterMinLengthUpdatedCheck), // RequestParameterMinSetCheck - newBackwardCompatibilityRule(RequestParameterMinSetId, WARN, true, RequestParameterMinSetCheck), + newBackwardCompatibilityRule(RequestParameterMinSetId, WARN, RequestParameterMinSetCheck), // RequestParameterMinUpdatedCheck - newBackwardCompatibilityRule(RequestParameterMinIncreasedId, ERR, true, RequestParameterMinUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterMinDecreasedId, INFO, true, RequestParameterMinUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinIncreasedId, ERR, RequestParameterMinUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterMinDecreasedId, INFO, RequestParameterMinUpdatedCheck), // RequestParameterPatternAddedOrChangedCheck - newBackwardCompatibilityRule(RequestParameterPatternAddedId, WARN, true, RequestParameterPatternAddedOrChangedCheck), - newBackwardCompatibilityRule(RequestParameterPatternRemovedId, INFO, true, RequestParameterPatternAddedOrChangedCheck), - newBackwardCompatibilityRule(RequestParameterPatternChangedId, WARN, true, RequestParameterPatternAddedOrChangedCheck), - newBackwardCompatibilityRule(RequestParameterPatternGeneralizedId, INFO, true, RequestParameterPatternAddedOrChangedCheck), + newBackwardCompatibilityRule(RequestParameterPatternAddedId, WARN, RequestParameterPatternAddedOrChangedCheck), + newBackwardCompatibilityRule(RequestParameterPatternRemovedId, INFO, RequestParameterPatternAddedOrChangedCheck), + newBackwardCompatibilityRule(RequestParameterPatternChangedId, WARN, RequestParameterPatternAddedOrChangedCheck), + newBackwardCompatibilityRule(RequestParameterPatternGeneralizedId, INFO, RequestParameterPatternAddedOrChangedCheck), // RequestParameterRemovedCheck - newBackwardCompatibilityRule(RequestParameterRemovedId, WARN, true, RequestParameterRemovedCheck), + newBackwardCompatibilityRule(RequestParameterRemovedId, WARN, RequestParameterRemovedCheck), // RequestParameterRequiredValueUpdatedCheck - newBackwardCompatibilityRule(RequestParameterBecomeRequiredId, ERR, true, RequestParameterRequiredValueUpdatedCheck), - newBackwardCompatibilityRule(RequestParameterBecomeOptionalId, INFO, true, RequestParameterRequiredValueUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterBecomeRequiredId, ERR, RequestParameterRequiredValueUpdatedCheck), + newBackwardCompatibilityRule(RequestParameterBecomeOptionalId, INFO, RequestParameterRequiredValueUpdatedCheck), // RequestParameterTypeChangedCheck - newBackwardCompatibilityRule(RequestParameterTypeChangedId, ERR, true, RequestParameterTypeChangedCheck), - newBackwardCompatibilityRule(RequestParameterTypeGeneralizedId, INFO, true, RequestParameterTypeChangedCheck), - newBackwardCompatibilityRule(RequestParameterPropertyTypeChangedId, WARN, true, RequestParameterTypeChangedCheck), - newBackwardCompatibilityRule(RequestParameterPropertyTypeGeneralizedId, INFO, true, RequestParameterTypeChangedCheck), - newBackwardCompatibilityRule(RequestParameterPropertyTypeSpecializedId, ERR, true, RequestParameterTypeChangedCheck), + newBackwardCompatibilityRule(RequestParameterTypeChangedId, ERR, RequestParameterTypeChangedCheck), + newBackwardCompatibilityRule(RequestParameterTypeGeneralizedId, INFO, RequestParameterTypeChangedCheck), + newBackwardCompatibilityRule(RequestParameterPropertyTypeChangedId, WARN, RequestParameterTypeChangedCheck), + newBackwardCompatibilityRule(RequestParameterPropertyTypeGeneralizedId, INFO, RequestParameterTypeChangedCheck), + newBackwardCompatibilityRule(RequestParameterPropertyTypeSpecializedId, ERR, RequestParameterTypeChangedCheck), // RequestParameterXExtensibleEnumValueRemovedCheck - newBackwardCompatibilityRule(RequestParameterXExtensibleEnumValueRemovedId, ERR, true, RequestParameterXExtensibleEnumValueRemovedCheck), + newBackwardCompatibilityRule(RequestParameterXExtensibleEnumValueRemovedId, ERR, RequestParameterXExtensibleEnumValueRemovedCheck), // RequestPropertyAllOfUpdatedCheck - newBackwardCompatibilityRule(RequestBodyAllOfAddedId, ERR, true, RequestPropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyAllOfRemovedId, WARN, true, RequestPropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyAllOfAddedId, ERR, true, RequestPropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyAllOfRemovedId, WARN, true, RequestPropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyAllOfAddedId, ERR, RequestPropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyAllOfRemovedId, WARN, RequestPropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyAllOfAddedId, ERR, RequestPropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyAllOfRemovedId, WARN, RequestPropertyAllOfUpdatedCheck), // RequestPropertyAnyOfUpdatedCheck - newBackwardCompatibilityRule(RequestBodyAnyOfAddedId, INFO, true, RequestPropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyAnyOfRemovedId, ERR, true, RequestPropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyAnyOfAddedId, INFO, true, RequestPropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyAnyOfRemovedId, ERR, true, RequestPropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyAnyOfAddedId, INFO, RequestPropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyAnyOfRemovedId, ERR, RequestPropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyAnyOfAddedId, INFO, RequestPropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyAnyOfRemovedId, ERR, RequestPropertyAnyOfUpdatedCheck), // RequestPropertyBecameEnumCheck - newBackwardCompatibilityRule(RequestPropertyBecameEnumId, ERR, true, RequestPropertyBecameEnumCheck), + newBackwardCompatibilityRule(RequestPropertyBecameEnumId, ERR, RequestPropertyBecameEnumCheck), // RequestPropertyBecameNotNullableCheck - newBackwardCompatibilityRule(RequestBodyBecomeNotNullableId, ERR, true, RequestPropertyBecameNotNullableCheck), - newBackwardCompatibilityRule(RequestBodyBecomeNullableId, INFO, true, RequestPropertyBecameNotNullableCheck), - newBackwardCompatibilityRule(RequestPropertyBecomeNotNullableId, ERR, true, RequestPropertyBecameNotNullableCheck), - newBackwardCompatibilityRule(RequestPropertyBecomeNullableId, INFO, true, RequestPropertyBecameNotNullableCheck), + newBackwardCompatibilityRule(RequestBodyBecomeNotNullableId, ERR, RequestPropertyBecameNotNullableCheck), + newBackwardCompatibilityRule(RequestBodyBecomeNullableId, INFO, RequestPropertyBecameNotNullableCheck), + newBackwardCompatibilityRule(RequestPropertyBecomeNotNullableId, ERR, RequestPropertyBecameNotNullableCheck), + newBackwardCompatibilityRule(RequestPropertyBecomeNullableId, INFO, RequestPropertyBecameNotNullableCheck), // RequestPropertyDefaultValueChangedCheck - newBackwardCompatibilityRule(RequestBodyDefaultValueAddedId, INFO, true, RequestPropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestBodyDefaultValueRemovedId, INFO, true, RequestPropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestBodyDefaultValueChangedId, INFO, true, RequestPropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestPropertyDefaultValueAddedId, INFO, true, RequestPropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestPropertyDefaultValueRemovedId, INFO, true, RequestPropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(RequestPropertyDefaultValueChangedId, INFO, true, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestBodyDefaultValueAddedId, INFO, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestBodyDefaultValueRemovedId, INFO, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestBodyDefaultValueChangedId, INFO, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestPropertyDefaultValueAddedId, INFO, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestPropertyDefaultValueRemovedId, INFO, RequestPropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(RequestPropertyDefaultValueChangedId, INFO, RequestPropertyDefaultValueChangedCheck), // RequestPropertyEnumValueUpdatedCheck - newBackwardCompatibilityRule(RequestPropertyEnumValueRemovedId, ERR, true, RequestPropertyEnumValueUpdatedCheck), - newBackwardCompatibilityRule(RequestReadOnlyPropertyEnumValueRemovedId, INFO, true, RequestPropertyEnumValueUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyEnumValueAddedId, INFO, true, RequestPropertyEnumValueUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyEnumValueRemovedId, ERR, RequestPropertyEnumValueUpdatedCheck), + newBackwardCompatibilityRule(RequestReadOnlyPropertyEnumValueRemovedId, INFO, RequestPropertyEnumValueUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyEnumValueAddedId, INFO, RequestPropertyEnumValueUpdatedCheck), // RequestPropertyMaxDecreasedCheck - newBackwardCompatibilityRule(RequestBodyMaxDecreasedId, ERR, true, RequestPropertyMaxDecreasedCheck), - newBackwardCompatibilityRule(RequestBodyMaxIncreasedId, INFO, true, RequestPropertyMaxDecreasedCheck), - newBackwardCompatibilityRule(RequestPropertyMaxDecreasedId, ERR, true, RequestPropertyMaxDecreasedCheck), - newBackwardCompatibilityRule(RequestReadOnlyPropertyMaxDecreasedId, INFO, true, RequestPropertyMaxDecreasedCheck), - newBackwardCompatibilityRule(RequestPropertyMaxIncreasedId, INFO, true, RequestPropertyMaxDecreasedCheck), + newBackwardCompatibilityRule(RequestBodyMaxDecreasedId, ERR, RequestPropertyMaxDecreasedCheck), + newBackwardCompatibilityRule(RequestBodyMaxIncreasedId, INFO, RequestPropertyMaxDecreasedCheck), + newBackwardCompatibilityRule(RequestPropertyMaxDecreasedId, ERR, RequestPropertyMaxDecreasedCheck), + newBackwardCompatibilityRule(RequestReadOnlyPropertyMaxDecreasedId, INFO, RequestPropertyMaxDecreasedCheck), + newBackwardCompatibilityRule(RequestPropertyMaxIncreasedId, INFO, RequestPropertyMaxDecreasedCheck), // RequestPropertyMaxLengthSetCheck - newBackwardCompatibilityRule(RequestBodyMaxLengthSetId, WARN, true, RequestPropertyMaxLengthSetCheck), - newBackwardCompatibilityRule(RequestPropertyMaxLengthSetId, WARN, true, RequestPropertyMaxLengthSetCheck), + newBackwardCompatibilityRule(RequestBodyMaxLengthSetId, WARN, RequestPropertyMaxLengthSetCheck), + newBackwardCompatibilityRule(RequestPropertyMaxLengthSetId, WARN, RequestPropertyMaxLengthSetCheck), // RequestPropertyMaxLengthUpdatedCheck - newBackwardCompatibilityRule(RequestBodyMaxLengthDecreasedId, ERR, true, RequestPropertyMaxLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyMaxLengthIncreasedId, INFO, true, RequestPropertyMaxLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyMaxLengthDecreasedId, ERR, true, RequestPropertyMaxLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestReadOnlyPropertyMaxLengthDecreasedId, INFO, true, RequestPropertyMaxLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyMaxLengthIncreasedId, INFO, true, RequestPropertyMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyMaxLengthDecreasedId, ERR, RequestPropertyMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyMaxLengthIncreasedId, INFO, RequestPropertyMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyMaxLengthDecreasedId, ERR, RequestPropertyMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestReadOnlyPropertyMaxLengthDecreasedId, INFO, RequestPropertyMaxLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyMaxLengthIncreasedId, INFO, RequestPropertyMaxLengthUpdatedCheck), // RequestPropertyMaxSetCheck - newBackwardCompatibilityRule(RequestBodyMaxSetId, WARN, true, RequestPropertyMaxSetCheck), - newBackwardCompatibilityRule(RequestPropertyMaxSetId, WARN, true, RequestPropertyMaxSetCheck), + newBackwardCompatibilityRule(RequestBodyMaxSetId, WARN, RequestPropertyMaxSetCheck), + newBackwardCompatibilityRule(RequestPropertyMaxSetId, WARN, RequestPropertyMaxSetCheck), // RequestPropertyMinIncreasedCheck - newBackwardCompatibilityRule(RequestBodyMinIncreasedId, ERR, true, RequestPropertyMinIncreasedCheck), - newBackwardCompatibilityRule(RequestBodyMinDecreasedId, INFO, true, RequestPropertyMinIncreasedCheck), - newBackwardCompatibilityRule(RequestPropertyMinIncreasedId, ERR, true, RequestPropertyMinIncreasedCheck), - newBackwardCompatibilityRule(RequestReadOnlyPropertyMinIncreasedId, INFO, true, RequestPropertyMinIncreasedCheck), - newBackwardCompatibilityRule(RequestPropertyMinDecreasedId, INFO, true, RequestPropertyMinIncreasedCheck), + newBackwardCompatibilityRule(RequestBodyMinIncreasedId, ERR, RequestPropertyMinIncreasedCheck), + newBackwardCompatibilityRule(RequestBodyMinDecreasedId, INFO, RequestPropertyMinIncreasedCheck), + newBackwardCompatibilityRule(RequestPropertyMinIncreasedId, ERR, RequestPropertyMinIncreasedCheck), + newBackwardCompatibilityRule(RequestReadOnlyPropertyMinIncreasedId, INFO, RequestPropertyMinIncreasedCheck), + newBackwardCompatibilityRule(RequestPropertyMinDecreasedId, INFO, RequestPropertyMinIncreasedCheck), // RequestPropertyMinItemsIncreasedCheck - newBackwardCompatibilityRule(RequestBodyMinItemsIncreasedId, ERR, true, RequestPropertyMinItemsIncreasedCheck), - newBackwardCompatibilityRule(RequestPropertyMinItemsIncreasedId, ERR, true, RequestPropertyMinItemsIncreasedCheck), + newBackwardCompatibilityRule(RequestBodyMinItemsIncreasedId, ERR, RequestPropertyMinItemsIncreasedCheck), + newBackwardCompatibilityRule(RequestPropertyMinItemsIncreasedId, ERR, RequestPropertyMinItemsIncreasedCheck), // RequestPropertyMinItemsSetCheck - newBackwardCompatibilityRule(RequestBodyMinItemsSetId, WARN, true, RequestPropertyMinItemsSetCheck), - newBackwardCompatibilityRule(RequestPropertyMinItemsSetId, WARN, true, RequestPropertyMinItemsSetCheck), + newBackwardCompatibilityRule(RequestBodyMinItemsSetId, WARN, RequestPropertyMinItemsSetCheck), + newBackwardCompatibilityRule(RequestPropertyMinItemsSetId, WARN, RequestPropertyMinItemsSetCheck), // RequestPropertyMinLengthUpdatedCheck - newBackwardCompatibilityRule(RequestBodyMinLengthIncreasedId, ERR, true, RequestPropertyMinLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyMinLengthDecreasedId, INFO, true, RequestPropertyMinLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyMinLengthIncreasedId, ERR, true, RequestPropertyMinLengthUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyMinLengthDecreasedId, INFO, true, RequestPropertyMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyMinLengthIncreasedId, ERR, RequestPropertyMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyMinLengthDecreasedId, INFO, RequestPropertyMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyMinLengthIncreasedId, ERR, RequestPropertyMinLengthUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyMinLengthDecreasedId, INFO, RequestPropertyMinLengthUpdatedCheck), // RequestPropertyMinSetCheck - newBackwardCompatibilityRule(RequestBodyMinSetId, WARN, true, RequestPropertyMinSetCheck), - newBackwardCompatibilityRule(RequestPropertyMinSetId, WARN, true, RequestPropertyMinSetCheck), + newBackwardCompatibilityRule(RequestBodyMinSetId, WARN, RequestPropertyMinSetCheck), + newBackwardCompatibilityRule(RequestPropertyMinSetId, WARN, RequestPropertyMinSetCheck), // RequestPropertyOneOfUpdatedCheck - newBackwardCompatibilityRule(RequestBodyOneOfAddedId, INFO, true, RequestPropertyOneOfUpdatedCheck), - newBackwardCompatibilityRule(RequestBodyOneOfRemovedId, ERR, true, RequestPropertyOneOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyOneOfAddedId, INFO, true, RequestPropertyOneOfUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyOneOfRemovedId, ERR, true, RequestPropertyOneOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyOneOfAddedId, INFO, RequestPropertyOneOfUpdatedCheck), + newBackwardCompatibilityRule(RequestBodyOneOfRemovedId, ERR, RequestPropertyOneOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyOneOfAddedId, INFO, RequestPropertyOneOfUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyOneOfRemovedId, ERR, RequestPropertyOneOfUpdatedCheck), // RequestPropertyPatternUpdatedCheck - newBackwardCompatibilityRule(RequestPropertyPatternRemovedId, INFO, true, RequestPropertyPatternUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyPatternAddedId, WARN, true, RequestPropertyPatternUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyPatternChangedId, WARN, true, RequestPropertyPatternUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyPatternGeneralizedId, INFO, true, RequestPropertyPatternUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyPatternRemovedId, INFO, RequestPropertyPatternUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyPatternAddedId, WARN, RequestPropertyPatternUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyPatternChangedId, WARN, RequestPropertyPatternUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyPatternGeneralizedId, INFO, RequestPropertyPatternUpdatedCheck), // RequestPropertyRequiredUpdatedCheck - newBackwardCompatibilityRule(RequestPropertyBecameRequiredId, ERR, true, RequestPropertyRequiredUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyBecameRequiredWithDefaultId, INFO, true, RequestPropertyRequiredUpdatedCheck), - newBackwardCompatibilityRule(RequestPropertyBecameOptionalId, INFO, true, RequestPropertyRequiredUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyBecameRequiredId, ERR, RequestPropertyRequiredUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyBecameRequiredWithDefaultId, INFO, RequestPropertyRequiredUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyBecameOptionalId, INFO, RequestPropertyRequiredUpdatedCheck), // RequestPropertyTypeChangedCheck - newBackwardCompatibilityRule(RequestBodyTypeGeneralizedId, INFO, true, RequestPropertyTypeChangedCheck), - newBackwardCompatibilityRule(RequestBodyTypeChangedId, ERR, true, RequestPropertyTypeChangedCheck), - newBackwardCompatibilityRule(RequestPropertyTypeGeneralizedId, INFO, true, RequestPropertyTypeChangedCheck), - newBackwardCompatibilityRule(RequestPropertyTypeChangedId, ERR, true, RequestPropertyTypeChangedCheck), + newBackwardCompatibilityRule(RequestBodyTypeGeneralizedId, INFO, RequestPropertyTypeChangedCheck), + newBackwardCompatibilityRule(RequestBodyTypeChangedId, ERR, RequestPropertyTypeChangedCheck), + newBackwardCompatibilityRule(RequestPropertyTypeGeneralizedId, INFO, RequestPropertyTypeChangedCheck), + newBackwardCompatibilityRule(RequestPropertyTypeChangedId, ERR, RequestPropertyTypeChangedCheck), // RequestPropertyUpdatedCheck - newBackwardCompatibilityRule(RequestPropertyRemovedId, WARN, true, RequestPropertyUpdatedCheck), - newBackwardCompatibilityRule(NewRequiredRequestPropertyId, ERR, true, RequestPropertyUpdatedCheck), - newBackwardCompatibilityRule(NewRequiredRequestPropertyWithDefaultId, INFO, true, RequestPropertyUpdatedCheck), - newBackwardCompatibilityRule(NewOptionalRequestPropertyId, INFO, true, RequestPropertyUpdatedCheck), + newBackwardCompatibilityRule(RequestPropertyRemovedId, WARN, RequestPropertyUpdatedCheck), + newBackwardCompatibilityRule(NewRequiredRequestPropertyId, ERR, RequestPropertyUpdatedCheck), + newBackwardCompatibilityRule(NewRequiredRequestPropertyWithDefaultId, INFO, RequestPropertyUpdatedCheck), + newBackwardCompatibilityRule(NewOptionalRequestPropertyId, INFO, RequestPropertyUpdatedCheck), // RequestPropertyWriteOnlyReadOnlyCheck - newBackwardCompatibilityRule(RequestOptionalPropertyBecameNonWriteOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestOptionalPropertyBecameWriteOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestOptionalPropertyBecameReadOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestOptionalPropertyBecameNonReadOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestRequiredPropertyBecameNonWriteOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestRequiredPropertyBecameWriteOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestRequiredPropertyBecameReadOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(RequestRequiredPropertyBecameNonReadOnlyCheckId, INFO, true, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestOptionalPropertyBecameNonWriteOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestOptionalPropertyBecameWriteOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestOptionalPropertyBecameReadOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestOptionalPropertyBecameNonReadOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestRequiredPropertyBecameNonWriteOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestRequiredPropertyBecameWriteOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestRequiredPropertyBecameReadOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(RequestRequiredPropertyBecameNonReadOnlyCheckId, INFO, RequestPropertyWriteOnlyReadOnlyCheck), // RequestPropertyXExtensibleEnumValueRemovedCheck - newBackwardCompatibilityRule(RequestPropertyXExtensibleEnumValueRemovedId, ERR, true, RequestPropertyXExtensibleEnumValueRemovedCheck), + newBackwardCompatibilityRule(RequestPropertyXExtensibleEnumValueRemovedId, ERR, RequestPropertyXExtensibleEnumValueRemovedCheck), // ResponseDiscriminatorUpdatedCheck - newBackwardCompatibilityRule(ResponseBodyDiscriminatorAddedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyDiscriminatorRemovedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyDiscriminatorPropertyNameChangedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingAddedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingDeletedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingChangedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorAddedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorRemovedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorPropertyNameChangedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingAddedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingDeletedId, INFO, true, ResponseDiscriminatorUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingChangedId, INFO, true, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorAddedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorRemovedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorPropertyNameChangedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingAddedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingDeletedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyDiscriminatorMappingChangedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorAddedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorRemovedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorPropertyNameChangedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingAddedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingDeletedId, INFO, ResponseDiscriminatorUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyDiscriminatorMappingChangedId, INFO, ResponseDiscriminatorUpdatedCheck), // ResponseHeaderBecameOptionalCheck - newBackwardCompatibilityRule(ResponseHeaderBecameOptionalId, ERR, true, ResponseHeaderBecameOptionalCheck), + newBackwardCompatibilityRule(ResponseHeaderBecameOptionalId, ERR, ResponseHeaderBecameOptionalCheck), // ResponseHeaderRemovedCheck - newBackwardCompatibilityRule(RequiredResponseHeaderRemovedId, ERR, true, ResponseHeaderRemovedCheck), - newBackwardCompatibilityRule(OptionalResponseHeaderRemovedId, WARN, true, ResponseHeaderRemovedCheck), + newBackwardCompatibilityRule(RequiredResponseHeaderRemovedId, ERR, ResponseHeaderRemovedCheck), + newBackwardCompatibilityRule(OptionalResponseHeaderRemovedId, WARN, ResponseHeaderRemovedCheck), // ResponseMediaTypeUpdatedCheck - newBackwardCompatibilityRule(ResponseMediaTypeRemovedId, ERR, true, ResponseMediaTypeUpdatedCheck), - newBackwardCompatibilityRule(ResponseMediaTypeAddedId, INFO, true, ResponseMediaTypeUpdatedCheck), + newBackwardCompatibilityRule(ResponseMediaTypeRemovedId, ERR, ResponseMediaTypeUpdatedCheck), + newBackwardCompatibilityRule(ResponseMediaTypeAddedId, INFO, ResponseMediaTypeUpdatedCheck), // ResponseOptionalPropertyUpdatedCheck - newBackwardCompatibilityRule(ResponseOptionalPropertyRemovedId, WARN, true, ResponseOptionalPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseOptionalWriteOnlyPropertyRemovedId, INFO, true, ResponseOptionalPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseOptionalPropertyAddedId, INFO, true, ResponseOptionalPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseOptionalWriteOnlyPropertyAddedId, INFO, true, ResponseOptionalPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyRemovedId, WARN, ResponseOptionalPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseOptionalWriteOnlyPropertyRemovedId, INFO, ResponseOptionalPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyAddedId, INFO, ResponseOptionalPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseOptionalWriteOnlyPropertyAddedId, INFO, ResponseOptionalPropertyUpdatedCheck), // ResponseOptionalPropertyWriteOnlyReadOnlyCheck - newBackwardCompatibilityRule(ResponseOptionalPropertyBecameNonWriteOnlyId, INFO, true, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseOptionalPropertyBecameWriteOnlyId, INFO, true, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseOptionalPropertyBecameReadOnlyId, INFO, true, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseOptionalPropertyBecameNonReadOnlyId, INFO, true, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyBecameNonWriteOnlyId, INFO, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyBecameWriteOnlyId, INFO, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyBecameReadOnlyId, INFO, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseOptionalPropertyBecameNonReadOnlyId, INFO, ResponseOptionalPropertyWriteOnlyReadOnlyCheck), // ResponsePatternAddedOrChangedCheck - newBackwardCompatibilityRule(ResponsePropertyPatternAddedId, INFO, true, ResponsePatternAddedOrChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyPatternChangedId, INFO, true, ResponsePatternAddedOrChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyPatternRemovedId, INFO, true, ResponsePatternAddedOrChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyPatternAddedId, INFO, ResponsePatternAddedOrChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyPatternChangedId, INFO, ResponsePatternAddedOrChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyPatternRemovedId, INFO, ResponsePatternAddedOrChangedCheck), // ResponsePropertyAllOfUpdatedCheck - newBackwardCompatibilityRule(ResponseBodyAllOfAddedId, INFO, true, ResponsePropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyAllOfRemovedId, INFO, true, ResponsePropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyAllOfAddedId, INFO, true, ResponsePropertyAllOfUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyAllOfRemovedId, INFO, true, ResponsePropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyAllOfAddedId, INFO, ResponsePropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyAllOfRemovedId, INFO, ResponsePropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyAllOfAddedId, INFO, ResponsePropertyAllOfUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyAllOfRemovedId, INFO, ResponsePropertyAllOfUpdatedCheck), // ResponsePropertyAnyOfUpdatedCheck - newBackwardCompatibilityRule(ResponseBodyAnyOfAddedId, INFO, true, ResponsePropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(ResponseBodyAnyOfRemovedId, INFO, true, ResponsePropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyAnyOfAddedId, INFO, true, ResponsePropertyAnyOfUpdatedCheck), - newBackwardCompatibilityRule(ResponsePropertyAnyOfRemovedId, INFO, true, ResponsePropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyAnyOfAddedId, INFO, ResponsePropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(ResponseBodyAnyOfRemovedId, INFO, ResponsePropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyAnyOfAddedId, INFO, ResponsePropertyAnyOfUpdatedCheck), + newBackwardCompatibilityRule(ResponsePropertyAnyOfRemovedId, INFO, ResponsePropertyAnyOfUpdatedCheck), // ResponsePropertyBecameNullableCheck - newBackwardCompatibilityRule(ResponsePropertyBecameNullableId, ERR, true, ResponsePropertyBecameNullableCheck), - newBackwardCompatibilityRule(ResponseBodyBecameNullableId, ERR, true, ResponsePropertyBecameNullableCheck), + newBackwardCompatibilityRule(ResponsePropertyBecameNullableId, ERR, ResponsePropertyBecameNullableCheck), + newBackwardCompatibilityRule(ResponseBodyBecameNullableId, ERR, ResponsePropertyBecameNullableCheck), // ResponsePropertyBecameOptionalCheck - newBackwardCompatibilityRule(ResponsePropertyBecameOptionalId, ERR, true, ResponsePropertyBecameOptionalCheck), - newBackwardCompatibilityRule(ResponseWriteOnlyPropertyBecameOptionalId, INFO, true, ResponsePropertyBecameOptionalCheck), + newBackwardCompatibilityRule(ResponsePropertyBecameOptionalId, ERR, ResponsePropertyBecameOptionalCheck), + newBackwardCompatibilityRule(ResponseWriteOnlyPropertyBecameOptionalId, INFO, ResponsePropertyBecameOptionalCheck), // ResponsePropertyBecameRequiredCheck - newBackwardCompatibilityRule(ResponsePropertyBecameRequiredId, INFO, true, ResponsePropertyBecameRequiredCheck), - newBackwardCompatibilityRule(ResponseWriteOnlyPropertyBecameRequiredId, INFO, true, ResponsePropertyBecameRequiredCheck), + newBackwardCompatibilityRule(ResponsePropertyBecameRequiredId, INFO, ResponsePropertyBecameRequiredCheck), + newBackwardCompatibilityRule(ResponseWriteOnlyPropertyBecameRequiredId, INFO, ResponsePropertyBecameRequiredCheck), // ResponsePropertyDefaultValueChangedCheck - newBackwardCompatibilityRule(ResponseBodyDefaultValueAddedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(ResponseBodyDefaultValueRemovedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(ResponseBodyDefaultValueChangedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyDefaultValueAddedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyDefaultValueRemovedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyDefaultValueChangedId, INFO, true, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponseBodyDefaultValueAddedId, INFO, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponseBodyDefaultValueRemovedId, INFO, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponseBodyDefaultValueChangedId, INFO, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyDefaultValueAddedId, INFO, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyDefaultValueRemovedId, INFO, ResponsePropertyDefaultValueChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyDefaultValueChangedId, INFO, ResponsePropertyDefaultValueChangedCheck), // ResponsePropertyEnumValueAddedCheck - newBackwardCompatibilityRule(ResponsePropertyEnumValueAddedId, WARN, true, ResponsePropertyEnumValueAddedCheck), - newBackwardCompatibilityRule(ResponseWriteOnlyPropertyEnumValueAddedId, INFO, true, ResponsePropertyEnumValueAddedCheck), + newBackwardCompatibilityRule(ResponsePropertyEnumValueAddedId, WARN, ResponsePropertyEnumValueAddedCheck), + newBackwardCompatibilityRule(ResponseWriteOnlyPropertyEnumValueAddedId, INFO, ResponsePropertyEnumValueAddedCheck), // ResponsePropertyMaxIncreasedCheck - newBackwardCompatibilityRule(ResponseBodyMaxIncreasedId, ERR, true, ResponsePropertyMaxIncreasedCheck), - newBackwardCompatibilityRule(ResponsePropertyMaxIncreasedId, ERR, true, ResponsePropertyMaxIncreasedCheck), + newBackwardCompatibilityRule(ResponseBodyMaxIncreasedId, ERR, ResponsePropertyMaxIncreasedCheck), + newBackwardCompatibilityRule(ResponsePropertyMaxIncreasedId, ERR, ResponsePropertyMaxIncreasedCheck), // ResponsePropertyMaxLengthIncreasedCheck - newBackwardCompatibilityRule(ResponseBodyMaxLengthIncreasedId, ERR, true, ResponsePropertyMaxLengthIncreasedCheck), - newBackwardCompatibilityRule(ResponsePropertyMaxLengthIncreasedId, ERR, true, ResponsePropertyMaxLengthIncreasedCheck), + newBackwardCompatibilityRule(ResponseBodyMaxLengthIncreasedId, ERR, ResponsePropertyMaxLengthIncreasedCheck), + newBackwardCompatibilityRule(ResponsePropertyMaxLengthIncreasedId, ERR, ResponsePropertyMaxLengthIncreasedCheck), // ResponsePropertyMaxLengthUnsetCheck - newBackwardCompatibilityRule(ResponseBodyMaxLengthUnsetId, ERR, true, ResponsePropertyMaxLengthUnsetCheck), - newBackwardCompatibilityRule(ResponsePropertyMaxLengthUnsetId, ERR, true, ResponsePropertyMaxLengthUnsetCheck), + newBackwardCompatibilityRule(ResponseBodyMaxLengthUnsetId, ERR, ResponsePropertyMaxLengthUnsetCheck), + newBackwardCompatibilityRule(ResponsePropertyMaxLengthUnsetId, ERR, ResponsePropertyMaxLengthUnsetCheck), // ResponsePropertyMinDecreasedCheck - newBackwardCompatibilityRule(ResponseBodyMinDecreasedId, ERR, true, ResponsePropertyMinDecreasedCheck), - newBackwardCompatibilityRule(ResponsePropertyMinDecreasedId, ERR, true, ResponsePropertyMinDecreasedCheck), + newBackwardCompatibilityRule(ResponseBodyMinDecreasedId, ERR, ResponsePropertyMinDecreasedCheck), + newBackwardCompatibilityRule(ResponsePropertyMinDecreasedId, ERR, ResponsePropertyMinDecreasedCheck), // ResponsePropertyMinItemsDecreasedCheck - newBackwardCompatibilityRule(ResponseBodyMinItemsDecreasedId, ERR, true, ResponsePropertyMinItemsDecreasedCheck), - newBackwardCompatibilityRule(ResponsePropertyMinItemsDecreasedId, ERR, true, ResponsePropertyMinItemsDecreasedCheck), + newBackwardCompatibilityRule(ResponseBodyMinItemsDecreasedId, ERR, ResponsePropertyMinItemsDecreasedCheck), + newBackwardCompatibilityRule(ResponsePropertyMinItemsDecreasedId, ERR, ResponsePropertyMinItemsDecreasedCheck), // ResponsePropertyMinItemsUnsetCheck - newBackwardCompatibilityRule(ResponseBodyMinItemsUnsetId, ERR, true, ResponsePropertyMinItemsUnsetCheck), - newBackwardCompatibilityRule(ResponsePropertyMinItemsUnsetId, ERR, true, ResponsePropertyMinItemsUnsetCheck), + newBackwardCompatibilityRule(ResponseBodyMinItemsUnsetId, ERR, ResponsePropertyMinItemsUnsetCheck), + newBackwardCompatibilityRule(ResponsePropertyMinItemsUnsetId, ERR, ResponsePropertyMinItemsUnsetCheck), // ResponsePropertyMinLengthDecreasedCheck - newBackwardCompatibilityRule(ResponseBodyMinLengthDecreasedId, ERR, true, ResponsePropertyMinLengthDecreasedCheck), - newBackwardCompatibilityRule(ResponsePropertyMinLengthDecreasedId, ERR, true, ResponsePropertyMinLengthDecreasedCheck), + newBackwardCompatibilityRule(ResponseBodyMinLengthDecreasedId, ERR, ResponsePropertyMinLengthDecreasedCheck), + newBackwardCompatibilityRule(ResponsePropertyMinLengthDecreasedId, ERR, ResponsePropertyMinLengthDecreasedCheck), // ResponsePropertyOneOfUpdated - newBackwardCompatibilityRule(ResponseBodyOneOfAddedId, INFO, true, ResponsePropertyOneOfUpdated), - newBackwardCompatibilityRule(ResponseBodyOneOfRemovedId, INFO, true, ResponsePropertyOneOfUpdated), - newBackwardCompatibilityRule(ResponsePropertyOneOfAddedId, INFO, true, ResponsePropertyOneOfUpdated), - newBackwardCompatibilityRule(ResponsePropertyOneOfRemovedId, INFO, true, ResponsePropertyOneOfUpdated), + newBackwardCompatibilityRule(ResponseBodyOneOfAddedId, INFO, ResponsePropertyOneOfUpdated), + newBackwardCompatibilityRule(ResponseBodyOneOfRemovedId, INFO, ResponsePropertyOneOfUpdated), + newBackwardCompatibilityRule(ResponsePropertyOneOfAddedId, INFO, ResponsePropertyOneOfUpdated), + newBackwardCompatibilityRule(ResponsePropertyOneOfRemovedId, INFO, ResponsePropertyOneOfUpdated), // ResponsePropertyTypeChangedCheck - newBackwardCompatibilityRule(ResponseBodyTypeChangedId, ERR, true, ResponsePropertyTypeChangedCheck), - newBackwardCompatibilityRule(ResponsePropertyTypeChangedId, ERR, true, ResponsePropertyTypeChangedCheck), + newBackwardCompatibilityRule(ResponseBodyTypeChangedId, ERR, ResponsePropertyTypeChangedCheck), + newBackwardCompatibilityRule(ResponsePropertyTypeChangedId, ERR, ResponsePropertyTypeChangedCheck), // ResponseRequiredPropertyUpdatedCheck - newBackwardCompatibilityRule(ResponseRequiredPropertyRemovedId, ERR, true, ResponseRequiredPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseRequiredWriteOnlyPropertyRemovedId, INFO, true, ResponseRequiredPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseRequiredPropertyAddedId, INFO, true, ResponseRequiredPropertyUpdatedCheck), - newBackwardCompatibilityRule(ResponseRequiredWriteOnlyPropertyAddedId, INFO, true, ResponseRequiredPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyRemovedId, ERR, ResponseRequiredPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseRequiredWriteOnlyPropertyRemovedId, INFO, ResponseRequiredPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyAddedId, INFO, ResponseRequiredPropertyUpdatedCheck), + newBackwardCompatibilityRule(ResponseRequiredWriteOnlyPropertyAddedId, INFO, ResponseRequiredPropertyUpdatedCheck), // ResponseRequiredPropertyWriteOnlyReadOnlyCheck - newBackwardCompatibilityRule(ResponseRequiredPropertyBecameNonWriteOnlyId, WARN, true, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseRequiredPropertyBecameWriteOnlyId, INFO, true, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseRequiredPropertyBecameReadOnlyId, INFO, true, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), - newBackwardCompatibilityRule(ResponseRequiredPropertyBecameNonReadOnlyId, INFO, true, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyBecameNonWriteOnlyId, WARN, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyBecameWriteOnlyId, INFO, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyBecameReadOnlyId, INFO, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), + newBackwardCompatibilityRule(ResponseRequiredPropertyBecameNonReadOnlyId, INFO, ResponseRequiredPropertyWriteOnlyReadOnlyCheck), // ResponseSuccessStatusUpdatedCheck - newBackwardCompatibilityRule(ResponseSuccessStatusRemovedId, ERR, true, ResponseSuccessStatusUpdatedCheck), - newBackwardCompatibilityRule(ResponseSuccessStatusAddedId, INFO, true, ResponseSuccessStatusUpdatedCheck), + newBackwardCompatibilityRule(ResponseSuccessStatusRemovedId, ERR, ResponseSuccessStatusUpdatedCheck), + newBackwardCompatibilityRule(ResponseSuccessStatusAddedId, INFO, ResponseSuccessStatusUpdatedCheck), // ResponseNonSuccessStatusUpdatedCheck - newBackwardCompatibilityRule(ResponseNonSuccessStatusRemovedId, INFO, false, ResponseNonSuccessStatusUpdatedCheck), // INFO or ERR - newBackwardCompatibilityRule(ResponseNonSuccessStatusAddedId, INFO, false, ResponseNonSuccessStatusUpdatedCheck), + newBackwardCompatibilityRule(ResponseNonSuccessStatusRemovedId, INFO, ResponseNonSuccessStatusUpdatedCheck), // optional + newBackwardCompatibilityRule(ResponseNonSuccessStatusAddedId, INFO, ResponseNonSuccessStatusUpdatedCheck), // APIOperationIdUpdatedCheck - newBackwardCompatibilityRule(APIOperationIdRemovedId, INFO, false, APIOperationIdUpdatedCheck), // INFO or ERR - newBackwardCompatibilityRule(APIOperationIdAddId, INFO, false, APIOperationIdUpdatedCheck), + newBackwardCompatibilityRule(APIOperationIdRemovedId, INFO, APIOperationIdUpdatedCheck), // optional + newBackwardCompatibilityRule(APIOperationIdAddId, INFO, APIOperationIdUpdatedCheck), // APITagUpdatedCheck - newBackwardCompatibilityRule(APITagRemovedId, INFO, false, APITagUpdatedCheck), // INFO or ERR - newBackwardCompatibilityRule(APITagAddedId, INFO, false, APITagUpdatedCheck), + newBackwardCompatibilityRule(APITagRemovedId, INFO, APITagUpdatedCheck), // optional + newBackwardCompatibilityRule(APITagAddedId, INFO, APITagUpdatedCheck), // APIComponentsSchemaRemovedCheck - newBackwardCompatibilityRule(APISchemasRemovedId, INFO, false, APIComponentsSchemaRemovedCheck), // INFO or ERR + newBackwardCompatibilityRule(APISchemasRemovedId, INFO, APIComponentsSchemaRemovedCheck), // optional // ResponseParameterEnumValueRemovedCheck - newBackwardCompatibilityRule(ResponsePropertyEnumValueRemovedId, INFO, false, ResponseParameterEnumValueRemovedCheck), // INFO or ERR + newBackwardCompatibilityRule(ResponsePropertyEnumValueRemovedId, INFO, ResponseParameterEnumValueRemovedCheck), // optional // ResponseMediaTypeEnumValueRemovedCheck - newBackwardCompatibilityRule(ResponseMediaTypeEnumValueRemovedId, INFO, false, ResponseMediaTypeEnumValueRemovedCheck), // INFO or ERR + newBackwardCompatibilityRule(ResponseMediaTypeEnumValueRemovedId, INFO, ResponseMediaTypeEnumValueRemovedCheck), // optional // RequestBodyEnumValueRemovedCheck - newBackwardCompatibilityRule(RequestBodyEnumValueRemovedId, INFO, false, RequestBodyEnumValueRemovedCheck), // INFO or ERR + newBackwardCompatibilityRule(RequestBodyEnumValueRemovedId, INFO, RequestBodyEnumValueRemovedCheck), // optional } } func GetOptionalRules() BackwardCompatibilityRules { return BackwardCompatibilityRules{ - newBackwardCompatibilityRule(ResponseNonSuccessStatusRemovedId, INFO, false, ResponseNonSuccessStatusUpdatedCheck), - newBackwardCompatibilityRule(APIOperationIdRemovedId, INFO, false, APIOperationIdUpdatedCheck), - newBackwardCompatibilityRule(APITagRemovedId, INFO, false, APITagUpdatedCheck), - newBackwardCompatibilityRule(APISchemasRemovedId, INFO, false, APIComponentsSchemaRemovedCheck), - newBackwardCompatibilityRule(ResponsePropertyEnumValueRemovedId, INFO, false, ResponseParameterEnumValueRemovedCheck), - newBackwardCompatibilityRule(ResponseMediaTypeEnumValueRemovedId, INFO, false, ResponseMediaTypeEnumValueRemovedCheck), - newBackwardCompatibilityRule(RequestBodyEnumValueRemovedId, INFO, false, RequestBodyEnumValueRemovedCheck), + newBackwardCompatibilityRule(ResponseNonSuccessStatusRemovedId, INFO, ResponseNonSuccessStatusUpdatedCheck), + newBackwardCompatibilityRule(APIOperationIdRemovedId, INFO, APIOperationIdUpdatedCheck), + newBackwardCompatibilityRule(APITagRemovedId, INFO, APITagUpdatedCheck), + newBackwardCompatibilityRule(APISchemasRemovedId, INFO, APIComponentsSchemaRemovedCheck), + newBackwardCompatibilityRule(ResponsePropertyEnumValueRemovedId, INFO, ResponseParameterEnumValueRemovedCheck), + newBackwardCompatibilityRule(ResponseMediaTypeEnumValueRemovedId, INFO, ResponseMediaTypeEnumValueRemovedCheck), + newBackwardCompatibilityRule(RequestBodyEnumValueRemovedId, INFO, RequestBodyEnumValueRemovedCheck), } } -func GetRequiredRules() BackwardCompatibilityRules { - result := BackwardCompatibilityRules{} - for _, rule := range GetAllRules() { - if rule.Required { - result = append(result, rule) - } - } - return result +// GetCheckLevels gets levels for all backward compatibility checks +func GetCheckLevels() map[string]Level { + return rulesToLevels(GetAllRules()) +} + +// GetAllChecks gets all backward compatibility checks +func GetAllChecks() BackwardCompatibilityChecks { + return rulesToChecks(GetAllRules()) } // rulesToChecks return a unique list of checks from a list of rules @@ -421,6 +419,14 @@ func rulesToChecks(rules BackwardCompatibilityRules) BackwardCompatibilityChecks return result } +func GetOptionalRuleIds() []string { + return rulesToIIs(GetOptionalRules()) +} + +func GetAllRuleIds() []string { + return rulesToIIs(GetAllRules()) +} + // rulesToLevels return a map of check IDs to levels func rulesToLevels(rules BackwardCompatibilityRules) map[string]Level { result := map[string]Level{} @@ -430,10 +436,9 @@ func rulesToLevels(rules BackwardCompatibilityRules) map[string]Level { return result } -func GetOptionalRuleIds() []string { - +func rulesToIIs(rules BackwardCompatibilityRules) []string { result := []string{} - for _, rule := range GetOptionalRules() { + for _, rule := range rules { result = append(result, rule.Id) } return result diff --git a/data/severity-levels.txt b/data/severity-levels.txt new file mode 100644 index 00000000..d84a618c --- /dev/null +++ b/data/severity-levels.txt @@ -0,0 +1,2 @@ +api-security-removed warn +request-parameter-enum-value-added err diff --git a/diff/example_test.go b/diff/example_test.go index dd6a9fc2..9e90e232 100644 --- a/diff/example_test.go +++ b/diff/example_test.go @@ -3,12 +3,9 @@ package diff_test import ( "fmt" "os" - "strings" "github.com/getkin/kin-openapi/openapi3" - "github.com/tufin/oasdiff/checker" "github.com/tufin/oasdiff/diff" - "github.com/tufin/oasdiff/load" "gopkg.in/yaml.v3" ) @@ -59,67 +56,3 @@ func ExampleGet() { // - method: GET // path: /api/test } - -func ExampleGetPathsDiff() { - loader := openapi3.NewLoader() - loader.IsExternalRefsAllowed = true - - s1, err := load.NewSpecInfo(loader, load.NewSource("../data/openapi-test1.yaml")) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to load spec: %v", err) - return - } - - s2, err := load.NewSpecInfo(loader, load.NewSource("../data/openapi-test3.yaml")) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to load spec: %v", err) - return - } - - diffRes, operationsSources, err := diff.GetPathsDiff(diff.NewConfig(), - []*load.SpecInfo{s1}, - []*load.SpecInfo{s2}, - ) - - if err != nil { - fmt.Fprintf(os.Stderr, "diff failed with %v", err) - return - } - - errs := checker.CheckBackwardCompatibility(checker.NewConfig(), diffRes, operationsSources) - - // process configuration file for ignoring errors - errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.ERR, errs, "../data/ignore-err-example.txt", checker.NewDefaultLocalizer()) - if err != nil { - fmt.Fprintf(os.Stderr, "ignore errors failed with %v", err) - return - } - - // process configuration file for ignoring warnings - errs, err = checker.ProcessIgnoredBackwardCompatibilityErrors(checker.WARN, errs, "../data/ignore-warn-example.txt", checker.NewDefaultLocalizer()) - if err != nil { - fmt.Fprintf(os.Stderr, "ignore warnings failed with %v", err) - return - } - - // pretty print breaking changes errors - if len(errs) > 0 { - localizer := checker.NewDefaultLocalizer() - count := errs.GetLevelCount() - fmt.Print(localizer("total-errors", len(errs), count[checker.ERR], "error", count[checker.WARN], "warning")) - for _, bcerr := range errs { - fmt.Printf("%s\n\n", strings.TrimRight(bcerr.SingleLineError(localizer, checker.ColorNever), " ")) - } - } - - // Output: - // 4 breaking changes: 1 error, 3 warning - // error at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score removed the success response with the status '201' [response-success-status-removed]. - // - // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'cookie' request parameter 'test' [request-parameter-removed]. - // - // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'header' request parameter 'user' [request-parameter-removed]. - // - // warning at ../data/openapi-test3.yaml, in API GET /api/{domain}/{project}/badges/security-score deleted the 'query' request parameter 'filter' [request-parameter-removed]. - // -} diff --git a/docs/BREAKING-CHANGES-EXAMPLES.md b/docs/BREAKING-CHANGES-EXAMPLES.md index 314d103e..8862f666 100644 --- a/docs/BREAKING-CHANGES-EXAMPLES.md +++ b/docs/BREAKING-CHANGES-EXAMPLES.md @@ -56,10 +56,10 @@ These examples are automatically generated from unit tests. [deleting an operation before sunset date is breaking](../checker/check_api_removed_test.go?plain=1#L11) [deleting an operation is breaking](../checker/check_breaking_test.go?plain=1#L45) [deleting sunset header for a deprecated endpoint is breaking](../checker/check_api_sunset_changed_test.go?plain=1#L11) -[deprecating an operation with a deprecation policy and an invalid stability level is breaking](../checker/check_api_deprecation_test.go?plain=1#L63) -[deprecating an operation with a deprecation policy and an invalid sunset date is breaking](../checker/check_api_deprecation_test.go?plain=1#L44) -[deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking](../checker/check_api_deprecation_test.go?plain=1#L210) -[deprecating an operation with a deprecation policy but without specifying sunset date is breaking](../checker/check_api_deprecation_test.go?plain=1#L99) +[deprecating an operation with a deprecation policy and an invalid stability level is breaking](../checker/check_api_deprecation_test.go?plain=1#L67) +[deprecating an operation with a deprecation policy and an invalid sunset date is breaking](../checker/check_api_deprecation_test.go?plain=1#L48) +[deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking](../checker/check_api_deprecation_test.go?plain=1#L214) +[deprecating an operation with a deprecation policy but without specifying sunset date is breaking](../checker/check_api_deprecation_test.go?plain=1#L103) [inclreasing request body min items is breaking](../checker/check_request_property_min_items_increased_test.go?plain=1#L12) [increasing max length in response is breaking](../checker/check_breaking_min_max_test.go?plain=1#L93) [increasing min items in request is breaking](../checker/check_breaking_min_max_test.go?plain=1#L236) @@ -129,21 +129,21 @@ These examples are automatically generated from unit tests. [changing response's body schema type from number to integer is not breaking](../checker/check_breaking_response_type_changed_test.go?plain=1#L52) [changing response's body schema type from number/none to integer/int32 is not breaking](../checker/check_breaking_response_type_changed_test.go?plain=1#L90) [changing servers is not breaking](../checker/check_not_breaking_test.go?plain=1#L252) -[deleting a path after sunset date of all contained operations is not breaking](../checker/check_api_deprecation_test.go?plain=1#L251) +[deleting a path after sunset date of all contained operations is not breaking](../checker/check_api_deprecation_test.go?plain=1#L255) [deleting a pattern from a schema is not breaking](../checker/check_breaking_test.go?plain=1#L459) [deleting a required write-only property in response body is not breaking](../checker/check_breaking_property_test.go?plain=1#L495) [deleting a tag is not breaking](../checker/check_not_breaking_test.go?plain=1#L71) -[deleting an operation after sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L29) +[deleting an operation after sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L33) [deleting an operation without sunset date is not breaking](../checker/check_api_removed_test.go?plain=1#L29) [deleting other extension (not sunset) header for a deprecated endpoint is not breaking](../checker/check_api_sunset_changed_test.go?plain=1#L84) [deprecating a header is not breaking](../checker/check_not_breaking_test.go?plain=1#L226) [deprecating a parameter is not breaking](../checker/check_not_breaking_test.go?plain=1#L213) [deprecating a schema is not breaking](../checker/check_not_breaking_test.go?plain=1#L239) -[deprecating an operation with a default deprecation policy but without specifying sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L117) -[deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking](../checker/check_api_deprecation_test.go?plain=1#L230) -[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for alpha level](../checker/check_api_deprecation_test.go?plain=1#L133) -[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for draft level](../checker/check_api_deprecation_test.go?plain=1#L167) -[deprecating an operation without a deprecation policy but without specifying sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L83) +[deprecating an operation with a default deprecation policy but without specifying sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L121) +[deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking](../checker/check_api_deprecation_test.go?plain=1#L234) +[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for alpha level](../checker/check_api_deprecation_test.go?plain=1#L137) +[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for draft level](../checker/check_api_deprecation_test.go?plain=1#L171) +[deprecating an operation without a deprecation policy but without specifying sunset date is not breaking](../checker/check_api_deprecation_test.go?plain=1#L87) [descreasing request body min items is not breaking](../checker/check_request_property_min_items_increased_test.go?plain=1#L35) [increasing max length in request is not breaking](../checker/check_breaking_min_max_test.go?plain=1#L76) [increasing min items in response is not breaking](../checker/check_breaking_min_max_test.go?plain=1#L250) @@ -162,8 +162,8 @@ These examples are automatically generated from unit tests. [reducing min length in request is not breaking](../checker/check_breaking_min_max_test.go?plain=1#L48) [removing an existing response with error status is not breaking](../checker/check_breaking_test.go?plain=1#L406) [removing an existing response with unparseable status is not breaking](../checker/check_breaking_test.go?plain=1#L390) -[removing the path without a deprecation policy and without specifying sunset date is not breaking for alpha level](../checker/check_api_deprecation_test.go?plain=1#L148) -[removing the path without a deprecation policy and without specifying sunset date is not breaking for draft level](../checker/check_api_deprecation_test.go?plain=1#L184) +[removing the path without a deprecation policy and without specifying sunset date is not breaking for alpha level](../checker/check_api_deprecation_test.go?plain=1#L152) +[removing the path without a deprecation policy and without specifying sunset date is not breaking for draft level](../checker/check_api_deprecation_test.go?plain=1#L188) [renaming a path parameter is not breaking](../checker/check_breaking_test.go?plain=1#L136) ## Examples of info-level changes for changelog @@ -306,8 +306,8 @@ These examples are automatically generated from unit tests. [making request property required, while also giving it a default value](../checker/check_request_property_required_updated_test.go?plain=1#L58) [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/check_api_deprecation_test.go?plain=1#L266) -[path operations that were re-activated](../checker/check_api_deprecation_test.go?plain=1#L289) +[path operations that became deprecated](../checker/check_api_deprecation_test.go?plain=1#L270) +[path operations that were re-activated](../checker/check_api_deprecation_test.go?plain=1#L293) [removing 'allOf' subschema from the request body or request body property](../checker/check_request_property_all_of_updated_test.go?plain=1#L46) [removing 'allOf' subschema from the response body or response body property](../checker/check_response_property_all_of_updated_test.go?plain=1#L46) [removing 'anyOf' schema from the request body or request body property](../checker/check_request_property_any_of_updated_test.go?plain=1#L46) diff --git a/docs/BREAKING-CHANGES.md b/docs/BREAKING-CHANGES.md index 16aacd63..6c23f459 100644 --- a/docs/BREAKING-CHANGES.md +++ b/docs/BREAKING-CHANGES.md @@ -27,6 +27,7 @@ To see the full list of checks and their descriptions, run: ``` oasdiff checks ``` +See also [Customizing Severity Levels](#customizing-severity-levels) ### Preventing Breaking Changes A common way to use oasdiff is by running it as a step the CI/CD pipeline to detect changes. @@ -100,14 +101,16 @@ This method allows adding new entries to enums used in responses which is very u In most cases the `x-extensible-enum` is similar to enum values, except it allows adding new entries in messages sent to the client (responses or callbacks). If you don't use the `x-extensible-enum` in your OpenAPI specifications, nothing changes for you, but if you do, oasdiff will identify breaking changes related to `x-extensible-enum` parameters and properties. -### Optional Checks -Oasdiff supports a few optional checks which can be added with the `--include-checks` flag. For example: +### Customizing Severity Levels +Oasdiff allows you to change the default severity levels according to your needs. +For example, the default severity level of the `api-security-removed` check is `INFO`. You can verify this by running `oasdiff checks`. +To change the `api-security-removed` check's severity level to `ERR` use the following command: ``` -oasdiff breaking data/openapi-test1.yaml data/openapi-test3.yaml --include-checks response-non-success-status-removed +oasdiff changelog data/checker/api_security_added_revision.yaml data/checker/api_security_added_base.yaml --severity-levels oasdiff-levels.txt ``` -To see a list of optional checks, run: +Where the file `oasdiff-levels.txt` contains a single line: ``` -oasdiff checks --required false +api-security-removed err ``` [Here are some examples of breaking and non-breaking changes that oasdiff supports](BREAKING-CHANGES-EXAMPLES.md). diff --git a/docs/CUSTOMIZING-CHECKS.md b/docs/CUSTOMIZING-CHECKS.md index 1ff68518..57e1d278 100644 --- a/docs/CUSTOMIZING-CHECKS.md +++ b/docs/CUSTOMIZING-CHECKS.md @@ -28,7 +28,6 @@ ./scripts/test.sh ``` 3. Make sure that [BREAKING-CHANGES-EXAMPLES.md](BREAKING-CHANGES-EXAMPLES.md) was updated with your use-cases -4. If your check is optional, also add it to [this list of optional checks](https://github.com/Tufin/oasdiff#optional-breaking-changes-checks) ## Example See this example of adding a custom check: https://github.com/Tufin/oasdiff/pull/208/files diff --git a/formatters/checks.go b/formatters/checks.go index 2fe0b533..f36c1297 100644 --- a/formatters/checks.go +++ b/formatters/checks.go @@ -4,7 +4,6 @@ type Check struct { Id string `json:"id" yaml:"id"` Level string `json:"level" yaml:"level"` Description string `json:"description" yaml:"description"` - Required bool `json:"required" yaml:"required"` } type Checks []Check diff --git a/formatters/format_json_test.go b/formatters/format_json_test.go index 0a5eec70..dd735a1c 100644 --- a/formatters/format_json_test.go +++ b/formatters/format_json_test.go @@ -37,13 +37,12 @@ func TestJsonFormatter_RenderChecks(t *testing.T) { Id: "change_id", Level: "info", Description: "This is a breaking change.", - Required: true, }, } out, err := jsonFormatter.RenderChecks(checks, formatters.NewRenderOpts()) require.NoError(t, err) - require.Equal(t, "[{\"id\":\"change_id\",\"level\":\"info\",\"description\":\"This is a breaking change.\",\"required\":true}]", string(out)) + require.Equal(t, "[{\"id\":\"change_id\",\"level\":\"info\",\"description\":\"This is a breaking change.\"}]", string(out)) } func TestJsonFormatter_RenderDiff(t *testing.T) { diff --git a/formatters/format_text_test.go b/formatters/format_text_test.go index 855862e2..806eb3f3 100644 --- a/formatters/format_text_test.go +++ b/formatters/format_text_test.go @@ -39,7 +39,6 @@ func TestTextFormatter_RenderChecks(t *testing.T) { Id: "change_id", Level: "info", Description: "This is a breaking change.", - Required: true, }, } diff --git a/formatters/format_yaml_test.go b/formatters/format_yaml_test.go index 5fd2239a..9c0ebd48 100644 --- a/formatters/format_yaml_test.go +++ b/formatters/format_yaml_test.go @@ -37,13 +37,12 @@ func TestYamlFormatter_RenderChecks(t *testing.T) { Id: "change_id", Level: "info", Description: "This is a breaking change.", - Required: true, }, } out, err := yamlFormatter.RenderChecks(checks, formatters.NewRenderOpts()) require.NoError(t, err) - require.Equal(t, "- id: change_id\n level: info\n description: This is a breaking change.\n required: true\n", string(out)) + require.Equal(t, "- id: change_id\n level: info\n description: This is a breaking change.\n", string(out)) } func TestYamlFormatter_RenderDiff(t *testing.T) { diff --git a/internal/changelog.go b/internal/changelog.go index e56235d3..0f830699 100644 --- a/internal/changelog.go +++ b/internal/changelog.go @@ -47,15 +47,22 @@ func runChangelog(flags Flags, stdout io.Writer) (bool, *ReturnError) { func getChangelog(flags Flags, stdout io.Writer, level checker.Level) (bool, *ReturnError) { - diffResult, err := calcDiff(flags) - if err != nil { - return false, err + diffResult, returnErr := calcDiff(flags) + if returnErr != nil { + return false, returnErr } - bcConfig := checker.NewConfig().WithOptionalChecks(flags.getIncludeChecks()).WithDeprecation(flags.getDeprecationDaysBeta(), flags.getDeprecationDaysStable()) + severityLevels, returnErr := getCustomSeverityLevels(flags.getSeverityLevelsFile()) + if returnErr != nil { + return false, returnErr + } errs, returnErr := filterIgnored( - checker.CheckBackwardCompatibilityUntilLevel(bcConfig, diffResult.diffReport, diffResult.operationsSources, level), + checker.CheckBackwardCompatibilityUntilLevel( + checker.NewConfig(checker.GetAllChecks()).WithOptionalChecks(flags.getIncludeChecks()).WithSeverityLevels(severityLevels).WithDeprecation(flags.getDeprecationDaysBeta(), flags.getDeprecationDaysStable()), + diffResult.diffReport, + diffResult.operationsSources, + level), flags.getWarnIgnoreFile(), flags.getErrIgnoreFile(), checker.NewLocalizer(flags.getLang())) @@ -126,3 +133,16 @@ func outputChangelog(flags Flags, stdout io.Writer, errs checker.Changes, specIn return nil } + +func getCustomSeverityLevels(severityLevelsFile string) (map[string]checker.Level, *ReturnError) { + if severityLevelsFile == "" { + return nil, nil + } + + m, err := checker.ProcessSeverityLevels(severityLevelsFile) + if err != nil { + return nil, getErrFailedToLoadSeverityLevels(severityLevelsFile, err) + } + + return m, nil +} diff --git a/internal/changelog_flags.go b/internal/changelog_flags.go index c68729b0..b2189ea5 100644 --- a/internal/changelog_flags.go +++ b/internal/changelog_flags.go @@ -30,6 +30,7 @@ type ChangelogFlags struct { deprecationDaysBeta uint deprecationDaysStable uint color string + severityLevelsFile string } func (flags *ChangelogFlags) toConfig() *diff.Config { @@ -117,6 +118,10 @@ func (flags *ChangelogFlags) getAsymmetric() bool { return false } +func (flags *ChangelogFlags) getSeverityLevelsFile() string { + return flags.severityLevelsFile +} + func (flags *ChangelogFlags) setBase(source *load.Source) { flags.base = source } @@ -208,3 +213,7 @@ func (flags *ChangelogFlags) refDeprecationDaysStable() *uint { func (flags *ChangelogFlags) refColor() *string { return &flags.color } + +func (flags *ChangelogFlags) refSeverityLevelsFile() *string { + return &flags.severityLevelsFile +} diff --git a/internal/checks.go b/internal/checks.go index f95b74a1..66a97258 100644 --- a/internal/checks.go +++ b/internal/checks.go @@ -20,7 +20,6 @@ type ChecksFlags struct { format string severity []string tags []string - required string } func getChecksCmd() *cobra.Command { @@ -49,26 +48,12 @@ func getChecksCmd() *cobra.Command { enumWithOptions(&cmd, newEnumValue(formatters.SupportedFormatsByContentType(formatters.OutputChecks), string(formatters.FormatText), &flags.format), "format", "f", "output format") enumWithOptions(&cmd, newEnumSliceValue([]string{"info", "warn", "error"}, nil, &flags.severity), "severity", "s", "list of severities to include (experimental)") cmd.PersistentFlags().StringSliceVarP(&flags.tags, "tags", "t", []string{}, "list of tags to include, eg. parameter, request (experimental)") - enumWithOptions(&cmd, newEnumValue([]string{"true", "false", "all"}, "all", &flags.required), "required", "r", "filter by required / optional") return &cmd } func runChecks(stdout io.Writer, flags ChecksFlags) *ReturnError { - return outputChecks(stdout, flags, getRules(flags.required)) -} - -func getRules(required string) []checker.BackwardCompatibilityRule { - switch required { - case "all": - return checker.GetAllRules() - case "false": - return checker.GetOptionalRules() - case "true": - return checker.GetRequiredRules() - } - - return nil + return outputChecks(stdout, flags, checker.GetAllRules()) } func outputChecks(stdout io.Writer, flags ChecksFlags, rules []checker.BackwardCompatibilityRule) *ReturnError { @@ -114,7 +99,6 @@ func outputChecks(stdout io.Writer, flags ChecksFlags, rules []checker.BackwardC Id: rule.Id, Level: rule.Level.String(), Description: rule.Description, - Required: rule.Required, }) } diff --git a/internal/cmd_flags.go b/internal/cmd_flags.go index 2df800fc..66442963 100644 --- a/internal/cmd_flags.go +++ b/internal/cmd_flags.go @@ -55,9 +55,11 @@ func addCommonBreakingFlags(cmd *cobra.Command, flags Flags) { enumWithOptions(cmd, newEnumValue(localizations.GetSupportedLanguages(), localizations.LangDefault, flags.refLang()), "lang", "l", "language for localized output") cmd.PersistentFlags().StringVarP(flags.refErrIgnoreFile(), "err-ignore", "", "", "configuration file for ignoring errors") cmd.PersistentFlags().StringVarP(flags.refWarnIgnoreFile(), "warn-ignore", "", "", "configuration file for ignoring warnings") - cmd.PersistentFlags().VarP(newEnumSliceValue(checker.GetOptionalRuleIds(), nil, flags.refIncludeChecks()), "include-checks", "i", "comma-separated list of optional checks (run 'oasdiff checks --required false' to see options)") + cmd.PersistentFlags().VarP(newEnumSliceValue(checker.GetOptionalRuleIds(), nil, flags.refIncludeChecks()), "include-checks", "i", "comma-separated list of optional checks") + hideFlag(cmd, "include-checks") cmd.PersistentFlags().UintVarP(flags.refDeprecationDaysBeta(), "deprecation-days-beta", "", checker.DefaultBetaDeprecationDays, "min days required between deprecating a beta resource and removing it") cmd.PersistentFlags().UintVarP(flags.refDeprecationDaysStable(), "deprecation-days-stable", "", checker.DefaultStableDeprecationDays, "min days required between deprecating a stable resource and removing it") enumWithOptions(cmd, newEnumValue([]string{"auto", "always", "never"}, "auto", flags.refColor()), "color", "", "when to colorize textual output") enumWithOptions(cmd, newEnumValue(formatters.SupportedFormatsByContentType(formatters.OutputChangelog), string(formatters.FormatText), flags.refFormat()), "format", "f", "output format") + cmd.PersistentFlags().StringVarP(flags.refSeverityLevelsFile(), "severity-levels", "", "", "configuration file for custom severity levels") } diff --git a/internal/diff_flags.go b/internal/diff_flags.go index 7db99136..49009410 100644 --- a/internal/diff_flags.go +++ b/internal/diff_flags.go @@ -109,6 +109,10 @@ func (flags *DiffFlags) getAsymmetric() bool { return false } +func (flags *DiffFlags) getSeverityLevelsFile() string { + return "" +} + func (flags *DiffFlags) setBase(source *load.Source) { flags.base = source } @@ -200,3 +204,7 @@ func (flags *DiffFlags) refDeprecationDaysStable() *uint { func (flags *DiffFlags) refColor() *string { return nil } + +func (flags *DiffFlags) refSeverityLevelsFile() *string { + return nil +} diff --git a/internal/errors.go b/internal/errors.go index c30c2ea8..84d2855d 100644 --- a/internal/errors.go +++ b/internal/errors.go @@ -48,6 +48,13 @@ func getErrFailedPrint(what string, err error) *ReturnError { ) } +func getErrFailedToLoadSeverityLevels(source string, err error) *ReturnError { + return getError( + fmt.Errorf("failed to load custom severity levels from %s: %w", source, err), + 106, + ) +} + func getErrUnsupportedFormat(format, cmd string) *ReturnError { return getError( fmt.Errorf("format %q is not supported by %q", format, cmd), diff --git a/internal/flags.go b/internal/flags.go index 4912dd0b..e5a97e80 100644 --- a/internal/flags.go +++ b/internal/flags.go @@ -26,6 +26,7 @@ type Flags interface { getLevel() string getFailOnDiff() bool getAsymmetric() bool + getSeverityLevelsFile() string setBase(source *load.Source) setRevision(source *load.Source) @@ -52,4 +53,5 @@ type Flags interface { refDeprecationDaysBeta() *uint refDeprecationDaysStable() *uint refColor() *string + refSeverityLevelsFile() *string } diff --git a/internal/run_test.go b/internal/run_test.go index 9da1bec0..d094efd3 100644 --- a/internal/run_test.go +++ b/internal/run_test.go @@ -326,3 +326,11 @@ func Test_InvalidEnumValue(t *testing.T) { require.Equal(t, `Error: invalid argument "xxx" for "-e, --exclude-elements" flag: xxx is not one of the allowed values: description, endpoints, examples, extensions, summary, or title `, stderr.String()) } + +func Test_CustomSeverityLevels(t *testing.T) { + require.Zero(t, internal.Run(cmdToArgs("oasdiff changelog ../data/openapi-test1.yaml ../data/openapi-test3.yaml --severity-levels ../data/severity-levels.txt"), io.Discard, io.Discard)) +} + +func Test_CustomSeverityLevelsInvalidFile(t *testing.T) { + require.Equal(t, 106, internal.Run(cmdToArgs("oasdiff changelog ../data/openapi-test1.yaml ../data/openapi-test3.yaml --severity-levels ../data/invalid.txt"), io.Discard, io.Discard)) +}