File tree 3 files changed +10
-4
lines changed
main/java/org/openapitools/openapidiff/core/model
java/org/openapitools/openapidiff/core
3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -137,8 +137,13 @@ private DiffResult calculateCoreChanged() {
137
137
&& !discriminatorPropertyChanged ) {
138
138
return DiffResult .NO_CHANGES ;
139
139
}
140
+ boolean missingRequiredProperties =
141
+ oldSchema != null
142
+ && oldSchema .getRequired () != null
143
+ && missingProperties .keySet ().stream ()
144
+ .anyMatch (missingProperty -> oldSchema .getRequired ().contains (missingProperty ));
140
145
boolean compatibleForResponse =
141
- missingProperties . isEmpty () && (oldSchema == null || newSchema != null );
146
+ ! missingRequiredProperties && (oldSchema == null || newSchema != null );
142
147
if ((context .isRequest () && compatibleForRequest ()
143
148
|| context .isResponse () && compatibleForResponse )
144
149
&& !changedType
Original file line number Diff line number Diff line change 1
1
package org .openapitools .openapidiff .core ;
2
2
3
3
import static org .openapitools .openapidiff .core .TestUtils .assertOpenApiAreEquals ;
4
- import static org .openapitools .openapidiff .core .TestUtils .assertOpenApiBackwardIncompatible ;
4
+ import static org .openapitools .openapidiff .core .TestUtils .assertOpenApiBackwardCompatible ;
5
5
6
6
import org .junit .jupiter .api .Test ;
7
7
@@ -16,6 +16,6 @@ public void testDiffSame() {
16
16
17
17
@ Test
18
18
public void testDiffDifferent () {
19
- assertOpenApiBackwardIncompatible (OPENAPI_DOC1 , OPENAPI_DOC2 );
19
+ assertOpenApiBackwardCompatible (OPENAPI_DOC1 , OPENAPI_DOC2 , true );
20
20
}
21
21
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ components:
19
19
schemas :
20
20
B :
21
21
type : object
22
+ required : ["message2"]
22
23
properties :
23
24
message :
24
25
type : string
@@ -27,4 +28,4 @@ components:
27
28
details :
28
29
type : array
29
30
items :
30
- $ref : ' #/components/schemas/B'
31
+ $ref : ' #/components/schemas/B'
You can’t perform that action at this time.
0 commit comments