1
1
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.$RefParser = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- /**!
2
+ /** !
3
3
* JSON Schema $Ref Parser v1.3.1
4
4
*
5
5
* @link https://github.com/BigstickCarpet/json-schema-ref-parser
@@ -62,7 +62,7 @@ function remap($refs, options) {
62
62
* @param {$RefParserOptions} options
63
63
*/
64
64
function crawl(obj, path, $refs, remapped, options) {
65
- if (obj && typeof( obj) === 'object') {
65
+ if (obj && typeof obj === 'object') {
66
66
Object.keys(obj).forEach(function(key) {
67
67
var keyPath = Pointer.join(path, key);
68
68
var value = obj[key];
@@ -143,7 +143,7 @@ function dereference(parser, options) {
143
143
function crawl(obj, path, parents, $refs, options) {
144
144
var isCircular = false;
145
145
146
- if (obj && typeof( obj) === 'object') {
146
+ if (obj && typeof obj === 'object') {
147
147
parents.push(obj);
148
148
149
149
Object.keys(obj).forEach(function(key) {
@@ -201,7 +201,7 @@ function crawl(obj, path, parents, $refs, options) {
201
201
* @returns {*} - Returns the dereferenced value
202
202
*/
203
203
function getDereferencedValue(currentValue, resolvedValue) {
204
- if (resolvedValue && typeof( resolvedValue) === 'object' && Object.keys(currentValue).length > 1) {
204
+ if (resolvedValue && typeof resolvedValue === 'object' && Object.keys(currentValue).length > 1) {
205
205
// The current value has additional properties (other than "$ref"),
206
206
// so merge the resolved value rather than completely replacing the reference
207
207
var merged = {};
@@ -303,7 +303,7 @@ function $RefParser() {
303
303
* @returns {Promise} - The returned promise resolves with the parsed JSON schema object.
304
304
*/
305
305
$RefParser.parse = function(schema, options, callback) {
306
- var Class = this;
306
+ var Class = this; // eslint-disable-line consistent-this
307
307
return new Class().parse(schema, options, callback);
308
308
};
309
309
@@ -320,7 +320,7 @@ $RefParser.parse = function(schema, options, callback) {
320
320
$RefParser.prototype.parse = function(schema, options, callback) {
321
321
var args = normalizeArgs(arguments);
322
322
323
- if (args.schema && typeof( args.schema) === 'object') {
323
+ if (args.schema && typeof args.schema === 'object') {
324
324
// The schema is an object, not a path/url
325
325
this.schema = args.schema;
326
326
this._basePath = '';
@@ -330,7 +330,7 @@ $RefParser.prototype.parse = function(schema, options, callback) {
330
330
return maybe(args.callback, Promise.resolve(this.schema));
331
331
}
332
332
333
- if (!args.schema || typeof( args.schema) !== 'string') {
333
+ if (!args.schema || typeof args.schema !== 'string') {
334
334
var err = ono('Expected a file path, URL, or object. Got %s', args.schema);
335
335
return maybe(args.callback, Promise.reject(err));
336
336
}
@@ -345,17 +345,17 @@ $RefParser.prototype.parse = function(schema, options, callback) {
345
345
// Read the schema file/url
346
346
return read(args.schema, this.$refs, args.options)
347
347
.then(function(cached$Ref) {
348
- var $ref = cached$Ref.$ref;
349
- if (!$ref. value || typeof($ref. value) !== 'object' || $ref. value instanceof Buffer) {
348
+ var value = cached$Ref.$ref.value ;
349
+ if (!value || typeof value !== 'object' || value instanceof Buffer) {
350
350
throw ono.syntax('"%s" is not a valid JSON Schema', me._basePath);
351
351
}
352
352
else {
353
- me.schema = $ref. value;
353
+ me.schema = value;
354
354
return maybe(args.callback, Promise.resolve(me.schema));
355
355
}
356
356
})
357
- .catch(function(err ) {
358
- return maybe(args.callback, Promise.reject(err ));
357
+ .catch(function(e ) {
358
+ return maybe(args.callback, Promise.reject(e ));
359
359
});
360
360
};
361
361
@@ -372,7 +372,7 @@ $RefParser.prototype.parse = function(schema, options, callback) {
372
372
* The returned promise resolves with a {@link $Refs} object containing the resolved JSON references
373
373
*/
374
374
$RefParser.resolve = function(schema, options, callback) {
375
- var Class = this;
375
+ var Class = this; // eslint-disable-line consistent-this
376
376
return new Class().resolve(schema, options, callback);
377
377
};
378
378
@@ -415,7 +415,7 @@ $RefParser.prototype.resolve = function(schema, options, callback) {
415
415
* @returns {Promise} - The returned promise resolves with the bundled JSON schema object.
416
416
*/
417
417
$RefParser.bundle = function(schema, options, callback) {
418
- var Class = this;
418
+ var Class = this; // eslint-disable-line consistent-this
419
419
return new Class().bundle(schema, options, callback);
420
420
};
421
421
@@ -453,7 +453,7 @@ $RefParser.prototype.bundle = function(schema, options, callback) {
453
453
* @returns {Promise} - The returned promise resolves with the dereferenced JSON schema object.
454
454
*/
455
455
$RefParser.dereference = function(schema, options, callback) {
456
- var Class = this;
456
+ var Class = this; // eslint-disable-line consistent-this
457
457
return new Class().dereference(schema, options, callback);
458
458
};
459
459
@@ -488,7 +488,7 @@ $RefParser.prototype.dereference = function(schema, options, callback) {
488
488
*/
489
489
function normalizeArgs(args) {
490
490
var options = args[1], callback = args[2];
491
- if (typeof( options) === 'function') {
491
+ if (typeof options === 'function') {
492
492
callback = options;
493
493
options = undefined;
494
494
}
@@ -505,6 +505,7 @@ function normalizeArgs(args) {
505
505
}).call(this,require("buffer").Buffer)
506
506
507
507
},{"./bundle":1,"./dereference":2,"./options":4,"./promise":7,"./read":8,"./ref":9,"./refs":10,"./resolve":11,"./util":12,"./yaml":13,"buffer":17,"call-me-maybe":19,"ono":65,"url":90}],4:[function(require,module,exports){
508
+ /* eslint lines-around-comment: [2, {beforeBlockComment: false}] */
508
509
'use strict';
509
510
510
511
module.exports = $RefParserOptions;
@@ -697,8 +698,8 @@ function parse(data, path, options) {
697
698
*/
698
699
function isEmpty(value) {
699
700
return !value ||
700
- (typeof( value) === 'object' && Object.keys(value).length === 0) ||
701
- (typeof( value) === 'string' && value.trim().length === 0) ||
701
+ (typeof value === 'object' && Object.keys(value).length === 0) ||
702
+ (typeof value === 'string' && value.trim().length === 0) ||
702
703
(value instanceof Buffer && value.length === 0);
703
704
}
704
705
@@ -941,7 +942,7 @@ function resolveIf$Ref(pointer, options) {
941
942
* @returns {*} - Returns the assigned value
942
943
*/
943
944
function setValue(pointer, token, value) {
944
- if (pointer.value && typeof( pointer.value) === 'object') {
945
+ if (pointer.value && typeof pointer.value === 'object') {
945
946
if (token === '-' && Array.isArray(pointer.value)) {
946
947
pointer.value.push(value);
947
948
}
@@ -956,8 +957,10 @@ function setValue(pointer, token, value) {
956
957
}
957
958
958
959
},{"./ref":9,"./util":12,"ono":65,"url":90}],7:[function(require,module,exports){
960
+ 'use strict';
961
+
959
962
/** @type {Promise} **/
960
- module.exports = typeof( Promise) === 'function' ? Promise : require('es6-promise').Promise;
963
+ module.exports = typeof Promise === 'function' ? Promise : require('es6-promise').Promise;
961
964
962
965
},{"es6-promise":23}],8:[function(require,module,exports){
963
966
(function (process,Buffer){
@@ -1137,16 +1140,16 @@ function download(protocol, u, options) {
1137
1140
util.debug('Downloading file: %s', u);
1138
1141
1139
1142
var req = protocol.get(
1140
- {
1141
- hostname: u.hostname,
1142
- port: u.port,
1143
- path: u.path,
1144
- auth: u.auth
1145
- },
1146
- onResponse
1143
+ {
1144
+ hostname: u.hostname,
1145
+ port: u.port,
1146
+ path: u.path,
1147
+ auth: u.auth
1148
+ },
1149
+ onResponse
1147
1150
);
1148
1151
1149
- if (typeof( req.setTimeout) === 'function') {
1152
+ if (typeof req.setTimeout === 'function') {
1150
1153
req.setTimeout(5000);
1151
1154
}
1152
1155
@@ -1162,6 +1165,11 @@ function download(protocol, u, options) {
1162
1165
reject(ono(err, 'Error downloading file "%s"', u.href));
1163
1166
}
1164
1167
1168
+ /**
1169
+ * Handles the response
1170
+ *
1171
+ * @param {Response} res
1172
+ */
1165
1173
function onResponse(res) {
1166
1174
var body;
1167
1175
@@ -1357,7 +1365,7 @@ $Ref.prototype.set = function(path, value, options) {
1357
1365
* @returns {boolean}
1358
1366
*/
1359
1367
$Ref.is$Ref = function(value) {
1360
- return value && typeof( value) === 'object' && typeof( value.$ref) === 'string' && value.$ref.length > 0;
1368
+ return value && typeof value === 'object' && typeof value.$ref === 'string' && value.$ref.length > 0;
1361
1369
};
1362
1370
1363
1371
/**
@@ -1647,7 +1655,7 @@ function resolve(parser, options) {
1647
1655
function crawl(obj, path, pathFromRoot, $refs, options) {
1648
1656
var promises = [];
1649
1657
1650
- if (obj && typeof( obj) === 'object') {
1658
+ if (obj && typeof obj === 'object') {
1651
1659
var keys = Object.keys(obj);
1652
1660
1653
1661
// If there's a "definitions" property, then crawl it FIRST.
@@ -1850,6 +1858,7 @@ exports.path.extname = function extname(path) {
1850
1858
}).call(this,require('_process'))
1851
1859
1852
1860
},{"_process":67,"debug":21}],13:[function(require,module,exports){
1861
+ /* eslint lines-around-comment: [2, {beforeBlockComment: false}] */
1853
1862
'use strict';
1854
1863
1855
1864
var yaml = require('js-yaml');
@@ -1878,7 +1887,7 @@ module.exports = {
1878
1887
* @returns {string}
1879
1888
*/
1880
1889
stringify: function yamlStringify(value, replacer, space) {
1881
- var indent = (typeof( space) === 'string' ? space.length : space) || 2;
1890
+ var indent = (typeof space === 'string' ? space.length : space) || 2;
1882
1891
return yaml.safeDump(value, {indent: indent});
1883
1892
}
1884
1893
};
0 commit comments