source: node_modules/@swagger-api/apidom-core/cjs/util.cjs@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.dereference = void 0;
5var _ramda = require("ramda");
6var _ramdaAdjunct = require("ramda-adjunct");
7/**
8 * This dereference algorithm is used exclusively for dereferencing specification objects.
9 * It doesn't handle circular references of external references and works on objects only (not arrays).
10 */
11// eslint-disable-next-line import/prefer-default-export
12const dereference = (object, root) => {
13 const rootObject = (0, _ramda.defaultTo)(object, root);
14 return (0, _ramda.mapObjIndexed)(val => {
15 if ((0, _ramdaAdjunct.isPlainObject)(val) && (0, _ramda.has)('$ref', val) && (0, _ramda.propSatisfies)(_ramdaAdjunct.isString, '$ref', val)) {
16 const $ref = (0, _ramda.path)(['$ref'], val);
17 // @ts-ignore
18 const pointer = (0, _ramdaAdjunct.trimCharsStart)('#/', $ref);
19 return (0, _ramda.path)(pointer.split('/'), rootObject);
20 }
21 if ((0, _ramdaAdjunct.isPlainObject)(val)) {
22 return dereference(val, rootObject);
23 }
24 return val;
25 }, object);
26};
27exports.dereference = dereference;
Note: See TracBrowser for help on using the repository browser.