Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-parser

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-parser - npm Package Compare versions

Comparing version 2.1.3 to 2.2.1

13

bower.json
{
"name": "swagger-parser",
"version": "2.2.1",
"description": "Parses a JSON or YAML Swagger spec, validates it against the Swagger schema, and dereferences all $ref pointers",

@@ -15,6 +16,8 @@ "keywords": [

],
"authors": [{
"name": "James Messinger",
"homepage": "http://jamesmessinger.com"
}],
"authors": [
{
"name": "James Messinger",
"homepage": "http://jamesmessinger.com"
}
],
"license": "MIT",

@@ -40,2 +43,2 @@ "homepage": "https://github.com/BigstickCarpet/swagger-parser",

}
}
}

@@ -6,2 +6,3 @@ 'use strict';

var fs = require('fs'),
path = require('path'),
http = require('http'),

@@ -13,4 +14,3 @@ url = require('url'),

_isEmpty = require('lodash/lang/isEmpty'),
_isFunction = require('lodash/lang/isFunction'),
_isPlainObject = require('lodash/lang/isPlainObject');
_isFunction = require('lodash/lang/isFunction');

@@ -192,21 +192,33 @@

var parsedObject;
if (state.options.parseYaml) {
util.debug('Parsing YAML file "%s"', pathOrUrl);
parsedObject = yaml.safeLoad(data);
}
else {
util.debug('Parsing JSON file "%s"', pathOrUrl);
parsedObject = JSON.parse(data);
}
if (_isEmpty(parsedObject)) {
throw util.newSyntaxError('Parsed value is empty');
try {
if (state.options.parseYaml) {
util.debug('Parsing YAML file "%s"', pathOrUrl);
parsedObject = yaml.safeLoad(data);
}
else {
util.debug('Parsing JSON file "%s"', pathOrUrl);
parsedObject = JSON.parse(data);
}
if (_isEmpty(parsedObject)) {
//noinspection ExceptionCaughtLocallyJS
throw util.newSyntaxError('Parsed value is empty');
}
util.debug(' Parsed successfully');
}
if (!_isPlainObject(parsedObject)) {
throw util.newSyntaxError('Parsed value is not a valid JavaScript object');
catch (e) {
var ext = path.extname(pathOrUrl).toLowerCase();
if (['.json', '.yaml', '.yml'].indexOf(ext) === -1) {
// It's not a YAML or JSON file, so ignore the parsing error and just treat it as a string
parsedObject = data;
}
else {
throw e;
}
}
util.debug(' Parsed successfully');
return parsedObject;
}

@@ -5,14 +5,15 @@ 'use strict';

var url = require('url'),
read = require('./read'),
util = require('./util'),
_last = require('lodash/array/last'),
_result = require('lodash/object/result'),
_has = require('lodash/object/has'),
_isEmpty = require('lodash/lang/isEmpty');
var url = require('url'),
read = require('./read'),
util = require('./util'),
_last = require('lodash/array/last'),
_result = require('lodash/object/result'),
_has = require('lodash/object/has'),
_isEmpty = require('lodash/lang/isEmpty');
// RegExp pattern for external $ref pointers
// (e.g. "http://company.com", "https://company.com", "./file.yaml", "../../file.yaml")
var external$RefPattern = /^https?\:\/\/|^\.|\.yml$|\.yaml$|\.json$/i;
// RegExp pattern to detect external $ref pointers.
// Matches anything that starts with "http://" or contains a period (".")
// (e.g. "http://localhost/some/path", "company.com/some/path", "file.yaml", "..\..\file.yaml", "./fileWithoutExt")
var external$RefPattern = /(^https?\:\/\/)|(\.)/i;

@@ -19,0 +20,0 @@

@@ -54,4 +54,4 @@ 'use strict';

/**
* The Swagger object (https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#swagger-object-)
* The Swagger object (https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object)
* @typedef {{swagger: string, info: {}, paths: {}}} SwaggerObject
*/

@@ -72,2 +72,8 @@ 'use strict';

// Do nothing if it's not an object or array
if (!_isPlainObject(obj) && !_isArray(obj)) {
callback(null, obj);
return;
}
// Keep a stack of parent objects

@@ -74,0 +80,0 @@ var parents = forEach.__parents = forEach.__parents || [];

{
"name": "swagger-parser",
"version": "2.1.3",
"version": "2.2.1",
"description": "Swagger JSON/YAML parser and validator for Node and browsers",

@@ -31,3 +31,4 @@ "keywords": [

"mocha": "mocha --recursive tests",
"karma": "karma start --single-run"
"karma": "karma start --single-run",
"release": "npm-check-updates -u && npm update && npm run build && npm test && bump --prompt --tag --push --all"
},

@@ -39,25 +40,25 @@ "repository": {

"dependencies": {
"debug": "^2.0.0",
"js-yaml": "^3.2.2",
"lodash": "^3.2.0",
"debug": "^2.1.1",
"js-yaml": "^3.2.7",
"lodash": "^3.3.1",
"swagger-schema-official": "2.0.0-a33091a",
"tv4": "^1.1.0"
"tv4": "^1.1.9"
},
"devDependencies": {
"browserify": "^8.0.0",
"chai": "^2.0.0",
"browserify": "^9.0.3",
"chai": "^2.1.0",
"coveralls": "^2.11.2",
"gulp": "^3.8.10",
"gulp": "^3.8.11",
"gulp-rename": "^1.2.0",
"gulp-sourcemaps": "^1.2.8",
"gulp-uglify": "^1.0.1",
"istanbul": "^0.3.5",
"jquery": "^2.1.1",
"karma": "^0.12.28",
"gulp-sourcemaps": "^1.5.0",
"gulp-uglify": "^1.1.0",
"istanbul": "^0.3.6",
"jquery": "^2.1.3",
"karma": "^0.12.31",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.5",
"karma-chrome-launcher": "^0.1.7",
"karma-cli": "0.0.4",
"karma-firefox-launcher": "^0.1.3",
"karma-firefox-launcher": "^0.1.4",
"karma-ie-launcher": "^0.1.5",
"karma-mocha": "^0.1.9",
"karma-mocha": "^0.1.10",
"karma-mocha-reporter": "^1.0.0",

@@ -67,8 +68,10 @@ "karma-phantomjs-launcher": "^0.1.4",

"karma-sinon": "^1.0.4",
"mocha": "^2.0.1",
"mocha": "^2.1.0",
"nock": "^0.59",
"sinon": "^1.12.1",
"npm-check-updates": "^1.5.1",
"sinon": "^1.12.2",
"version-bump-prompt": "^1.0.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.0.0"
}
}
}

@@ -37,3 +37,3 @@ Swagger-Parser

````
The `api` parameter that's passed to the callback function is the parsed, validated, and dereferenced [Swagger object](https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#swagger-object-).
The `api` parameter that's passed to the callback function is the parsed, validated, and dereferenced [Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object).

@@ -101,3 +101,3 @@

|`resolveExternal$Refs` |bool |true |Determines whether `$ref` pointers will be resolved if they point to external files or URLs. Internal `$ref` pointers will still be resolved and dereferenced.
|`validateSchema` |bool |true |Determines whether your API will be validated against the official Swagger schema. If set to `false`, then the resulting [Swagger object](https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#swagger-object-) may be missing properties, have properties of the wrong data type, etc.
|`validateSchema` |bool |true |Determines whether your API will be validated against the official Swagger schema. If set to `false`, then the resulting [Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object) may be missing properties, have properties of the wrong data type, etc.

@@ -108,3 +108,3 @@ #### Callback

|`err` |Error |`null` unless an error occurred.
|`api` |[Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object-) |The complete Swagger API object. Or `null` if an error occurred
|`api` |[Swagger object](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#swagger-object) |The complete Swagger API object. Or `null` if an error occurred
|`metadata` |object |This parameter provides extra information about the parsing operation. It is always provided, even if there's an error.

@@ -111,0 +111,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc