@@ -24,14 +24,41 @@ Compare two OpenAPI specifications(3.x) and render the difference to html file o
2424
2525# Usage
2626OpenDiff 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+
2753``` java
2854final String OPENAPI_V3_DOC1 = " petstore_v3_1.json" ;
2955final String OPENAPI_V3_DOC2 = " http://petstore.swagger.io/v2/swagger.json" ;
3056
3157SwaggerDiff diff = OpenApiDiff . compare(SWAGGER_V3_DOC1 , SWAGGER_V3_DOC2 );
3258```
3359
34- # Render difference
60+ ### Render difference
61+ ---
3562#### HTML
3663``` java
3764String html = new HtmlRender (" Changelog" ,
@@ -62,58 +89,177 @@ try {
6289 e. printStackTrace();
6390}
6491```
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
65192``` markdown
66193### What's New
67194---
68195* `GET` /pet/{petId} Find pet by ID
69196
70- ### What's Deprecated
197+ ### What's Deleted
71198---
72199* `POST` /pet/{petId} Updates a pet in the store with form data
73200
201+ ### What's Deprecated
202+ ---
203+ * `GET` /user/logout Logs out current logged in user session
204+
74205### What's Changed
75206---
76207* `PUT` /pet Update an existing pet
77- Parameter
208+ Request
78209
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]
82212* `POST` /pet Add a new pet to the store
83213 Parameter
84214
85215 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
89230* `DELETE` /pet/{petId} Deletes a pet
90231 Parameter
91232
92233 Add newHeaderParam
93234* `POST` /pet/{petId}/uploadImage uploads an image for pet
94235 Parameter
95236
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
97238* `POST` /user Create user
98- Parameter
239+ Request
99240
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]
102250* `GET` /user/login Logs user into the system
103251 Parameter
104252
105253 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
111255* `PUT` /user/{username} Updated user
112- Parameter
256+ Request
113257
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
116261
262+ Changed response : [200] //successful operation
117263```
118264
119265# License
0 commit comments