@@ -203,13 +203,23 @@ protected String oneOfSchema(int deepness, ChangedOneOfSchema schema, String dis
203
203
.forEach (key -> sb .append (format ("%sDeleted '%s' %s\n " , indent (deepness ), key , discriminator )));
204
204
schema .getIncreasedMapping ().forEach ((key , sub ) ->
205
205
sb .append (format ("%sAdded '%s' %s:\n " , indent (deepness ), key , discriminator ))
206
- .append (schema (deepness , sub )));
206
+ .append (schema (deepness , sub , schema . getContext () )));
207
207
schema .getChangedMapping ().forEach ((key , sub ) ->
208
208
sb .append (format ("%sUpdated `%s` %s:\n " , indent (deepness ), key , discriminator ))
209
209
.append (schema (deepness , sub )));
210
210
return sb .toString ();
211
211
}
212
212
213
+ protected String required (int deepness , String title , List <String > required ) {
214
+ StringBuilder sb = new StringBuilder ("" );
215
+ if (required .size () > 0 ) {
216
+ sb .append (format ("%s%s:\n " , indent (deepness ), title ));
217
+ required .forEach (s -> sb .append (format ("%s- `%s`\n " , indent (deepness ), s )));
218
+ sb .append ("\n " );
219
+ }
220
+ return sb .toString ();
221
+ }
222
+
213
223
protected String schema (int deepness , ChangedSchema schema ) {
214
224
StringBuilder sb = new StringBuilder ("" );
215
225
if (schema .isDiscriminatorPropertyChanged ()) {
@@ -220,58 +230,62 @@ protected String schema(int deepness, ChangedSchema schema) {
220
230
schema .getNewSchema ().getDiscriminator ().getPropertyName () : "" ;
221
231
sb .append (oneOfSchema (deepness , schema .getChangedOneOfSchema (), discriminator ));
222
232
}
233
+ if (schema .getChangeRequired () != null ) {
234
+ sb .append (required (deepness , "New required properties" , schema .getChangeRequired ().getIncreased ()));
235
+ sb .append (required (deepness , "New optional properties" , schema .getChangeRequired ().getMissing ()));
236
+ }
223
237
sb .append (listDiff (deepness , "enum" , schema .getChangeEnum ()));
224
- sb .append (properties (deepness , "Added property" , schema .getIncreasedProperties (), true ));
225
- sb .append (properties (deepness , "Deleted property" , schema .getMissingProperties (), false ));
238
+ sb .append (properties (deepness , "Added property" , schema .getIncreasedProperties (), true , schema . getContext () ));
239
+ sb .append (properties (deepness , "Deleted property" , schema .getMissingProperties (), false , schema . getContext () ));
226
240
schema .getChangedProperties ().forEach ((name , property ) -> sb .append (property (deepness , name , property )));
227
241
return sb .toString ();
228
242
}
229
243
230
- protected String schema (int deepness , ComposedSchema schema ) {
244
+ protected String schema (int deepness , ComposedSchema schema , DiffContext context ) {
231
245
StringBuilder sb = new StringBuilder ("" );
232
246
if (schema .getAllOf () != null && schema .getAllOf () != null ) {
233
247
LOGGER .debug ("All of schema" );
234
248
schema .getAllOf ().stream ()
235
249
.map (this ::resolve )
236
- .forEach (composedChild -> sb .append (schema (deepness , composedChild )));
250
+ .forEach (composedChild -> sb .append (schema (deepness , composedChild , context )));
237
251
}
238
252
if (schema .getOneOf () != null && schema .getOneOf () != null ) {
239
253
LOGGER .debug ("One of schema" );
240
254
sb .append (format ("%sOne of:\n \n " , indent (deepness )));
241
255
schema .getOneOf ().stream ()
242
256
.map (this ::resolve )
243
- .forEach (composedChild -> sb .append (schema (deepness + 1 , composedChild )));
257
+ .forEach (composedChild -> sb .append (schema (deepness + 1 , composedChild , context )));
244
258
}
245
259
return sb .toString ();
246
260
}
247
261
248
- protected String schema (int deepness , Schema schema ) {
262
+ protected String schema (int deepness , Schema schema , DiffContext context ) {
249
263
StringBuilder sb = new StringBuilder ("" );
250
264
sb .append (listItem (deepness , "Enum" , schema .getEnum ()));
251
- sb .append (properties (deepness , "Property" , schema .getProperties (), true ));
265
+ sb .append (properties (deepness , "Property" , schema .getProperties (), true , context ));
252
266
if (schema instanceof ComposedSchema ) {
253
- sb .append (schema (deepness , (ComposedSchema ) schema ));
267
+ sb .append (schema (deepness , (ComposedSchema ) schema , context ));
254
268
} else if (schema instanceof ArraySchema ) {
255
- sb .append (items (deepness , resolve (((ArraySchema ) schema ).getItems ())));
269
+ sb .append (items (deepness , resolve (((ArraySchema ) schema ).getItems ()), context ));
256
270
}
257
271
return sb .toString ();
258
272
}
259
273
260
- protected String items (int deepness , Schema schema ) {
274
+ protected String items (int deepness , Schema schema , DiffContext context ) {
261
275
StringBuilder sb = new StringBuilder ("" );
262
276
sb .append (format ("%sItems (%s)%s\n " , indent (deepness ), type (schema ), Arrays .asList ("object" , "array" ).contains (type (schema )) ? " :\n " : "" ));
263
277
description (indent (deepness + 1 ), schema .getDescription ());
264
- sb .append (schema (deepness , schema ));
278
+ sb .append (schema (deepness , schema , context ));
265
279
return sb .toString ();
266
280
}
267
281
268
- protected String properties (final int deepness , String title , Map <String , Schema > properties , boolean showContent ) {
282
+ protected String properties (final int deepness , String title , Map <String , Schema > properties , boolean showContent , DiffContext context ) {
269
283
StringBuilder sb = new StringBuilder ("" );
270
284
if (properties != null ) {
271
285
properties .forEach ((key , value ) -> {
272
286
sb .append (property (deepness , title , key , resolve (value )));
273
287
if (showContent ) {
274
- sb .append (schema (deepness + 1 , resolve (value )));
288
+ sb .append (schema (deepness + 1 , resolve (value ), context ));
275
289
}
276
290
});
277
291
}
0 commit comments