Skip to content

Commit 53fa192

Browse files
committed
feat: Test adding or removing property
1 parent 75fbcd5 commit 53fa192

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedMaxItems.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public DiffResult isChanged() {
2020
if (oldValue == newValue) {
2121
return DiffResult.NO_CHANGES;
2222
}
23-
if (oldValue == null && newValue == null) {
24-
return DiffResult.NO_CHANGES;
25-
}
2623
if (oldValue == null || newValue == null) {
2724
return DiffResult.COMPATIBLE;
2825
}

core/src/main/java/org/openapitools/openapidiff/core/model/schema/ChangedMinItems.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public DiffResult isChanged() {
2020
if (oldValue == newValue) {
2121
return DiffResult.NO_CHANGES;
2222
}
23-
if (oldValue == null && newValue == null) {
24-
return DiffResult.NO_CHANGES;
25-
}
2623
if (oldValue == null || newValue == null) {
2724
return DiffResult.COMPATIBLE;
2825
}

core/src/test/java/org/openapitools/openapidiff/core/SchemaDiffTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ public void changeMinMaxItemsHandling() {
180180
assertThat(props.get("field4").getMaxItems().isIncompatible()).isTrue();
181181
assertThat(props.get("field4").getMaxItems().getOldValue()).isEqualTo(100);
182182
assertThat(props.get("field4").getMaxItems().getNewValue()).isEqualTo(90);
183+
184+
// Check removal of minItems
185+
assertThat(props.get("field5").getMinItems().isCompatible()).isTrue();
186+
assertThat(props.get("field5").getMinItems().getOldValue()).isEqualTo(1);
187+
assertThat(props.get("field5").getMinItems().getNewValue()).isNull();
188+
189+
// Check removal of maxItems
190+
assertThat(props.get("field5").getMaxItems().isCompatible()).isTrue();
191+
assertThat(props.get("field5").getMaxItems().getOldValue()).isEqualTo(100);
192+
assertThat(props.get("field5").getMaxItems().getNewValue()).isNull();
193+
194+
// Check addition of minItems
195+
assertThat(props.get("field6").getMinItems().isCompatible()).isTrue();
196+
assertThat(props.get("field6").getMinItems().getOldValue()).isNull();
197+
assertThat(props.get("field6").getMinItems().getNewValue()).isEqualTo(1);
198+
199+
// Check addition of maxItems
200+
assertThat(props.get("field6").getMaxItems().isCompatible()).isTrue();
201+
assertThat(props.get("field6").getMaxItems().getOldValue()).isNull();
202+
assertThat(props.get("field6").getMaxItems().getNewValue()).isEqualTo(100);
183203
}
184204

185205
@Test // issue #482

core/src/test/resources/schemaDiff/schema-min-max-items-diff-1.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ components:
4646
type: string
4747
minItems: 1
4848
maxItems: 100
49+
field5:
50+
type: array
51+
items:
52+
type: string
53+
minItems: 1
54+
maxItems: 100
55+
field6:
56+
type: array
57+
items:
58+
type: string

core/src/test/resources/schemaDiff/schema-min-max-items-diff-2.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,13 @@ components:
4646
type: string
4747
minItems: 1
4848
maxItems: 90
49+
field5:
50+
type: array
51+
items:
52+
type: string
53+
field6:
54+
type: array
55+
items:
56+
type: string
57+
minItems: 1
58+
maxItems: 100

0 commit comments

Comments
 (0)