Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ChangedMaxItems(Integer oldValue, Integer newValue, DiffContext context)

@Override
public DiffResult isChanged() {
if (oldValue == null && newValue == null) {
if (oldValue == newValue) {
return DiffResult.NO_CHANGES;
}
if (oldValue == null || newValue == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ChangedMinItems(Integer oldValue, Integer newValue, DiffContext context)

@Override
public DiffResult isChanged() {
if (oldValue == null && newValue == null) {
if (oldValue == newValue) {
return DiffResult.NO_CHANGES;
}
if (oldValue == null || newValue == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void changeMultipleOfHandling() {
assertThat(props.get("field4").getMultipleOf().getRight()).isNull();
}

@Test // issues #480
@Test // issues #480 and #779
public void changeMinMaxItemsHandling() {
ChangedOpenApi changedOpenApi =
OpenApiCompare.fromLocations(
Expand All @@ -158,6 +158,9 @@ public void changeMinMaxItemsHandling() {
Map<String, ChangedSchema> props = changedSchema.getChangedProperties();
assertThat(props).isNotEmpty();

// Check no changes in minItems and maxItems
assertThat(props.get("field0")).isNull();

// Check increasing of minItems
assertThat(props.get("field1").getMinItems().isIncompatible()).isTrue();
assertThat(props.get("field1").getMinItems().getOldValue()).isEqualTo(1);
Expand All @@ -177,6 +180,26 @@ public void changeMinMaxItemsHandling() {
assertThat(props.get("field4").getMaxItems().isIncompatible()).isTrue();
assertThat(props.get("field4").getMaxItems().getOldValue()).isEqualTo(100);
assertThat(props.get("field4").getMaxItems().getNewValue()).isEqualTo(90);

// Check removal of minItems
assertThat(props.get("field5").getMinItems().isCompatible()).isTrue();
assertThat(props.get("field5").getMinItems().getOldValue()).isEqualTo(1);
assertThat(props.get("field5").getMinItems().getNewValue()).isNull();

// Check removal of maxItems
assertThat(props.get("field5").getMaxItems().isCompatible()).isTrue();
assertThat(props.get("field5").getMaxItems().getOldValue()).isEqualTo(100);
assertThat(props.get("field5").getMaxItems().getNewValue()).isNull();

// Check addition of minItems
assertThat(props.get("field6").getMinItems().isCompatible()).isTrue();
assertThat(props.get("field6").getMinItems().getOldValue()).isNull();
assertThat(props.get("field6").getMinItems().getNewValue()).isEqualTo(1);

// Check addition of maxItems
assertThat(props.get("field6").getMaxItems().isCompatible()).isTrue();
assertThat(props.get("field6").getMaxItems().getOldValue()).isNull();
assertThat(props.get("field6").getMaxItems().getNewValue()).isEqualTo(100);
}

@Test // issue #482
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ components:
TestDTO:
type: object
properties:
field0:
type: array
items:
type: string
minItems: 1
maxItems: 10
field1:
type: array
items:
Expand All @@ -33,10 +39,20 @@ components:
items:
type: string
minItems: 1
maxItems: 90
maxItems: 90
field4:
type: array
items:
type: string
minItems: 1
maxItems: 100
field5:
type: array
items:
type: string
minItems: 1
maxItems: 100
field6:
type: array
items:
type: string
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ components:
TestDTO:
type: object
properties:
field0:
type: array
items:
type: string
minItems: 1
maxItems: 10
field1:
type: array
items:
Expand All @@ -27,16 +33,26 @@ components:
items:
type: string
minItems: 10
maxItems: 100
maxItems: 100
field3:
type: array
items:
type: string
minItems: 1
maxItems: 100
maxItems: 100
field4:
type: array
items:
type: string
minItems: 1
maxItems: 90
field5:
type: array
items:
type: string
field6:
type: array
items:
type: string
minItems: 1
maxItems: 100