Skip to content

Commit a95cf50

Browse files
Set the pathType of the root schema file, so its path is correctly formatted by $refs.paths() and $refs.values()
1 parent 24ca937 commit a95cf50

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ $RefParser.prototype.parse = function (path, schema, options, callback) {
8585
// So we're being generous here and doing the conversion automatically.
8686
// This is not intended to be a 100% bulletproof solution.
8787
// If it doesn't work for your use-case, then use a URL instead.
88+
var pathType = 'http';
8889
if (url.isFileSystemPath(args.path)) {
8990
args.path = url.fromFileSystemPath(args.path);
91+
pathType = 'file';
9092
}
9193

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

0 commit comments

Comments
 (0)