Skip to content

Commit

Permalink
Set the pathType of the root schema file, so its path is correctly …
Browse files Browse the repository at this point in the history
…formatted by `$refs.paths()` and `$refs.values()`
  • Loading branch information
JamesMessinger committed Mar 17, 2018
1 parent 24ca937 commit a95cf50
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
// So we're being generous here and doing the conversion automatically.
// This is not intended to be a 100% bulletproof solution.
// If it doesn't work for your use-case, then use a URL instead.
var pathType = 'http';
if (url.isFileSystemPath(args.path)) {
args.path = url.fromFileSystemPath(args.path);
pathType = 'file';
}

// Resolve the absolute path of the schema
Expand All @@ -95,7 +97,9 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
if (args.schema && typeof args.schema === 'object') {
// A schema object was passed-in.
// So immediately add a new $Ref with the schema object as its value
this.$refs._add(args.path, args.schema);
var $ref = this.$refs._add(args.path);
$ref.value = args.schema;
$ref.pathType = pathType;
promise = Promise.resolve(args.schema);
}
else {
Expand Down

0 comments on commit a95cf50

Please sign in to comment.