nvs api diff
nvs api diff <old.json> <new.json> compares two OpenAPI documents and lists what changed.
The usual input is the document of the last release and the one that nvs build --openapi just printed. The command prints one line for each change. Each line starts with breaking, additive or cosmetic. A removed path is breaking, for example, and a new optional parameter is additive. A summary line with the counts comes last. When the two documents are the same, the command prints no change.
The exit status is 1 when a change is breaking. A build server can use this to stop a release that breaks the clients of your API.
Examples
A parameter clients may leave out
<?nvs// Shows a change to an API that `nvs api diff` reports as safe for existing clients.// The first version of `index` had no `$status` parameter. `nvs api diff` compares// the old and the new API document, and prints this line:// additive: paths./orders.get.query.status — optional parameter added
class Orders{ // `$status` has a default value, so a client can still leave it out. Without the // default value, the change is `breaking`, and the command exits with `1`. #[Core\Route(path: '/orders', method: Core\Http\Method::Get)] #[Core\Access(allow: Core\Audience::Public)] public function index(#[Core\Query] string $status = 'open'): string { return 'orders that are ' . $status; }}
// Running the program calls the method directly. This prints `orders that are open`.Orders $orders = new Orders();echo $orders->index(), "\n";orders that are open