openapi-diff
Version:
A CLI tool to identify differences between Swagger/OpenAPI specs.
29 lines (28 loc) • 1.46 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const JsonSchemaDiff = require("json-schema-diff");
const open_api_diff_error_impl_1 = require("../../../common/open-api-diff-error-impl");
exports.getJsonSchemaForDiffing = (parsedScope) => {
return parsedScope.jsonSchema
? parsedScope.jsonSchema.schema
: {};
};
exports.getSchemaDifferences = (sourceParsedScope, destinationParsedScope) => __awaiter(this, void 0, void 0, function* () {
try {
return yield JsonSchemaDiff.diffSchemas({
destinationSchema: exports.getJsonSchemaForDiffing(destinationParsedScope),
sourceSchema: exports.getJsonSchemaForDiffing(sourceParsedScope)
});
}
catch (error) {
throw new open_api_diff_error_impl_1.OpenApiDiffErrorImpl('OPENAPI_DIFF_DIFF_ERROR', error);
}
});