Skip to content

Commit

Permalink
chore: code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
joschi committed Mar 7, 2024
1 parent 2c34b3d commit a2ceca4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 45 deletions.
12 changes: 6 additions & 6 deletions cli/src/main/java/org/openapitools/openapidiff/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public static void main(String... args) {
.desc("export diff as html in given file with incompatible changes")
.build());
options.addOption(
Option.builder()
.longOpt("html-detailed")
.hasArg()
.argName("file")
.desc("export diff as html in given file with all changes")
.build());
Option.builder()
.longOpt("html-detailed")
.hasArg()
.argName("file")
.desc("export diff as html in given file with all changes")
.build());
options.addOption(
Option.builder()
.longOpt("text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public DiffResult resultApiResponses() {
public DiffResult resultRequestBody() {
return requestBody == null ? DiffResult.NO_CHANGES : requestBody.isChanged();
}

public DiffResult resultSecurityRequirements() {
return securityRequirements == null ? DiffResult.NO_CHANGES : securityRequirements.isChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ private OlTag ol_changed(List<ChangedOperation> changedOperations) {
}
if (showAllChanges && changedOperation.resultSecurityRequirements().isDifferent()) {
ul_detail.with(
li().with(h3("Security Requirements"))
.with(ul_securityRequirements(changedOperation.getSecurityRequirements())));
li().with(h3("Security Requirements"))
.with(ul_securityRequirements(changedOperation.getSecurityRequirements())));
}
ol.with(
li().with(span(method).withClass(method))
Expand Down Expand Up @@ -255,24 +255,24 @@ private UlTag ul_securityRequirements(ChangedSecurityRequirements changedSecurit

private LiTag li_addSecurityRequirement(SecurityRequirement securityRequirement) {
return li().withText("New security requirement : ")
.with(span(null == securityRequirement.toString() ? "" : (securityRequirement.toString())));
.with(span(null == securityRequirement.toString() ? "" : (securityRequirement.toString())));
}

private LiTag li_missingSecurityRequirement(SecurityRequirement securityRequirement) {
return li().withText("Deleted security requirement : ")
.with(span(null == securityRequirement.toString() ? "" : (securityRequirement.toString())));
.with(span(null == securityRequirement.toString() ? "" : (securityRequirement.toString())));
}

private LiTag li_changedSecurityRequirement(
ChangedSecurityRequirement changedSecurityRequirement) {
ChangedSecurityRequirement changedSecurityRequirement) {
return li().withText(String.format("Changed security requirement : "))
.with(
span(
(null == changedSecurityRequirement.getNewSecurityRequirement()
|| null
== changedSecurityRequirement.getNewSecurityRequirement().toString())
? ""
: (changedSecurityRequirement.getNewSecurityRequirement().toString())));
.with(
span(
(null == changedSecurityRequirement.getNewSecurityRequirement()
|| null
== changedSecurityRequirement.getNewSecurityRequirement().toString())
? ""
: (changedSecurityRequirement.getNewSecurityRequirement().toString())));
}

private UlTag ul_response(ChangedApiResponse changedApiResponse) {
Expand Down Expand Up @@ -347,8 +347,7 @@ private LiTag li_changedRequest(String name, ChangedMediaType request) {
.withText(String.format("Changed body: '%s'", name));
if (request.isIncompatible() && !showAllChanges) {
incompatibilities(li, request.getSchema());
}
else if (showAllChanges) {
} else if (showAllChanges) {
allChanges(li, request.getSchema());
}
return li;
Expand All @@ -365,21 +364,21 @@ private void allChanges(final LiTag output, final ChangedSchema schema) {
}

private void allChanges(
final ContainerTag<?> output, String propName, final ChangedSchema schema) {
final ContainerTag<?> output, String propName, final ChangedSchema schema) {
String prefix = propName.isEmpty() ? "" : propName + ".";
properties(
output, prefix, "Missing property", schema.getMissingProperties(), schema.getContext());
output, prefix, "Missing property", schema.getMissingProperties(), schema.getContext());
properties(
output, prefix, "Added property", schema.getIncreasedProperties(), schema.getContext());
output, prefix, "Added property", schema.getIncreasedProperties(), schema.getContext());

propertiesChanged(
output, prefix, "Changed property", schema.getChangedProperties(), schema.getContext());
output, prefix, "Changed property", schema.getChangedProperties(), schema.getContext());
if (schema.getItems() != null) {
itemsAllChanges(output, propName, schema.getItems());
}
schema
.getChangedProperties()
.forEach((name, property) -> allChanges(output, prefix + name, property));
.getChangedProperties()
.forEach((name, property) -> allChanges(output, prefix + name, property));
}

private void incompatibilities(final LiTag output, final ChangedSchema schema) {
Expand Down Expand Up @@ -423,11 +422,11 @@ private void properties(
}

private void propertiesChanged(
ContainerTag<?> output,
String propPrefix,
String title,
Map<String, ChangedSchema> properties,
DiffContext context) {
ContainerTag<?> output,
String propPrefix,
String title,
Map<String, ChangedSchema> properties,
DiffContext context) {
if (properties != null) {
properties.forEach((key, value) -> resolveProperty(output, propPrefix, key, value, title));
}
Expand All @@ -443,7 +442,7 @@ private void resolveProperty(
}

private void resolveProperty(
ContainerTag<?> output, String propPrefix, String key, ChangedSchema value, String title) {
ContainerTag<?> output, String propPrefix, String key, ChangedSchema value, String title) {
try {
property(output, propPrefix + key, title, resolve(value));
} catch (Exception e) {
Expand All @@ -466,9 +465,9 @@ protected Schema<?> resolve(Schema<?> schema) {

protected Schema<?> resolve(ChangedSchema schema) {
return refPointer.resolveRef(
diff.getNewSpecOpenApi().getComponents(),
schema.getNewSchema(),
schema.getNewSchema().get$ref());
diff.getNewSpecOpenApi().getComponents(),
schema.getNewSchema(),
schema.getNewSchema().get$ref());
}

protected String type(Schema<?> schema) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public void renderDoesNotFailWhenPropertyHasBeenRemoved() {
ConsoleRender render = new ConsoleRender();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff = OpenApiCompare.fromLocations("missing_property_1.yaml", "missing_property_2.yaml");
ChangedOpenApi diff =
OpenApiCompare.fromLocations("missing_property_1.yaml", "missing_property_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).isNotBlank();
}
Expand All @@ -36,7 +37,7 @@ public void renderShowsWhatsDeletedSectionWhenEndpointIsDeleted() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations("delete_endpoint_1.yaml", "delete_endpoint_2.yaml");
OpenApiCompare.fromLocations("delete_endpoint_1.yaml", "delete_endpoint_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).contains("What's Deleted");
}
Expand All @@ -47,7 +48,7 @@ public void renderShowsWhatsNewSectionWhenEndpointIsAdded() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations("add_endpoint_1.yaml", "add_endpoint_2.yaml");
OpenApiCompare.fromLocations("add_endpoint_1.yaml", "add_endpoint_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).contains("What's New");
}
Expand All @@ -58,7 +59,7 @@ public void renderShowsWhatsDeprecatedSectionWhenEndpointIsDeprecated() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations("deprecate_endpoint_1.yaml", "deprecate_endpoint_2.yaml");
OpenApiCompare.fromLocations("deprecate_endpoint_1.yaml", "deprecate_endpoint_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString()).contains("What's Deprecated");
}
Expand All @@ -69,10 +70,10 @@ public void renderShowsWhatsChangedSectionWithCorrectFormattingWhenEndpointIsCha
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
ChangedOpenApi diff =
OpenApiCompare.fromLocations("change_endpoint_1.yaml", "change_endpoint_2.yaml");
OpenApiCompare.fromLocations("change_endpoint_1.yaml", "change_endpoint_2.yaml");
render.render(diff, outputStreamWriter);
assertThat(outputStream.toString())
.contains("What's Changed")
.containsSubsequence("- GET /widgets", "Parameter:", "- Changed query-param-1 in query");
.contains("What's Changed")
.containsSubsequence("- GET /widgets", "Parameter:", "- Changed query-param-1 in query");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public void issue458ExclusiveMinimumTrueRemoved() {

@Test
public void issue488RenameParameterAddAndRemoveParameterReturnFalse() {
assertOpenApiChangedEndpoints(
"issue-488-1.json", "issue-488-2.json");
assertOpenApiChangedEndpoints("issue-488-1.json", "issue-488-2.json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class OpenApiDiffMojo extends AbstractMojo {

@Parameter(property = "configProps")
Map<String, String> configProps;

@Parameter(property = "asciidocOutputFileName")
String asciidocOutputFileName;

Expand Down

0 comments on commit a2ceca4

Please sign in to comment.