|
15 | 15 | import org.slf4j.Logger;
|
16 | 16 | import org.slf4j.LoggerFactory;
|
17 | 17 |
|
18 |
| -import java.util.Arrays; |
19 | 18 | import java.util.List;
|
20 | 19 | import java.util.Map;
|
21 | 20 |
|
@@ -234,6 +233,9 @@ protected String schema(int deepness, ChangedSchema schema) {
|
234 | 233 | sb.append(required(deepness, "New required properties", schema.getChangeRequired().getIncreased()));
|
235 | 234 | sb.append(required(deepness, "New optional properties", schema.getChangeRequired().getMissing()));
|
236 | 235 | }
|
| 236 | + if (schema.getChangedItems() != null) { |
| 237 | + sb.append(items(deepness, schema.getChangedItems())); |
| 238 | + } |
237 | 239 | sb.append(listDiff(deepness, "enum", schema.getChangeEnum()));
|
238 | 240 | sb.append(properties(deepness, "Added property", schema.getIncreasedProperties(), true, schema.getContext()));
|
239 | 241 | sb.append(properties(deepness, "Deleted property", schema.getMissingProperties(), false, schema.getContext()));
|
@@ -271,14 +273,27 @@ protected String schema(int deepness, Schema schema, DiffContext context) {
|
271 | 273 | return sb.toString();
|
272 | 274 | }
|
273 | 275 |
|
274 |
| - protected String items(int deepness, Schema schema, DiffContext context) { |
| 276 | + protected String items(int deepness, ChangedSchema schema) { |
275 | 277 | StringBuilder sb = new StringBuilder("");
|
276 |
| - sb.append(format("%sItems (%s)%s\n", indent(deepness), type(schema), Arrays.asList("object", "array").contains(type(schema)) ? " :\n" : "")); |
277 |
| - description(indent(deepness + 1), schema.getDescription()); |
278 |
| - sb.append(schema(deepness, schema, context)); |
| 278 | + String type = type(schema.getNewSchema()); |
| 279 | + if (schema.isChangedType()) { |
| 280 | + type = type(schema.getOldSchema()) + " -> " + type(schema.getNewSchema()); |
| 281 | + } |
| 282 | + sb.append(items(deepness, "Changed items", type, schema.getNewSchema().getDescription())); |
| 283 | + sb.append(schema(deepness, schema)); |
279 | 284 | return sb.toString();
|
280 | 285 | }
|
281 | 286 |
|
| 287 | + protected String items(int deepness, Schema schema, DiffContext context) { |
| 288 | + return items(deepness, "Items", type(schema), schema.getDescription()) + |
| 289 | + schema(deepness, schema, context); |
| 290 | + } |
| 291 | + |
| 292 | + protected String items(int deepness, String title, String type, String description) { |
| 293 | + return format("%s%s (%s):" + |
| 294 | + "\n%s\n", indent(deepness), title, type, description(indent(deepness + 1), description)); |
| 295 | + } |
| 296 | + |
282 | 297 | protected String properties(final int deepness, String title, Map<String, Schema> properties, boolean showContent, DiffContext context) {
|
283 | 298 | StringBuilder sb = new StringBuilder("");
|
284 | 299 | if (properties != null) {
|
|
0 commit comments