Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ public void render(ChangedOpenApi diff, OutputStreamWriter outputStreamWriter) {
diff.getNewSpecOpenApi().getInfo().getTitle(),
diff.getNewSpecOpenApi().getInfo().getVersion()));
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, ":reproducible:\n:sectlinks:\n:toc:\n");
safelyAppend(outputStreamWriter, ":reproducible:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, ":sectlinks:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, ":toc:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, System.lineSeparator());

List<Endpoint> newEndpoints = diff.getNewEndpoints();
Expand Down Expand Up @@ -86,19 +91,23 @@ private void ol_changed(
Optional.ofNullable(operation.getSummary()).map(ChangedMetadata::getRight).orElse("");

safelyAppend(outputStreamWriter, itemEndpoint(method, pathUrl, desc));
safelyAppend(outputStreamWriter, System.lineSeparator());
if (result(operation.getParameters()).isDifferent()) {
safelyAppend(outputStreamWriter, "* Parameter:\n");
safelyAppend(outputStreamWriter, "* Parameter:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, ul_param(operation.getParameters()));
safelyAppend(outputStreamWriter, System.lineSeparator());
}
if (operation.resultRequestBody().isDifferent()) {
safelyAppend(outputStreamWriter, "* Request:\n");
safelyAppend(outputStreamWriter, "* Request:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(
outputStreamWriter, ul_content(operation.getRequestBody().getContent(), true, 2));
safelyAppend(outputStreamWriter, System.lineSeparator());
}
if (operation.resultApiResponses().isDifferent()) {
safelyAppend(outputStreamWriter, "* Return Type:\n");
safelyAppend(outputStreamWriter, "* Return Type:");
safelyAppend(outputStreamWriter, System.lineSeparator());
safelyAppend(outputStreamWriter, ul_response(operation.getApiResponses()));
safelyAppend(outputStreamWriter, System.lineSeparator());
}
Expand Down Expand Up @@ -128,13 +137,14 @@ private String itemResponse(String title, String code) {
if (!code.equals("default") && !code.matches("[1-5]XX")) {
status = HttpStatus.getReasonPhrase(Integer.parseInt(code));
}
sb.append(title).append(code).append(' ').append(status).append("\n");
sb.append(title).append(code).append(' ').append(status).append(System.lineSeparator());
return sb.toString();
}

private String itemChangedResponse(String title, String contentType, ChangedResponse response) {
return itemResponse(title, contentType)
+ "** Media types:\n"
+ "** Media types:"
+ System.lineSeparator()
+ ul_content(response.getContent(), false, 3);
}

Expand All @@ -158,7 +168,7 @@ private String ul_content(ChangedContent changedContent, boolean isRequest, int
}

private String itemContent(String title, String contentType, int indent) {
return StringUtils.repeat('*', indent) + " " + title + contentType + "\n";
return StringUtils.repeat('*', indent) + " " + title + contentType + System.lineSeparator();
}

private String itemContent(
Expand All @@ -171,7 +181,7 @@ private String itemContent(
sb.append(itemContent(title, contentType, indent))
.append(itemContent("Schema:", "", indent))
.append(changedMediaType.isCompatible() ? "Backward compatible" : "Broken compatibility")
.append("\n");
.append(System.lineSeparator());
if (!changedMediaType.isCompatible()) {
sb.append(incompatibilities(changedMediaType.getSchema()));
}
Expand All @@ -190,6 +200,8 @@ private String incompatibilities(String propName, final ChangedSchema schema) {
if (schema.isCoreChanged() == DiffResult.INCOMPATIBLE && schema.isChangedType()) {
String type = type(schema.getOldSchema()) + " -> " + type(schema.getNewSchema());
sb.append(property(propName, "Changed property type", type));
sb.append(System.lineSeparator());
sb.append(System.lineSeparator());
}
String prefix = propName.isEmpty() ? "" : propName + ".";
sb.append(
Expand Down Expand Up @@ -226,7 +238,7 @@ protected String property(String name, String title, Schema<?> schema) {
}

protected String property(String name, String title, String type) {
return String.format("*** %s: %s (%s)%n\n", title, name, type);
return String.format("*** %s: %s (%s)", title, name, type);
}

protected Schema<?> resolve(Schema<?> schema) {
Expand Down Expand Up @@ -286,12 +298,13 @@ private String listEndpoints(
sb.append(
itemEndpoint(
endpoint.getMethod().toString(), endpoint.getPathUrl(), endpoint.getSummary()));
sb.append(System.lineSeparator());
}
return sb.append(System.lineSeparator()).toString();
}

private String itemEndpoint(String method, String path, String desc) {
return String.format("=== %s%s%n", StringUtils.rightPad(method, 6), path);
return String.format("=== %s%s", StringUtils.rightPad(method, 6), path);
}

public String bigTitle(String title, String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void validateAsciiDocChangeFile() {
OpenApiCompare.fromLocations("missing_property_1.yaml", "missing_property_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString())
.isEqualTo(
.isEqualToNormalizingNewlines(
"= TITLE (v 1.0.0)\n"
+ ":reproducible:\n"
+ ":sectlinks:\n"
Expand Down Expand Up @@ -78,7 +78,7 @@ public void validateAsciiDocRangeStatus() {
OpenApiCompare.fromLocations("range_statuscode_1.yaml", "range_statuscode_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString())
.isEqualTo(
.isEqualToNormalizingNewlines(
"= PROJECTS API (v 1.0.0)\n"
+ ":reproducible:\n"
+ ":sectlinks:\n"
Expand Down