json-schema-ref-parser
Advanced tools
Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5
@@ -20,3 +20,4 @@ 'use strict'; | ||
'tests/helper.js', | ||
'tests/**/*.spec.js' | ||
'tests/**/*.spec.js', | ||
{pattern: 'tests/files/**', included: false, served: true} | ||
], | ||
@@ -23,0 +24,0 @@ |
@@ -7,3 +7,2 @@ 'use strict'; | ||
$Refs = require('./refs'), | ||
$Ref = require('./ref'), | ||
read = require('./read'), | ||
@@ -26,2 +25,3 @@ resolve = require('./resolve'), | ||
* @type {object} | ||
* @readonly | ||
*/ | ||
@@ -80,3 +80,3 @@ this.schema = null; | ||
// Make sure the file was a POJO (in JSON or YAML format), NOT a Buffer or string | ||
if (_isPlainObject($ref.value)) { | ||
if ($ref.value && _isPlainObject($ref.value)) { | ||
me.schema = $ref.value; | ||
@@ -87,5 +87,3 @@ util.doCallback(callback, null, me.schema); | ||
else { | ||
var err = util.newError(SyntaxError, '"%s" is not a valid JSON Schema', me._url); | ||
util.doCallback(callback, err, $ref.value); | ||
throw err; | ||
throw util.newError(SyntaxError, '"%s" is not a valid JSON Schema', me._url); | ||
} | ||
@@ -139,10 +137,5 @@ }) | ||
return this.parse(schema, options) | ||
.then(function(result) { | ||
return resolve(me, options); | ||
}) | ||
return this.resolve(schema, options) | ||
.then(function() { | ||
return dereference(me, options); | ||
}) | ||
.then(function() { | ||
dereference(me, options); | ||
util.doCallback(callback, null, me.schema); | ||
@@ -149,0 +142,0 @@ return me.schema; |
'use strict'; | ||
var _merge = require('lodash/object/merge'), | ||
_cloneDeep = require('lodash/lang/cloneDeep'); | ||
var _merge = require('lodash/object/merge'); | ||
@@ -9,21 +8,21 @@ module.exports = Options; | ||
function Options(options) { | ||
_merge(this, _cloneDeep(Options.prototype), options); | ||
} | ||
this.allow = { | ||
json: true, | ||
yaml: true, | ||
empty: true, | ||
unknown: true | ||
}; | ||
Options.prototype.allow = { | ||
json: true, | ||
yaml: true, | ||
empty: true, | ||
unknown: true | ||
}; | ||
this.$refs = { | ||
internal: true, | ||
external: true | ||
}; | ||
Options.prototype.$refs = { | ||
internal: true, | ||
external: true | ||
}; | ||
this.cache = { | ||
fs: 60, | ||
http: 5 * 60, | ||
https: 5 * 60 | ||
}; | ||
Options.prototype.cache = { | ||
fs: 60, | ||
http: 5 * 60, | ||
https: 5 * 60 | ||
}; | ||
_merge(this, options); | ||
} |
'use strict'; | ||
var yaml = require('js-yaml'), | ||
Url = require('./url'), | ||
util = require('./util'), | ||
@@ -6,0 +5,0 @@ _isEmpty = require('lodash/lang/isEmpty'), |
@@ -8,3 +8,2 @@ 'use strict'; | ||
util = require('./util'), | ||
Url = require('./url'), | ||
$Ref = require('./ref'), | ||
@@ -83,3 +82,3 @@ Promise = require('./promise'), | ||
return $ref; | ||
}) | ||
}); | ||
} | ||
@@ -86,0 +85,0 @@ else { |
@@ -12,3 +12,3 @@ 'use strict'; | ||
if (_isString(u)) { | ||
this._url = Url.parse(u); | ||
this._url = Url.parse(u)._url; | ||
} | ||
@@ -42,3 +42,3 @@ else if (u instanceof Url) { | ||
} | ||
}) | ||
}); | ||
} | ||
@@ -126,3 +126,3 @@ ); | ||
// It's a web URL, so return it as-is | ||
return u; | ||
return new Url(u); | ||
} | ||
@@ -129,0 +129,0 @@ |
'use strict'; | ||
var debug = require('debug'), | ||
format = require('util').format, | ||
var debug = require('debug'), | ||
format = require('util').format, | ||
_isFunction = require('lodash/lang/isFunction'), | ||
_isString = require('lodash/lang/isString'); | ||
_isString = require('lodash/lang/isString'), | ||
slice = Array.prototype.slice; | ||
@@ -15,3 +16,2 @@ module.exports = { | ||
debug: debug('json-schema-ref-parser'), | ||
slice: slice, | ||
doCallback: doCallback, | ||
@@ -22,14 +22,2 @@ newError: newError | ||
/** | ||
* {@link Array#slice} for any array-like object (e.g. arguments) | ||
* | ||
* @param {object} array | ||
* @param {number} [start] | ||
* @param {number} [end] | ||
* @returns {Array} | ||
*/ | ||
function slice(array, start, end) { | ||
return Array.prototype.slice.call(array, start, end); | ||
} | ||
/** | ||
* Asynchronously invokes the given callback function with the given parameters. | ||
@@ -43,3 +31,3 @@ * | ||
if (_isFunction(callback)) { | ||
var args = slice(arguments, 1); | ||
var args = slice.call(arguments, 1); | ||
@@ -71,9 +59,9 @@ /* istanbul ignore if: code-coverage doesn't run in the browser */ | ||
if (_isFunction(Klass) && err instanceof Error) { | ||
return makeError(Klass, err, format.apply(null, slice(arguments, 2))); | ||
return makeError(Klass, err, format.apply(null, slice.call(arguments, 2))); | ||
} | ||
else if (_isFunction(Klass)) { | ||
return makeError(Klass, null, format.apply(null, slice(arguments, 1))); | ||
return makeError(Klass, null, format.apply(null, slice.call(arguments, 1))); | ||
} | ||
else if (err instanceof Error) { | ||
return makeError(Error, err, format.apply(null, slice(arguments, 1))); | ||
return makeError(Error, err, format.apply(null, slice.call(arguments, 1))); | ||
} | ||
@@ -80,0 +68,0 @@ else { |
{ | ||
"name": "json-schema-ref-parser", | ||
"version": "1.0.0-alpha.4", | ||
"version": "1.0.0-alpha.5", | ||
"description": "Parse, Resolve, and Dereference JSON Schema $ref pointers", | ||
@@ -30,4 +30,5 @@ "keywords": [ | ||
"karma": "karma start --single-run", | ||
"upgrade": "npm-check-updates -u && npm update && gulp update-tests", | ||
"release": "npm run upgrade && npm run build && npm test && bump --prerelease --tag --push --all && npm publish" | ||
"upgrade": "npm-check-updates -u && npm update", | ||
"bump": "bump --prerelease --tag --push --all", | ||
"release": "npm run upgrade && npm run build && npm test && npm run bump && npm publish" | ||
}, | ||
@@ -43,3 +44,3 @@ "repository": { | ||
"browserify-istanbul": "^0.2.1", | ||
"karma": "^0.12.37", | ||
"karma": "^0.13.0", | ||
"karma-chai": "^0.1.0", | ||
@@ -63,3 +64,3 @@ "karma-chrome-launcher": "^0.2.0", | ||
"npm-check-updates": "^1.5.1", | ||
"version-bump-prompt": "^1.4.0", | ||
"version-bump-prompt": "^1.4.1", | ||
"gulp": "^3.9.0", | ||
@@ -66,0 +67,0 @@ "gulp-rename": "^1.2.2", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2630268
20350