Skip to content

Commit 769bc3b

Browse files
committed
Updating Maven Plugin to add Asciidoc Rebdering
1 parent d7df464 commit 769bc3b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

maven/src/main/java/org/openapitools/openapidiff/maven/OpenApiDiffMojo.java

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.maven.plugins.annotations.Parameter;
1515
import org.openapitools.openapidiff.core.OpenApiCompare;
1616
import org.openapitools.openapidiff.core.model.ChangedOpenApi;
17+
import org.openapitools.openapidiff.core.output.AsciidocRender;
1718
import org.openapitools.openapidiff.core.output.ConsoleRender;
1819
import org.openapitools.openapidiff.core.output.JsonRender;
1920
import org.openapitools.openapidiff.core.output.MarkdownRender;
@@ -46,6 +47,9 @@ public class OpenApiDiffMojo extends AbstractMojo {
4647
@Parameter(property = "markdownOutputFileName")
4748
String markdownOutputFileName;
4849

50+
@Parameter(property = "asciidocOutputFileName")
51+
String asciidocOutputFileName;
52+
4953
@Override
5054
public void execute() throws MojoExecutionException, MojoFailureException {
5155
if (Boolean.TRUE.equals(skip)) {
@@ -67,6 +71,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
6771
writeDiffAsTextToFile(diff);
6872
writeDiffAsJsonToFile(diff);
6973
writeDiffAsMarkdownToFile(diff);
74+
writeDiffAsAsciidocToFile(diff);
7075

7176
if (failOnIncompatible && diff.isIncompatible()) {
7277
throw new BackwardIncompatibilityException("The API changes broke backward compatibility");
@@ -91,4 +96,8 @@ private void writeDiffAsJsonToFile(final ChangedOpenApi diff) {
9196
private void writeDiffAsMarkdownToFile(final ChangedOpenApi diff) {
9297
writeToFile(new MarkdownRender(), diff, markdownOutputFileName);
9398
}
99+
100+
private void writeDiffAsAsciidocToFile(final ChangedOpenApi diff) {
101+
writeToFile(new AsciidocRender(), diff, asciidocOutputFileName);
102+
}
94103
}

maven/src/test/java/org/openapitools/openapidiff/maven/OpenApiDiffMojoTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class OpenApiDiffMojoTest {
2525
private final File consoleOutputfile = new File("target/diff.txt");
2626
private final File markdownOutputfile = new File("target/diff.md");
2727
private final File jsonOutputfile = new File("target/diff.json");
28+
private final File asciidocOutputfile = new File("target/diff.adoc");
2829

2930
@BeforeEach
3031
void setup() {
@@ -158,6 +159,20 @@ void Should_outputToJsonFile_When_SpecIsDifferent() {
158159
assertTrue(Files.exists(jsonOutputfile.toPath()));
159160
}
160161

162+
@Test
163+
void Should_outputToAsccidocFile_When_SpecIsDifferent() {
164+
final OpenApiDiffMojo mojo = new OpenApiDiffMojo();
165+
mojo.oldSpec = oldSpecFile.getAbsolutePath();
166+
mojo.newSpec = newSpecFile.getAbsolutePath();
167+
168+
mojo.asciidocOutputFileName = asciidocOutputfile.getAbsolutePath();
169+
mojo.failOnChanged = true;
170+
171+
assertThrows(ApiChangedException.class, mojo::execute);
172+
173+
assertTrue(Files.exists(asciidocOutputfile.toPath()));
174+
}
175+
161176
private void cleanupGeneratedFiles() {
162177
try {
163178
Files.deleteIfExists(Paths.get(consoleOutputfile.getPath()));

0 commit comments

Comments
 (0)