Skip to content

Configurable incompatibility checks #552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f093580
config-file and config-prop CLI options
westse Jun 27, 2023
19d7901
Maven plugin config parameters
westse Jul 26, 2023
d1b0245
Configurable incompatible checks - Enum
westse Jul 18, 2023
a19683a
Configurable incompatible checks - MaxLength
westse Jul 18, 2023
3f43dc5
Configurable incompatible checks - Required
westse Jul 18, 2023
ec14f58
Configurable incompatible checks - ApiResponse
westse Jul 18, 2023
d3702b8
Configurable incompatible checks - Content
westse Jul 18, 2023
e53eb32
Configurable incompatible checks - Schema
westse Jul 19, 2023
acac9d2
Configurable incompatible checks - Extensions
westse Jul 19, 2023
290a489
Fix NumericRange compatibility checks
westse Jul 19, 2023
2111467
Configurable incompatible checks - NumericRange
westse Jul 20, 2023
fac7577
Configurable incompatible checks - ReadOnly
westse Jul 20, 2023
38340b6
Configurable incompatible checks - WriteOnly
westse Jul 20, 2023
8ed4e54
Configurable incompatible checks - Headers
westse Jul 20, 2023
e0609bb
Configurable incompatible checks - Header
westse Jul 20, 2023
ac3981c
Configurable incompatible checks - OneOf
westse Jul 20, 2023
839cb04
Configurable incompatible checks - OpenApi
westse Jul 21, 2023
2af9762
Configurable incompatible checks - Parameters
westse Jul 21, 2023
a38b6d4
Configurable incompatible checks - Parameter
westse Jul 21, 2023
d5b6104
Configurable incompatible checks - Paths
westse Jul 21, 2023
8c19195
Configurable incompatible checks - Path
westse Jul 25, 2023
9b28c66
Configurable incompatible checks - RequestBody
westse Jul 25, 2023
4ff68fa
Configurable incompatible checks - SecurityScheme
westse Jul 25, 2023
c51495f
Configurable incompatible checks - SecurityRequirement
westse Jul 25, 2023
60c3f1a
Configurable incompatible checks - SecurityRequirements
westse Jul 25, 2023
bec808b
Configurable incompatible checks - OauthFlow
westse Jul 26, 2023
058058c
Merge branch 'master' into configure-check-compatible
joschi Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Configurable incompatible checks - NumericRange
- See #550
- Makes configurable the enabling/disabling of this incompatibility check (disabled by default to avoid a breaking change)
  • Loading branch information
