File tree 4 files changed +69
-0
lines changed
main/java/org/openapitools/openapidiff/core/model
java/org/openapitools/openapidiff/core
4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ private DiffResult calculateCoreChanged() {
136
136
if (!changedType
137
137
&& (oldSchema == null && newSchema == null || oldSchema != null && newSchema != null )
138
138
&& !changeFormat
139
+ && !changeDefault
139
140
&& increasedProperties .isEmpty ()
140
141
&& missingProperties .isEmpty ()
141
142
&& changedProperties .values ().isEmpty ()
Original file line number Diff line number Diff line change
1
+ package org .openapitools .openapidiff .core ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
5
+
6
+ import org .junit .jupiter .api .Test ;
7
+ import org .openapitools .openapidiff .core .model .ChangedOpenApi ;
8
+ import org .openapitools .openapidiff .core .model .ChangedSchema ;
9
+
10
+ public class SchemaDefaultsTest {
11
+
12
+ @ Test
13
+ public void issue717DefaultsInSchema () {
14
+ ChangedOpenApi changedOpenApi =
15
+ OpenApiCompare .fromLocations (
16
+ "issue-717-schema-defaults-handling-1.yaml" ,
17
+ "issue-717-schema-defaults-handling-2.yaml" );
18
+
19
+ assertEquals (1 , changedOpenApi .getChangedOperations ().size ());
20
+ assertEquals (1 , changedOpenApi .getChangedSchemas ().size ());
21
+ ChangedSchema changedSchema = changedOpenApi .getChangedSchemas ().get (0 );
22
+ assertEquals (1 , changedSchema .getChangedProperties ().size ());
23
+ assertTrue (changedSchema .getChangedProperties ().containsKey ("field1" ));
24
+ assertTrue (changedSchema .getChangedProperties ().get ("field1" ).isChangeDefault ());
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ openapi : 3.1.0
2
+ info :
3
+ description : Schema defaults handling
4
+ title : defaults
5
+ version : 1.0.0
6
+ paths :
7
+ /defaults/property-schema/ :
8
+ post :
9
+ requestBody :
10
+ content :
11
+ application/json :
12
+ schema :
13
+ $ref : ' #/components/schemas/TestDTO'
14
+ components :
15
+ schemas :
16
+ TestDTO :
17
+ type : object
18
+ properties :
19
+ field1 :
20
+ default : default value
21
+ type : string
Original file line number Diff line number Diff line change
1
+ openapi : 3.1.0
2
+ info :
3
+ description : Schema defaults handling
4
+ title : defaults
5
+ version : 1.0.0
6
+ paths :
7
+ /defaults/property-schema/ :
8
+ post :
9
+ requestBody :
10
+ content :
11
+ application/json :
12
+ schema :
13
+ $ref : ' #/components/schemas/TestDTO'
14
+ components :
15
+ schemas :
16
+ TestDTO :
17
+ type : object
18
+ properties :
19
+ field1 :
20
+ default : default value updated
21
+ type : string
You can’t perform that action at this time.
0 commit comments