Comments (11)
Available in release 1.2.0
from openapi-diff.
If i had this option --fail-on-incompatible
we will be able to do it:
I guess the use case for checking for checking only for backward compatibility is:
There is a diff but it is backward compatible => OK (Return 0)
There is a diff that is not backward compatible => NOK (Return 1)
I'm suggesting this algorithm to improve current behavior in cli mode ;
What you are suggesting is:
No diff: Return code 0
Diff and not backward compatible: Return code 1
Diff that is backward compatible: Return code 2
from openapi-diff.
$ openapi-diff <old> <new> --state
<state>
With <state>
in : no_changes
,imcompatible
,compatible
(thanks for this proposition @itsjavi).
What do you think ?
from openapi-diff.
it sounds good π
from openapi-diff.
The main method provided by the project com.qdesrame.openapi.diff.Main
focuses on creating report.
As you can see in the code Line 129, the return status check if there is a diff or not.
System.exit(result.isDiff() ? 1 : 0);
The class ChangedOpenApi
(result
is an instance of it) provides also a isDiffBackwardCompatible()
method.
For the moment, you will need to write your own Main class that creates a ChangedOpenApi
instance for the two spec you provide as input. Then you can call isDiffBackwardCompatible()
and do a System.exit
call.
(If you need more details, just continue the discussion).
I am not really an expert on CLI tools written in Java, but maybe an option could be added βreturn codeβ or "exit check" with 2 possible values:
diff
current and default behaviourbackward
This way the use-case described in this question could be addressed for CLI users.
@quen2404: what do you think?
from openapi-diff.
Thank you for your detailed response
I think it would be enough to have an option like --fail-on-incompatible
or similar.
from openapi-diff.
Hi,
@jmini i can update main method to return a new code if contract changed with backward compatibility (maybe with code 2 ?).
@itsjavi I can add a new option if you want that the tool failed when it broke the compatibility.
from openapi-diff.
@quen2404 that is what I mean with "I am not familiar with CLI tools"... I have no input on what is the most appropriate.
I guess the use case for checking for checking only for backward compatibility is:
- There is a diff but it is backward compatible => OK
- There is a diff that is not backward compatible => NOK
What you are suggesting is:
- No diff: Return code 0
- Diff and not backward compatible: Return code 1
- Diff that is backward compatible: Return code 2
This is not exactly the same. Maybe it can be used. @itsjavi what is your opinion?
PS: I am using the lib at Java level (integrated in some Unit Tests).
from openapi-diff.
No diff: Return code 0
Diff and not backward compatible: Return code 1
Diff that is backward compatible: Return code 2
Note that program exit codes different than 0
are commonly used for reporting errors, so the return code 2
for indicating a "successful" state would be inappropriate in this case.
I like the first solution you suggested:
There is a diff but it is backward compatible => OK (exit code 0)
There is a diff that is not backward compatible => NOK (exit code 1)
If you still want to support a more variety of results/states I'd suggest to print a keyword instead, indicating the state, for example:
- No diff prints:
no_changes
- Diff and not backward compatible:
incompatible
- Diff that is backward compatible:
compatible
But I am not sure how that will work with the verbosity options, since it won't be the only thing printed.
from openapi-diff.
Done in PR #38
from openapi-diff.
That's awesome! thank you =)
from openapi-diff.
Related Issues (20)
- Getting NPE when I compare two Yaml or JSON file. HOT 4
- enum and properties change in schemas not reported in .md file generated after diff check
- [2.1.0-beta.6 and oas-3.1.0] Request body property data type change is detected as compatible or no_change HOT 1
- incompatible api diff result when one of property in model becomes not required HOT 2
- Treat new PUT request properties as compatible HOT 7
- Use maven wrapper (mvnw) in Git pre-commit hook
- Allowing circular references HOT 1
- Produce output to outputStream instead of String
- Backward-compatibility test coverage
- Response numeric range increase should be incompatible
- Make incompatibility checks configurable HOT 2
- --json output is absurdly huge
- [bug] [polymorphism] Changes in child schema are ignored when only parent schema is directly referenced HOT 1
- Gestion de stock
- Servers.Url are not considered when path changes HOT 4
- OneOf property is failing during OAS Schema Validation HOT 1
- Console rendering missing sections since 2.1.0-beta.7
- Removing a mandatory or optional property in the input data : breaking change ? HOT 1
- The current openapi-diff implementation does not capture differences in extensions that occur at the properties level (attributes under the type object) and the path level
- No backward compatible changes in Schema are marked as Compatible
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-diff.