Skip to content

Commit

Permalink
fix: update random shit
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jun 30, 2020
1 parent fffb7b9 commit 6e11447
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@json-schema-tools/dereferencer",
"version": "0.0.0-development",
"description": "",
"description": "Dereference (aka parse refs) from JSON Schemas",
"main": "build/index.js",
"publishConfig": {
"access": "public"
Expand All @@ -11,7 +11,7 @@
"lint": "tslint --fix -p .",
"test": "npm run lint && jest --coverage"
},
"author": "",
"author": "BelfordZ<belfordz66@gmail.com>",
"license": "Apache-2.0",
"devDependencies": {
"@json-schema-tools/meta-schema": "^1.0.10",
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export class InvalidFileSystemPathError extends Error {
}

/**
* When instantiated, represents a fully configured dereferencer.
* When instantiated, represents a fully configured dereferencer. When constructed, references are pulled out.
* No references are fetched until .resolve is called.
*/
export class Dereferencer {

Expand Down Expand Up @@ -243,9 +244,9 @@ export class Dereferencer {
} catch (e) {
throw new NonJsonRefError({ $ref: ref }, await fetchResult.text());
}
} catch (e) { /* noop */ }

throw new Error("Unhandled ref");
} catch (e) {
throw new Error("Unhandled ref");
}
}

/**
Expand All @@ -254,13 +255,18 @@ export class Dereferencer {
*/
private collectRefs(): string[] {
const refs: string[] = [];

traverse(this.schema, (s) => {
if (s.$ref && refs.indexOf(s.$ref) === -1) {
if (typeof s.$ref !== "string") { throw new NonStringRefError(s); }
if (typeof s.$ref !== "string") {
throw new NonStringRefError(s);
}

refs.push(s.$ref);
}
return s;
});

return refs;
}
}
Expand Down

0 comments on commit 6e11447

Please sign in to comment.