openapi-diff
Version:
A CLI tool to identify differences between Swagger/OpenAPI specs.
23 lines (22 loc) • 1.44 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 open_api_diff_error_impl_1 = require("../../common/open-api-diff-error-impl");
const validate_and_dereference_spec_1 = require("./common/validate-and-dereference-spec");
const is_swagger2_content_1 = require("./swagger2/is-swagger2-content");
const validateSpecFormat = (content, location) => {
if (!is_swagger2_content_1.isSwagger2Content(content)) {
throw new open_api_diff_error_impl_1.OpenApiDiffErrorImpl('OPENAPI_DIFF_PARSE_ERROR', `"${location}" is not a "swagger2" spec`);
}
};
exports.validateAndDereferenceSwagger2Spec = (content, location) => __awaiter(this, void 0, void 0, function* () {
validateSpecFormat(content, location);
return validate_and_dereference_spec_1.validateAndDereferenceSpec(content, location);
});