@@ -203,13 +203,23 @@ protected String oneOfSchema(int deepness, ChangedOneOfSchema schema, String dis
203203 .forEach (key -> sb .append (format ("%sDeleted '%s' %s\n " , indent (deepness ), key , discriminator )));
204204 schema .getIncreasedMapping ().forEach ((key , sub ) ->
205205 sb .append (format ("%sAdded '%s' %s:\n " , indent (deepness ), key , discriminator ))
206- .append (schema (deepness , sub )));
206+ .append (schema (deepness , sub , schema . getContext () )));
207207 schema .getChangedMapping ().forEach ((key , sub ) ->
208208 sb .append (format ("%sUpdated `%s` %s:\n " , indent (deepness ), key , discriminator ))
209209 .append (schema (deepness , sub )));
210210 return sb .toString ();
211211 }
212212
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+
213223 protected String schema (int deepness , ChangedSchema schema ) {
214224 StringBuilder sb = new StringBuilder ("" );
215225 if (schema .isDiscriminatorPropertyChanged ()) {
@@ -220,58 +230,62 @@ protected String schema(int deepness, ChangedSchema schema) {
220230 schema .getNewSchema ().getDiscriminator ().getPropertyName () : "" ;
221231 sb .append (oneOfSchema (deepness , schema .getChangedOneOfSchema (), discriminator ));
222232 }
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+ }
223237 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 () ));
226240 schema .getChangedProperties ().forEach ((name , property ) -> sb .append (property (deepness , name , property )));
227241 return sb .toString ();
228242 }
229243
230- protected String schema (int deepness , ComposedSchema schema ) {
244+ protected String schema (int deepness , ComposedSchema schema , DiffContext context ) {
231245 StringBuilder sb = new StringBuilder ("" );
232246 if (schema .getAllOf () != null && schema .getAllOf () != null ) {
233247 LOGGER .debug ("All of schema" );
234248 schema .getAllOf ().stream ()
235249 .map (this ::resolve )
236- .forEach (composedChild -> sb .append (schema (deepness , composedChild )));
250+ .forEach (composedChild -> sb .append (schema (deepness , composedChild , context )));
237251 }
238252 if (schema .getOneOf () != null && schema .getOneOf () != null ) {
239253 LOGGER .debug ("One of schema" );
240254 sb .append (format ("%sOne of:\n \n " , indent (deepness )));
241255 schema .getOneOf ().stream ()
242256 .map (this ::resolve )
243- .forEach (composedChild -> sb .append (schema (deepness + 1 , composedChild )));
257+ .forEach (composedChild -> sb .append (schema (deepness + 1 , composedChild , context )));
244258 }
245259 return sb .toString ();
246260 }
247261
248- protected String schema (int deepness , Schema schema ) {
262+ protected String schema (int deepness , Schema schema , DiffContext context ) {
249263 StringBuilder sb = new StringBuilder ("" );
250264 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 ));
252266 if (schema instanceof ComposedSchema ) {
253- sb .append (schema (deepness , (ComposedSchema ) schema ));
267+ sb .append (schema (deepness , (ComposedSchema ) schema , context ));
254268 } else if (schema instanceof ArraySchema ) {
255- sb .append (items (deepness , resolve (((ArraySchema ) schema ).getItems ())));
269+ sb .append (items (deepness , resolve (((ArraySchema ) schema ).getItems ()), context ));
256270 }
257271 return sb .toString ();
258272 }
259273
260- protected String items (int deepness , Schema schema ) {
274+ protected String items (int deepness , Schema schema , DiffContext context ) {
261275 StringBuilder sb = new StringBuilder ("" );
262276 sb .append (format ("%sItems (%s)%s\n " , indent (deepness ), type (schema ), Arrays .asList ("object" , "array" ).contains (type (schema )) ? " :\n " : "" ));
263277 description (indent (deepness + 1 ), schema .getDescription ());
264- sb .append (schema (deepness , schema ));
278+ sb .append (schema (deepness , schema , context ));
265279 return sb .toString ();
266280 }
267281
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 ) {
269283 StringBuilder sb = new StringBuilder ("" );
270284 if (properties != null ) {
271285 properties .forEach ((key , value ) -> {
272286 sb .append (property (deepness , title , key , resolve (value )));
273287 if (showContent ) {
274- sb .append (schema (deepness + 1 , resolve (value )));
288+ sb .append (schema (deepness + 1 , resolve (value ), context ));
275289 }
276290 });
277291 }
0 commit comments