7
7
import java .io .File ;
8
8
import java .util .List ;
9
9
import org .openapitools .openapidiff .core .compare .OpenApiDiff ;
10
+ import org .openapitools .openapidiff .core .compare .OpenApiDiffOptions ;
10
11
import org .openapitools .openapidiff .core .model .ChangedOpenApi ;
11
12
12
13
public class OpenApiCompare {
@@ -40,7 +41,25 @@ public static ChangedOpenApi fromContents(String oldContent, String newContent)
40
41
*/
41
42
public static ChangedOpenApi fromContents (
42
43
String oldContent , String newContent , List <AuthorizationValue > auths ) {
43
- return fromSpecifications (readContent (oldContent , auths ), readContent (newContent , auths ));
44
+ return fromContents (oldContent , newContent , auths , OpenApiDiffOptions .builder ().build ());
45
+ }
46
+
47
+ /**
48
+ * compare two openapi doc
49
+ *
50
+ * @param oldContent old api-doc location:Json or Http
51
+ * @param newContent new api-doc location:Json or Http
52
+ * @param auths
53
+ * @param options
54
+ * @return Comparison result
55
+ */
56
+ public static ChangedOpenApi fromContents (
57
+ String oldContent ,
58
+ String newContent ,
59
+ List <AuthorizationValue > auths ,
60
+ OpenApiDiffOptions options ) {
61
+ return fromSpecifications (
62
+ readContent (oldContent , auths ), readContent (newContent , auths ), options );
44
63
}
45
64
46
65
/**
@@ -64,7 +83,21 @@ public static ChangedOpenApi fromFiles(File oldFile, File newFile) {
64
83
*/
65
84
public static ChangedOpenApi fromFiles (
66
85
File oldFile , File newFile , List <AuthorizationValue > auths ) {
67
- return fromLocations (oldFile .getAbsolutePath (), newFile .getAbsolutePath (), auths );
86
+ return fromFiles (oldFile , newFile , auths , OpenApiDiffOptions .builder ().build ());
87
+ }
88
+
89
+ /**
90
+ * compare two openapi doc
91
+ *
92
+ * @param oldFile old api-doc file
93
+ * @param newFile new api-doc file
94
+ * @param auths
95
+ * @param options
96
+ * @return Comparison result
97
+ */
98
+ public static ChangedOpenApi fromFiles (
99
+ File oldFile , File newFile , List <AuthorizationValue > auths , OpenApiDiffOptions options ) {
100
+ return fromLocations (oldFile .getAbsolutePath (), newFile .getAbsolutePath (), auths , options );
68
101
}
69
102
70
103
/**
@@ -88,7 +121,25 @@ public static ChangedOpenApi fromLocations(String oldLocation, String newLocatio
88
121
*/
89
122
public static ChangedOpenApi fromLocations (
90
123
String oldLocation , String newLocation , List <AuthorizationValue > auths ) {
91
- return fromSpecifications (readLocation (oldLocation , auths ), readLocation (newLocation , auths ));
124
+ return fromLocations (oldLocation , newLocation , auths , OpenApiDiffOptions .builder ().build ());
125
+ }
126
+
127
+ /**
128
+ * compare two openapi doc
129
+ *
130
+ * @param oldLocation old api-doc location (local or http)
131
+ * @param newLocation new api-doc location (local or http)
132
+ * @param auths
133
+ * @param options
134
+ * @return Comparison result
135
+ */
136
+ public static ChangedOpenApi fromLocations (
137
+ String oldLocation ,
138
+ String newLocation ,
139
+ List <AuthorizationValue > auths ,
140
+ OpenApiDiffOptions options ) {
141
+ return fromSpecifications (
142
+ readLocation (oldLocation , auths ), readLocation (newLocation , auths ), options );
92
143
}
93
144
94
145
/**
@@ -99,7 +150,20 @@ public static ChangedOpenApi fromLocations(
99
150
* @return Comparison result
100
151
*/
101
152
public static ChangedOpenApi fromSpecifications (OpenAPI oldSpec , OpenAPI newSpec ) {
102
- return OpenApiDiff .compare (notNull (oldSpec , "old" ), notNull (newSpec , "new" ));
153
+ return fromSpecifications (oldSpec , newSpec , OpenApiDiffOptions .builder ().build ());
154
+ }
155
+
156
+ /**
157
+ * compare two openapi doc
158
+ *
159
+ * @param oldSpec old api-doc specification
160
+ * @param newSpec new api-doc specification
161
+ * @param options
162
+ * @return Comparison result
163
+ */
164
+ public static ChangedOpenApi fromSpecifications (
165
+ OpenAPI oldSpec , OpenAPI newSpec , OpenApiDiffOptions options ) {
166
+ return OpenApiDiff .compare (notNull (oldSpec , "old" ), notNull (newSpec , "new" ), options );
103
167
}
104
168
105
169
private static OpenAPI notNull (OpenAPI spec , String type ) {
0 commit comments