1
1
package com .qdesrame .openapi .diff .model ;
2
2
3
- import com .qdesrame .openapi .diff .model .schema .ChangedReadOnly ;
4
- import com .qdesrame .openapi .diff .model .schema .ChangedWriteOnly ;
3
+ import com .qdesrame .openapi .diff .model .schema .*;
5
4
import io .swagger .v3 .oas .models .media .Schema ;
6
5
import java .util .LinkedHashMap ;
7
6
import java .util .List ;
11
10
import lombok .Getter ;
12
11
import lombok .Setter ;
13
12
import lombok .experimental .Accessors ;
14
- import org .apache .commons .collections4 .CollectionUtils ;
15
13
16
14
/** Created by adarsh.sharma on 22/12/17. */
17
15
@ Getter
@@ -28,14 +26,14 @@ public class ChangedSchema implements ComposedChanged {
28
26
protected boolean changeDeprecated ;
29
27
protected ChangedMetadata description ;
30
28
protected boolean changeTitle ;
31
- protected ListDiff < String > changeRequired ;
29
+ protected ChangedRequired required ;
32
30
protected boolean changeDefault ;
33
- protected ListDiff changeEnum ;
31
+ protected ChangedEnum <?> enumeration ;
34
32
protected boolean changeFormat ;
35
33
protected ChangedReadOnly readOnly ;
36
34
protected ChangedWriteOnly writeOnly ;
37
35
protected boolean changedType ;
38
- protected boolean changedMaxLength ;
36
+ protected ChangedMaxLength maxLength ;
39
37
protected boolean discriminatorPropertyChanged ;
40
38
protected ChangedSchema items ;
41
39
protected ChangedOneOfSchema oneOfSchema ;
@@ -52,43 +50,35 @@ public ChangedSchema() {
52
50
public List <Changed > getChangedElements () {
53
51
return Stream .concat (
54
52
changedProperties .values ().stream (),
55
- Stream .of (description , readOnly , writeOnly , items , oneOfSchema , addProp , extensions ))
53
+ Stream .of (
54
+ description ,
55
+ readOnly ,
56
+ writeOnly ,
57
+ items ,
58
+ oneOfSchema ,
59
+ addProp ,
60
+ enumeration ,
61
+ required ,
62
+ maxLength ,
63
+ extensions ))
56
64
.collect (Collectors .toList ());
57
65
}
58
66
59
67
@ Override
60
68
public DiffResult isCoreChanged () {
61
69
if (!changedType
62
70
&& (oldSchema == null && newSchema == null || oldSchema != null && newSchema != null )
63
- && !changedMaxLength
64
- && (changeEnum == null || changeEnum .isUnchanged ())
65
71
&& !changeFormat
66
72
&& increasedProperties .size () == 0
67
73
&& missingProperties .size () == 0
68
74
&& changedProperties .values ().size () == 0
69
75
&& !changeDeprecated
70
- && (changeRequired == null || changeRequired .isUnchanged ())
71
76
&& !discriminatorPropertyChanged ) {
72
77
return DiffResult .NO_CHANGES ;
73
78
}
74
- boolean compatibleForRequest =
75
- (changeEnum == null || changeEnum .getMissing ().isEmpty ())
76
- && (changeRequired == null || CollectionUtils .isEmpty (changeRequired .getIncreased ()))
77
- && (oldSchema != null || newSchema == null )
78
- && (!changedMaxLength
79
- || newSchema .getMaxLength () == null
80
- || (oldSchema .getMaxLength () != null
81
- && oldSchema .getMaxLength () <= newSchema .getMaxLength ()));
82
-
79
+ boolean compatibleForRequest = (oldSchema != null || newSchema == null );
83
80
boolean compatibleForResponse =
84
- (changeEnum == null || changeEnum .getIncreased ().isEmpty ())
85
- && (changeRequired == null || CollectionUtils .isEmpty (changeRequired .getMissing ()))
86
- && missingProperties .isEmpty ()
87
- && (oldSchema == null || newSchema != null )
88
- && (!changedMaxLength
89
- || oldSchema .getMaxLength () == null
90
- || (newSchema .getMaxLength () != null
91
- && newSchema .getMaxLength () <= oldSchema .getMaxLength ()));
81
+ missingProperties .isEmpty () && (oldSchema == null || newSchema != null );
92
82
if ((context .isRequest () && compatibleForRequest
93
83
|| context .isResponse () && compatibleForResponse )
94
84
&& !changedType
0 commit comments