Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@json-schema-tools/dereferencer

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@json-schema-tools/dereferencer - npm Package Compare versions

Comparing version 1.5.6 to 1.5.7

1

build/dereferencer.d.ts

@@ -64,2 +64,3 @@ import { JSONSchema } from "@json-schema-tools/meta-schema";

resolve(): Promise<JSONSchema>;
_resolve(): Promise<JSONSchema>;
/**

@@ -66,0 +67,0 @@ * First-pass traversal to collect all the refs that we can find. This allows us to

53

build/dereferencer.js

@@ -137,3 +137,17 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var refMap, unfetchedRefs, proms, _i, unfetchedRefs_1, ref, fetched, refProm, subDerefferOpts, subDereffer, subFetchedProm, subFetched;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._resolve()];
case 1:
_a.sent();
delete this.schema.definitions;
delete this.schema.components;
return [2 /*return*/, this.schema];
}
});
});
};
Dereferencer.prototype._resolve = function () {
return __awaiter(this, void 0, void 0, function () {
var unfetchedRefs, proms, _i, unfetchedRefs_1, ref, fetched, refProm, subDerefferOpts, subDereffer, subFetchedProm, subFetched;
var _this = this;

@@ -143,3 +157,2 @@ return __generator(this, function (_a) {

case 0:
refMap = {};
if (this.schema === true || this.schema === false) {

@@ -151,3 +164,3 @@ return [2 /*return*/, Promise.resolve(this.schema)];

}
unfetchedRefs = this.refs.filter(function (r) { return refMap[r] === undefined; });
unfetchedRefs = this.refs.filter(function (r) { return _this.refCache[r] === undefined; });
proms = [];

@@ -157,3 +170,3 @@ _i = 0, unfetchedRefs_1 = unfetchedRefs;

case 1:
if (!(_i < unfetchedRefs_1.length)) return [3 /*break*/, 12];
if (!(_i < unfetchedRefs_1.length)) return [3 /*break*/, 11];
ref = unfetchedRefs_1[_i];

@@ -183,3 +196,3 @@ fetched = void 0;

if (!(subDereffer.refs.length !== 0)) return [3 /*break*/, 7];
subFetchedProm = subDereffer.resolve();
subFetchedProm = subDereffer._resolve();
proms.push(subFetchedProm);

@@ -189,22 +202,17 @@ return [4 /*yield*/, subFetchedProm];

subFetched = _a.sent();
// if there are props other than $ref present on the fetched schema,
// we have to break referential integrity, creating a new schema all together.
refMap[ref] = copyOrNot(fetched, subFetched);
this.refCache[ref] = copyOrNot(fetched, subFetched);
return [3 /*break*/, 8];
case 7:
refMap[ref] = fetched;
this.refCache[ref] = fetched;
_a.label = 8;
case 8: return [3 /*break*/, 10];
case 9:
refMap[ref] = fetched;
this.refCache[ref] = fetched;
_a.label = 10;
case 10:
this.refCache[ref] = refMap[ref];
_a.label = 11;
case 11:
_i++;
return [3 /*break*/, 1];
case 12:
case 11:
if (this.schema.$ref !== undefined) {
this.schema = copyOrNot(this.schema, refMap[this.schema.$ref]);
this.schema = copyOrNot(this.schema, this.refCache[this.schema.$ref]);
}

@@ -217,3 +225,3 @@ else {

if (s.$ref !== undefined) {
var reffedSchema = refMap[s.$ref];
var reffedSchema = _this.refCache[s.$ref];
return copyOrNot(s, reffedSchema);

@@ -224,11 +232,6 @@ }

}
return [2 /*return*/, Promise
.all(proms)
.then(function () {
if (_this.schema !== false && _this.schema !== true) { // while not required, makes it nicer.
delete _this.schema.definitions;
delete _this.schema.components;
}
return _this.schema;
})];
return [4 /*yield*/, Promise.all(proms)];
case 12:
_a.sent();
return [2 /*return*/, this.schema];
}

@@ -235,0 +238,0 @@ });

{
"name": "@json-schema-tools/dereferencer",
"version": "1.5.6",
"version": "1.5.7",
"description": "Dereference (aka parse refs) from JSON Schemas",

@@ -5,0 +5,0 @@ "main": "build/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc