|
8 | 8 | import java.util.List;
|
9 | 9 | import java.util.Map;
|
10 | 10 | import java.util.Optional;
|
| 11 | +import java.util.stream.Collectors; |
11 | 12 | import org.apache.commons.httpclient.HttpStatus;
|
12 | 13 | import org.apache.commons.lang3.StringUtils;
|
13 | 14 |
|
@@ -168,9 +169,54 @@ private String itemContent(
|
168 | 169 | .append("Schema: ")
|
169 | 170 | .append(changedMediaType.isCompatible() ? "Backward compatible" : "Broken compatibility")
|
170 | 171 | .append(System.lineSeparator());
|
| 172 | + if (!changedMediaType.isCompatible()) { |
| 173 | + sb.append(incompatibility(changedMediaType)); |
| 174 | + } |
171 | 175 | return sb.toString();
|
172 | 176 | }
|
173 | 177 |
|
| 178 | + private String incompatibility(ComposedChanged changed) { |
| 179 | + if (changed.isCoreChanged() == DiffResult.INCOMPATIBLE) { |
| 180 | + if (changed instanceof ChangedSchema) { |
| 181 | + ChangedSchema cs = (ChangedSchema) changed; |
| 182 | + |
| 183 | + if (cs.getMissingProperties().size() > 0) { |
| 184 | + return cs.getMissingProperties().keySet().stream().collect(Collectors.joining()); |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + return ""; |
| 189 | + } else { |
| 190 | + if (changed instanceof ChangedSchema) { |
| 191 | + ChangedSchema cs = (ChangedSchema) changed; |
| 192 | + |
| 193 | + return cs.getChangedProperties().keySet().stream().collect(Collectors.joining()) |
| 194 | + + "." |
| 195 | + + cs.getChangedElements().stream() |
| 196 | + .map( |
| 197 | + (c) -> |
| 198 | + c != null && c instanceof ComposedChanged |
| 199 | + ? incompatibility((ComposedChanged) c) |
| 200 | + : "") |
| 201 | + .collect(Collectors.joining()); |
| 202 | + } |
| 203 | + |
| 204 | + StringBuilder sb = new StringBuilder(); |
| 205 | + for (Changed child : changed.getChangedElements()) { |
| 206 | + if (child instanceof ComposedChanged) { |
| 207 | + String childIncompatibility = incompatibility((ComposedChanged) child); |
| 208 | + if (!"".equals(childIncompatibility)) { |
| 209 | + sb.append(StringUtils.repeat(' ', 10)) |
| 210 | + .append("Missing property: ") |
| 211 | + .append(childIncompatibility) |
| 212 | + .append(System.lineSeparator()); |
| 213 | + } |
| 214 | + } |
| 215 | + } |
| 216 | + return sb.toString(); |
| 217 | + } |
| 218 | + } |
| 219 | + |
174 | 220 | private String ul_param(ChangedParameters changedParameters) {
|
175 | 221 | List<Parameter> addParameters = changedParameters.getIncreased();
|
176 | 222 | List<Parameter> delParameters = changedParameters.getMissing();
|
|
0 commit comments