Skip to content

Commit 981c8f2

Browse files
committed
Add parameter to fail if API changed
Instead of always failing when the API changed, this behavior is now triggered by `--fail-on-changed`. The normal behavior is now to print the report and exit successfully.
1 parent f81e67b commit 981c8f2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ usage: openapi-diff <old> <new>
7575
--state Only output diff state: no_changes,
7676
incompatible, compatible
7777
--fail-on-incompatible Fail only if API changes broke backward compatibility
78+
--fail-on-changed Fail if API changed but is backward compatible
7879
--trace be extra verbose
7980
--version print the version information and exit
8081
--warn Print warning information

src/main/java/com/qdesrame/openapi/diff/Main.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public static void main(String... args) {
3939
.longOpt("fail-on-incompatible")
4040
.desc("Fail only if API changes broke backward compatibility")
4141
.build());
42+
options.addOption(
43+
Option.builder()
44+
.longOpt("fail-on-changed")
45+
.desc("Fail if API changed but is backward compatible")
46+
.build());
4247
options.addOption(Option.builder().longOpt("trace").desc("be extra verbose").build());
4348
options.addOption(
4449
Option.builder().longOpt("debug").desc("Print debugging information").build());
@@ -174,7 +179,7 @@ public static void main(String... args) {
174179
System.exit(0);
175180
} else if (line.hasOption("fail-on-incompatible")) {
176181
System.exit(result.isCompatible() ? 0 : 1);
177-
} else {
182+
} else if (line.hasOption("fail-on-changed")) {
178183
System.exit(result.isUnchanged() ? 0 : 1);
179184
}
180185
} catch (ParseException e) {

0 commit comments

Comments
 (0)