UNPKG

openapi-diff

Version:

A CLI tool to identify differences between Swagger/OpenAPI specs.

41 lines (38 loc) 1.82 kB
#! /usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const cli_factory_1 = require("./cli-factory"); // tslint:disable:no-var-requires const packageJson = require('../package.json'); const openApiDiff = cli_factory_1.CliFactory.createOpenApiDiff(); commander_1.program .version(packageJson.version) .arguments('<source> <destination>') .description(`A CLI tool to identify differences between Swagger/OpenAPI specs. Supported spec formats: - JSON Basic usage: The <source> spec and <destination> spec arguments should be paths to where the specs live in your filesystem.`) .action((sourceSpecPath, destinationSpecPath) => __awaiter(void 0, void 0, void 0, function* () { try { yield openApiDiff.diffPaths({ destinationSpec: { format: 'auto-detect', location: destinationSpecPath }, sourceSpec: { format: 'auto-detect', location: sourceSpecPath } }); } catch (error) { process.exit(1); } })) .parse(process.argv) .showHelpAfterError();