westse committed Jul 26, 2023
commit 2111467e116ffd5eb53a3191b91899f2af3f926f
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ public enum BackwardIncompatibleProp {
REQUEST_CONTENT_DECREASED("incompatible.request.content.decreased", true),
REQUEST_ENUM_DECREASED("incompatible.request.enum.decreased", true),
REQUEST_MAX_LENGTH_DECREASED("incompatible.request.max.length.decreased", true),
REQUEST_NUMERIC_RANGE_DECREASED("incompatible.request.numeric.range.decreased", true),
REQUEST_REQUIRED_INCREASED("incompatible.request.required.increased", true),
RESPONSE_CONTENT_DECREASED("incompatible.response.content.decreased", true),
RESPONSE_ENUM_INCREASED("incompatible.response.enum.increased", true),
RESPONSE_MAX_LENGTH_INCREASED("incompatible.response.max.length.increased", true),
RESPONSE_NUMERIC_RANGE_INCREASED("incompatible.response.numeric.range.increased", false),
RESPONSE_REQUIRED_DECREASED("incompatible.response.required.decreased", true),
RESPONSE_RESPONSES_DECREASED("incompatible.response.responses.decreased", true),
SCHEMA_DISCRIMINATOR_CHANGED("incompatible.schema.discriminator.changed", true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.openapitools.openapidiff.core.model.schema;

import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.REQUEST_NUMERIC_RANGE_DECREASED;
import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.RESPONSE_NUMERIC_RANGE_INCREASED;

import java.math.BigDecimal;
import java.util.Objects;
import org.openapitools.openapidiff.core.model.Changed;
Expand All @@ -26,6 +29,11 @@ public DiffResult isChanged() {
return DiffResult.NO_CHANGES;
}

if ((context.isRequest() && !REQUEST_NUMERIC_RANGE_DECREASED.enabled(context))
|| (context.isResponse() && !RESPONSE_NUMERIC_RANGE_INCREASED.enabled(context))) {
return DiffResult.COMPATIBLE;
}

boolean exclusiveMaxOld = oldMaximumExclusiveValue != null && oldMaximumExclusiveValue;
boolean exclusiveMinOld = oldMinimumExclusiveValue != null && oldMinimumExclusiveValue;
boolean exclusiveMaxNew = newMaximumExclusiveValue != null && newMaximumExclusiveValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.openapitools.openapidiff.core.backcompat;

import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible;
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible;
import static org.openapitools.openapidiff.core.TestUtils.assertSpecIncompatible;
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged;
import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.REQUEST_NUMERIC_RANGE_DECREASED;
import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.RESPONSE_NUMERIC_RANGE_INCREASED;

import org.junit.jupiter.api.Test;

Expand All @@ -21,81 +23,89 @@ public void changedButCompatible() {

@Test
public void requestExclusiveMaxCreated() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_created.yaml");
assertIncompatibleRequest("bc_request_numericrange_exclusive_max_created.yaml");
}

@Test
public void requestExclusiveMaxSet() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_set.yaml");
assertIncompatibleRequest("bc_request_numericrange_exclusive_max_set.yaml");
}

@Test
public void requestExclusiveMinCreated() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_created.yaml");
assertIncompatibleRequest("bc_request_numericrange_exclusive_min_created.yaml");
}

@Test
public void requestExclusiveMinSet() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_set.yaml");
assertIncompatibleRequest("bc_request_numericrange_exclusive_min_set.yaml");
}

@Test
public void requestMaxAdded() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_added.yaml");
assertIncompatibleRequest("bc_request_numericrange_max_added.yaml");
}

@Test
public void requestMaxDecreased() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_decreased.yaml");
assertIncompatibleRequest("bc_request_numericrange_max_decreased.yaml");
}

@Test
public void requestMinAdded() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_added.yaml");
assertIncompatibleRequest("bc_request_numericrange_min_added.yaml");
}

@Test
public void requestMinIncreased() {
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_increased.yaml");
assertIncompatibleRequest("bc_request_numericrange_min_increased.yaml");
}

@Test
public void responseExclusiveMaxDeleted() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_max_deleted.yaml");
assertIncompatibleResponse("bc_response_numericrange_exclusive_max_deleted.yaml");
}

@Test
public void responseExclusiveMaxUnset() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_max_unset.yaml");
assertIncompatibleResponse("bc_response_numericrange_exclusive_max_unset.yaml");
}

@Test
public void responseExclusiveMinDeleted() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_min_deleted.yaml");
assertIncompatibleResponse("bc_response_numericrange_exclusive_min_deleted.yaml");
}

@Test
public void responseExclusiveMinUnset() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_min_unset.yaml");
assertIncompatibleResponse("bc_response_numericrange_exclusive_min_unset.yaml");
}

@Test
public void responseMaxDeleted() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_max_deleted.yaml");
assertIncompatibleResponse("bc_response_numericrange_max_deleted.yaml");
}

@Test
public void responseMaxIncreased() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_max_increased.yaml");
assertIncompatibleResponse("bc_response_numericrange_max_increased.yaml");
}

@Test
public void responseMinDecreased() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_min_decreased.yaml");
assertIncompatibleResponse("bc_response_numericrange_min_decreased.yaml");
}

@Test
public void responseMinDeleted() {
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_min_deleted.yaml");
assertIncompatibleResponse("bc_response_numericrange_min_deleted.yaml");
}

private void assertIncompatibleRequest(String newSpec) {
assertSpecIncompatible(BASE, newSpec, REQUEST_NUMERIC_RANGE_DECREASED);
}

private void assertIncompatibleResponse(String newSpec) {
assertSpecIncompatible(BASE, newSpec, RESPONSE_NUMERIC_RANGE_INCREASED);
}
}