@@ -24,14 +24,41 @@ Compare two OpenAPI specifications(3.x) and render the difference to html file o
24
24
25
25
# Usage
26
26
OpenDiff can read swagger api spec from json file or http.
27
+
28
+ ## Command Line
29
+
30
+ ``` bash
31
+ $ openapi-diff --help
32
+ usage: openapi-diff < old> < new>
33
+ --debug Print debugging information
34
+ --error Print error information
35
+ -h,--help print this message
36
+ --header < property=value> use given header for authorisation
37
+ --html < file> export diff as html in given file
38
+ --info Print additional information
39
+ -l,--log < level> use given level for log (TRACE, DEBUG,
40
+ INFO, WARN, ERROR, OFF). Default: ERROR
41
+ --markdown < file> export diff as markdown in given file
42
+ -o,--output < format=file> use given format (html, markdown) for
43
+ output in file
44
+ --off No information printed
45
+ --query < property=value> use query param for authorisation
46
+ --trace be extra verbose
47
+ --version print the version information and exit
48
+ --warn Print warning information
49
+ ```
50
+
51
+ ## Direct Invocation
52
+
27
53
``` java
28
54
final String OPENAPI_V3_DOC1 = " petstore_v3_1.json" ;
29
55
final String OPENAPI_V3_DOC2 = " http://petstore.swagger.io/v2/swagger.json" ;
30
56
31
57
SwaggerDiff diff = OpenApiDiff . compare(SWAGGER_V3_DOC1 , SWAGGER_V3_DOC2 );
32
58
```
33
59
34
- # Render difference
60
+ ### Render difference
61
+ ---
35
62
#### HTML
36
63
``` java
37
64
String html = new HtmlRender (" Changelog" ,
@@ -62,58 +89,177 @@ try {
62
89
e. printStackTrace();
63
90
}
64
91
```
92
+
93
+ # Example
94
+ ### CLI Output
95
+
96
+ ``` text
97
+ ==========================================================================
98
+ == API CHANGE LOG ==
99
+ ==========================================================================
100
+ Swagger Petstore
101
+ --------------------------------------------------------------------------
102
+ -- What's New --
103
+ --------------------------------------------------------------------------
104
+ - GET /pet/{petId}
105
+
106
+ --------------------------------------------------------------------------
107
+ -- What's Deleted --
108
+ --------------------------------------------------------------------------
109
+ - POST /pet/{petId}
110
+
111
+ --------------------------------------------------------------------------
112
+ -- What's Deprecated --
113
+ --------------------------------------------------------------------------
114
+ - GET /user/logout
115
+
116
+ --------------------------------------------------------------------------
117
+ -- What's Changed --
118
+ --------------------------------------------------------------------------
119
+ - PUT /pet
120
+ Request:
121
+ - Deleted application/xml
122
+ - Changed application/json
123
+ Schema: Backward compatible
124
+ - POST /pet
125
+ Parameter:
126
+ - Add tags in query
127
+ Request:
128
+ - Changed application/xml
129
+ Schema: Backward compatible
130
+ - Changed application/json
131
+ Schema: Backward compatible
132
+ - GET /pet/findByStatus
133
+ Parameter:
134
+ - Deprecated status in query
135
+ Return Type:
136
+ - Changed 200 OK
137
+ Media types:
138
+ - Changed application/xml
139
+ Schema: Broken compatibility
140
+ - Changed application/json
141
+ Schema: Broken compatibility
142
+ - GET /pet/findByTags
143
+ Return Type:
144
+ - Changed 200 OK
145
+ Media types:
146
+ - Changed application/xml
147
+ Schema: Broken compatibility
148
+ - Changed application/json
149
+ Schema: Broken compatibility
150
+ - DELETE /pet/{petId}
151
+ Parameter:
152
+ - Add newHeaderParam in header
153
+ - POST /pet/{petId}/uploadImage
154
+ Parameter:
155
+ - Changed petId in path
156
+ - POST /user
157
+ Request:
158
+ - Changed application/json
159
+ Schema: Backward compatible
160
+ - POST /user/createWithArray
161
+ Request:
162
+ - Changed application/json
163
+ Schema: Backward compatible
164
+ - POST /user/createWithList
165
+ Request:
166
+ - Changed application/json
167
+ Schema: Backward compatible
168
+ - GET /user/login
169
+ Parameter:
170
+ - Delete password in query
171
+ - GET /user/logout
172
+ - GET /user/{username}
173
+ Return Type:
174
+ - Changed 200 OK
175
+ Media types:
176
+ - Changed application/xml
177
+ Schema: Broken compatibility
178
+ - Changed application/json
179
+ Schema: Broken compatibility
180
+ - PUT /user/{username}
181
+ Request:
182
+ - Changed application/json
183
+ Schema: Backward compatible
184
+ --------------------------------------------------------------------------
185
+ -- Result --
186
+ --------------------------------------------------------------------------
187
+ API changes broke backward compatibility
188
+ --------------------------------------------------------------------------
189
+ ```
190
+
191
+ ### Markdown
65
192
``` markdown
66
193
### What's New
67
194
---
68
195
* `GET` /pet/{petId} Find pet by ID
69
196
70
- ### What's Deprecated
197
+ ### What's Deleted
71
198
---
72
199
* `POST` /pet/{petId} Updates a pet in the store with form data
73
200
201
+ ### What's Deprecated
202
+ ---
203
+ * `GET` /user/logout Logs out current logged in user session
204
+
74
205
### What's Changed
75
206
---
76
207
* `PUT` /pet Update an existing pet
77
- Parameter
208
+ Request
78
209
79
- Add body.newField //a field demo
80
- Add body.category.newCatField
81
- Delete body.category.name
210
+ Deleted request body : [application/xml]
211
+ Changed response : [application/json]
82
212
* `POST` /pet Add a new pet to the store
83
213
Parameter
84
214
85
215
Add tags //add new query param demo
86
- Add body.newField //a field demo
87
- Add body.category.newCatField
88
- Delete body.category.name
216
+ Request
217
+
218
+ Changed response : [application/xml]
219
+ Changed response : [application/json]
220
+ * `GET` /pet/findByStatus Finds Pets by status
221
+ Parameter
222
+
223
+ Return Type
224
+
225
+ Changed response : [200] //successful operation
226
+ * `GET` /pet/findByTags Finds Pets by tags
227
+ Return Type
228
+
229
+ Changed response : [200] //successful operation
89
230
* `DELETE` /pet/{petId} Deletes a pet
90
231
Parameter
91
232
92
233
Add newHeaderParam
93
234
* `POST` /pet/{petId}/uploadImage uploads an image for pet
94
235
Parameter
95
236
96
- petId change into not required Notes ID of pet to update change into ID of pet to update, default false
237
+ petId Notes ID of pet to update change into ID of pet to update, default false
97
238
* `POST` /user Create user
98
- Parameter
239
+ Request
99
240
100
- Add body.newUserFeild //a new user feild demo
101
- Delete body.phone
241
+ Changed response : [application/json]
242
+ * `POST` /user/createWithArray Creates list of users with given input array
243
+ Request
244
+
245
+ Changed response : [application/json]
246
+ * `POST` /user/createWithList Creates list of users with given input array
247
+ Request
248
+
249
+ Changed response : [application/json]
102
250
* `GET` /user/login Logs user into the system
103
251
Parameter
104
252
105
253
Delete password //The password for login in clear text
106
- * `GET` /user/{username} Get user by user name
107
- Return Type
108
-
109
- Add newUserFeild //a new user feild demo
110
- Delete phone
254
+ * `GET` /user/logout Logs out current logged in user session
111
255
* `PUT` /user/{username} Updated user
112
- Parameter
256
+ Request
113
257
114
- Add body.newUserFeild //a new user feild demo
115
- Delete body.phone
258
+ Changed response : [application/json]
259
+ * `GET` /user/{username} Get user by user name
260
+ Return Type
116
261
262
+ Changed response : [200] //successful operation
117
263
```
118
264
119
265
# License
0 commit comments