UNPKG

openapi-diff

Version:

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

16 lines (15 loc) 838 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toDiffReadyOpenApi3Schema = void 0; const to_diff_compatible_json_schema_1 = require("../common/to-diff-compatible-json-schema"); const getReferenceSources = (spec) => { return spec.components && spec.components.schemas ? spec.components.schemas : {}; }; const toDiffReadyOpenApi3Schema = (schema, spec) => { const compatibleReferenceSources = (0, to_diff_compatible_json_schema_1.toDiffCompatibleJsonSchemaMap)(getReferenceSources(spec)); const compatibleSchema = (0, to_diff_compatible_json_schema_1.toDiffCompatibleJsonSchema)(schema); return Object.assign(Object.assign({}, compatibleSchema), { components: { schemas: compatibleReferenceSources } }); }; exports.toDiffReadyOpenApi3Schema = toDiffReadyOpenApi3Schema;