Skip to content

Commit 9968702

Browse files
committed
Report multiple missing properties
1 parent 0fdaa1d commit 9968702

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/main/java/com/qdesrame/openapi/diff/output/ConsoleRender.java

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,28 @@ private String itemContent(
170170
.append(changedMediaType.isCompatible() ? "Backward compatible" : "Broken compatibility")
171171
.append(System.lineSeparator());
172172
if (!changedMediaType.isCompatible()) {
173-
sb.append(incompatibility(changedMediaType));
173+
incompatibility(sb, changedMediaType, "");
174174
}
175175
return sb.toString();
176176
}
177177

178-
private String incompatibility(ComposedChanged changed) {
178+
private void incompatibility(
179+
final StringBuilder output, final ComposedChanged changed, final String propPrefix) {
179180
if (changed.isCoreChanged() == DiffResult.INCOMPATIBLE) {
180181
if (changed instanceof ChangedSchema) {
181182
ChangedSchema cs = (ChangedSchema) changed;
182183

183-
if (cs.getMissingProperties().size() > 0) {
184-
return cs.getMissingProperties().keySet().stream().collect(Collectors.joining());
185-
}
184+
cs.getMissingProperties().keySet().stream()
185+
.forEach(
186+
(propName) -> {
187+
output
188+
.append(StringUtils.repeat(' ', 10))
189+
.append("Missing property: ")
190+
.append(propPrefix)
191+
.append(propName)
192+
.append(System.lineSeparator());
193+
});
186194
}
187-
188-
return "";
189195
} else {
190196
if (changed instanceof ChangedSchema) {
191197
ChangedSchema cs = (ChangedSchema) changed;
@@ -196,30 +202,22 @@ private String incompatibility(ComposedChanged changed) {
196202
} else if (cs.getItems() != null) {
197203
description = "[n]";
198204
}
199-
return description
200-
+ "."
201-
+ cs.getChangedElements().stream()
202-
.map(
203-
(c) ->
204-
c != null && c instanceof ComposedChanged
205-
? incompatibility((ComposedChanged) c)
206-
: "")
207-
.collect(Collectors.joining());
205+
final String prefix = propPrefix + description + ".";
206+
cs.getChangedElements().stream()
207+
.forEach(
208+
(c) -> {
209+
if (c != null && c instanceof ComposedChanged) {
210+
incompatibility(output, (ComposedChanged) c, prefix);
211+
}
212+
});
213+
return;
208214
}
209215

210-
StringBuilder sb = new StringBuilder();
211216
for (Changed child : changed.getChangedElements()) {
212217
if (child instanceof ComposedChanged) {
213-
String childIncompatibility = incompatibility((ComposedChanged) child);
214-
if (!"".equals(childIncompatibility)) {
215-
sb.append(StringUtils.repeat(' ', 10))
216-
.append("Missing property: ")
217-
.append(childIncompatibility)
218-
.append(System.lineSeparator());
219-
}
218+
incompatibility(output, (ComposedChanged) child, "");
220219
}
221220
}
222-
return sb.toString();
223221
}
224222
}
225223

0 commit comments

Comments
 (0)