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 - SecurityRequirement
  • Loading branch information
westse committed Jul 26, 2023
commit c51495f8e380ee84ab43d65a15b3dd08a54cbba6
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public DeferredChanged<ChangedSecurityRequirement> diff(
DeferredBuilder<Changed> builder = new DeferredBuilder<>();

ChangedSecurityRequirement changedSecurityRequirement =
new ChangedSecurityRequirement(left, right != null ? getCopy(right) : null);
new ChangedSecurityRequirement(left, right != null ? getCopy(right) : null, context);

SecurityRequirement leftRequirement = left == null ? new SecurityRequirement() : left;
SecurityRequirement rightRequirement = right == null ? new SecurityRequirement() : right;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public enum BackwardIncompatibleProp {
RESPONSE_RESPONSES_DECREASED("incompatible.response.responses.decreased", true),
RESPONSE_WRITEONLY_INCREASED("incompatible.response.writeonly.increased", true),
RESPONSE_WRITEONLY_REQUIRED_DECREASED("incompatible.response.writeonly.required.decreased", true),
SECURITY_REQUIREMENT_SCHEMES_INCREASED(
"incompatible.security.requirement.schemes.increased", true),
SECURITY_SCHEME_BEARER_FORMAT_CHANGED("incompatible.security.scheme.bearer.format.changed", true),
SECURITY_SCHEME_OPENIDCONNECT_URL_CHANGED(
"incompatible.security.scheme.openidconnect.url.changed", true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openapitools.openapidiff.core.model;

import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.SECURITY_REQUIREMENT_SCHEMES_INCREASED;

import io.swagger.v3.oas.models.security.SecurityRequirement;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -8,14 +10,18 @@
public class ChangedSecurityRequirement implements ComposedChanged {
private SecurityRequirement oldSecurityRequirement;
private SecurityRequirement newSecurityRequirement;
private final DiffContext context;
private SecurityRequirement missing;
private SecurityRequirement increased;
private List<ChangedSecurityScheme> changed;

public ChangedSecurityRequirement(
SecurityRequirement oldSecurityRequirement, SecurityRequirement newSecurityRequirement) {
SecurityRequirement oldSecurityRequirement,
SecurityRequirement newSecurityRequirement,
DiffContext context) {
this.oldSecurityRequirement = oldSecurityRequirement;
this.newSecurityRequirement = newSecurityRequirement;
this.context = context;
this.changed = new ArrayList<>();
}

Expand All @@ -29,10 +35,12 @@ public DiffResult isCoreChanged() {
if (increased == null && missing == null) {
return DiffResult.NO_CHANGES;
}
if (increased == null) {
return DiffResult.COMPATIBLE;
if (increased != null) {
if (SECURITY_REQUIREMENT_SCHEMES_INCREASED.enabled(context)) {
return DiffResult.INCOMPATIBLE;
}
}
return DiffResult.INCOMPATIBLE;
return DiffResult.COMPATIBLE;
}

public void addMissing(String key, List<String> scopes) {
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.*;
import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.SECURITY_REQUIREMENT_SCHEMES_INCREASED;

import org.junit.jupiter.api.Test;
import org.openapitools.openapidiff.core.model.BackwardIncompatibleProp;

public class SecurityRequirementBCTest {
private final String BASE = "bc_security_requirement_base.yaml";
Expand All @@ -19,6 +21,7 @@ public void changedButCompatible() {

@Test
public void schemesIncreased() {
assertOpenApiBackwardIncompatible(BASE, "bc_security_requirement_schemes_increased.yaml");
BackwardIncompatibleProp prop = SECURITY_REQUIREMENT_SCHEMES_INCREASED;
assertSpecIncompatible(BASE, "bc_security_requirement_schemes_increased.yaml", prop);
}
}