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

swagger-tools

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-tools - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

128

index.js

@@ -26,10 +26,11 @@ /*

var defaultOptions = {
validator: {
useDefault: false,
useCoerce: false,
checkRequired: true,
removeAdditional: false
}
var jjvOptions = {
checkRequired: true,
removeAdditional: false,
useDefault: false,
useCoerce: false
};
var jjveOptions = {
formatPath: false
};

@@ -60,13 +61,6 @@ var mergeResults = function mergeResults (errors, warnings, results) {

* @param {string} version - The Swagger version
* @param {object} [options] - The specification options
* @param {boolean} [options.validator.useDefault=false] - If true it modifies the object to have the default values for
* missing non-required fields
* @param {boolean} [options.validator.useCoerce=false] - If true it enables type coercion where defined
* @param {boolean} [options.validatorcheckRequired=true] - If true it reports missing required properties, otherwise it
* allows missing required properties
* @param {boolean} [options.validator.removeAdditional=false] - If true it removes all attributes of an object which
* are not matched by the schema's specification
*
* @constructor
*/
var Specification = function Specification (version, options) {
var Specification = function Specification (version) {
var schemasPath = path.join(__dirname, 'schemas', version);

@@ -77,4 +71,2 @@ var docsUrl;

options = _.defaults(options || {}, defaultOptions);
switch (version) {

@@ -104,3 +96,2 @@ case '1.2':

this.docsUrl = docsUrl;
this.options = options;
this.primitives = primitives;

@@ -127,3 +118,3 @@ this.schemasUrl = schemasUrl;

Object.keys(this.schemas).forEach(function (schemaName) {
var validator = jjv(this.options.validator);
var validator = jjv(jjvOptions);
var toCompile = [];

@@ -214,3 +205,3 @@

data: defaultValue,
path: path + '.defaultValue'
path: path.concat(['defaultValue'])
});

@@ -230,3 +221,3 @@ }

data: defaultValue,
path: path + '.defaultValue'
path: path.concat(['defaultValue'])
});

@@ -243,3 +234,3 @@ }

data: data.maximum,
path: path + '.maximum'
path: path.concat(['maximum'])
});

@@ -251,3 +242,3 @@ } else if (_.isNumber(parsedValue) && _.isNumber(parsedMaximumValue) && parsedValue > parsedMaximumValue) {

data: defaultValue,
path: path + '.defaultValue'
path: path.concat(['defaultValue'])
});

@@ -265,3 +256,3 @@ }

data: data.minimum,
path: path + '.minimum'
path: path.concat(['minimum'])
});

@@ -273,3 +264,3 @@ } else if (_.isNumber(parsedValue) && _.isNumber(parsedMinimumValue) && parsedValue < parsedMinimumValue) {

data: defaultValue,
path: path + '.defaultValue'
path: path.concat(['defaultValue'])
});

@@ -288,3 +279,3 @@ }

data: defaultValue,
path: path + '.defaultValue'
path: path.concat(['defaultValue'])
});

@@ -327,3 +318,3 @@ }

data: prop,
path: '$.models[\'' + parentModel + '\'].properties[\'' + propName + '\']'
path: ['models', parentModel, 'properties', propName]
});

@@ -358,3 +349,3 @@ } else {

data: model,
path: '$.models[\'' + id + '\']'
path: ['models', id]
});

@@ -372,3 +363,3 @@ }

data: model.subTypes || [],
path: '$.models[\'' + id + '\'].subTypes'
path: ['models', id, 'subTypes']
});

@@ -407,12 +398,12 @@ return;

_.each(resource.apis, function (api, index) {
var apiPath = '$.apis[' + index + ']';
var apiPath = ['apis', index.toString()];
_.each(api.operations, function (operation, index) {
var operationPath = apiPath + '.operations[' + index + ']';
var operationPath = apiPath.concat(['operations', index.toString()]);
// References in operation type
if (operation.type === 'array' && operation.items.$ref) {
addModelRef(operation.items.$ref, operationPath + '.items.$ref');
addModelRef(operation.items.$ref, operationPath.concat(['items', '$ref']));
} else if (primitives.indexOf(operation.type) === -1) {
addModelRef(operation.type, operationPath + '.type');
addModelRef(operation.type, operationPath.concat(['type']));
}

@@ -422,6 +413,8 @@

_.each(operation.parameters, function (parameter, index) {
var paramPath = operationPath.concat(['parameters', index.toString()]);
if (primitives.indexOf(parameter.type) === -1) {
addModelRef(parameter.type, operationPath + '.parameters[' + index + '].type');
addModelRef(parameter.type, paramPath.concat(['type']));
} else if (parameter.type === 'array' && parameter.items.$ref) {
addModelRef(parameter.items.$ref, operationPath + '.parameters[' + index + '].items.$ref');
addModelRef(parameter.items.$ref, paramPath.concat(['items', '$ref']));
}

@@ -433,3 +426,4 @@ });

if (message.responseModel) {
addModelRef(message.responseModel, operationPath + '.responseMessages[' + index + '].responseModel');
addModelRef(message.responseModel,
operationPath.concat(['responseMessages', index.toString(), 'responseModel']));
}

@@ -443,3 +437,3 @@ });

_.each(models, function (model, name) {
var modelPath = '$.models[\'' + name + '\']'; // Always use bracket notation just to be safe
var modelPath = ['models', name];
var modelId = model.id;

@@ -454,3 +448,3 @@ var seenSubTypes = [];

data: modelId,
path: '$.models[\'' + name + '\'].id'
path: modelPath.concat(['id'])
});

@@ -471,3 +465,3 @@ } else {

data: subType,
path: '$.models[\'' + name + '\'].subTypes[' + index + ']'
path: modelPath.concat(['subTypes', index.toString()])
});

@@ -487,8 +481,8 @@ } else {

_.each(model.properties, function (property, name) {
var propPath = modelPath + '.properties[\'' + name + '\']'; // Always use bracket notation just to be safe
var propPath = modelPath.concat(['properties', name]);
if (property.$ref) {
addModelRef(property.$ref, propPath + '.$ref');
addModelRef(property.$ref, propPath.concat(['$ref']));
} else if (property.type === 'array' && property.items.$ref) {
addModelRef(property.items.$ref, propPath + '.items.$ref');
addModelRef(property.items.$ref, propPath.concat(['items', '$ref']));
} else {

@@ -502,3 +496,3 @@ mergeResults(errors, warnings, validateDefaultValue(property, propPath));

_.each(model.subTypes, function (name, index) {
addModelRef(name, modelPath + '.subTypes[' + index + ']');
addModelRef(name, modelPath.concat(['subTypes', index.toString()]));
});

@@ -512,3 +506,3 @@ }

data: model.discriminator,
path: '$.models[\'' + name + '\'].discriminator'
path: modelPath.concat(['discriminator'])
});

@@ -526,3 +520,3 @@ }

data: propName,
path: '$.models[\'' + name + '\'].required[' + index + ']'
path: modelPath.concat(['required', index.toString()])
});

@@ -558,3 +552,3 @@ }

data: unused,
path: '$.models[\'' + unused + '\']'
path: ['models', unused]
});

@@ -582,3 +576,3 @@ });

_.each(resource.apis, function (api, index) {
var apiPath = '$.apis[' + index + ']';
var apiPath = ['apis', index.toString()];
var seenMethods = [];

@@ -592,3 +586,3 @@ var seenNicknames = [];

_.each(api.operations, function (operation, index) {
var operationPath = apiPath + '.operations[' + index + ']';
var operationPath = apiPath.concat(['operations', index.toString()]);
var seenResponseMessageCodes = [];

@@ -599,3 +593,3 @@

mergeResults(errors, warnings,
validateDefaultValue(parameter, operationPath + '.parameters[' + index + ']'));
validateDefaultValue(parameter, operationPath.concat(['parameters', index.toString()])));
});

@@ -609,3 +603,3 @@

data: operation.method,
path: operationPath + '.method'
path: operationPath.concat(['method'])
});

@@ -622,3 +616,3 @@ } else {

data: operation.nickname,
path: operationPath + '.nickname'
path: operationPath.concat(['nickname'])
});

@@ -638,3 +632,3 @@ } else {

data: responseMessage.code,
path: operationPath + '.responseMessages[' + index + '].code'
path: operationPath.concat(['responseMessages', index.toString(), 'code'])
});

@@ -654,3 +648,3 @@ } else {

data: operation.summary,
path: operationPath + '.summary'
path: operationPath.concat(['summary'])
});

@@ -711,3 +705,3 @@ }

if (result) {
errors = validator.je(schema, data, result);
errors = validator.je(schema, data, result, jjveOptions);
}

@@ -778,3 +772,3 @@

data: api.path,
path: '$.apis[' + index + '].path'
path: ['apis', index.toString(), 'path']
});

@@ -829,3 +823,3 @@ } else {

data: scope.scope,
path: path + '.scopes[' + index + ']'
path: path.concat(['scopes', index.toString()])
});

@@ -849,3 +843,3 @@ } else {

_.each(resource.authorizations, function (authorization, name) {
recordAuth(authorization, name, '$.authorizations[\'' + name + ']');
recordAuth(authorization, name, ['authorizations', name]);
});

@@ -856,11 +850,11 @@ }

_.each(resource.apis, function (api, index) {
var aPath = '$.apis[' + index + ']';
var aPath = ['apis', index.toString()];
if (_.isArray(api.operations)) {
_.each(api.operations, function (operation, index) {
var oPath = aPath + '.operations[' + index + ']';
var oPath = aPath.concat(['operations', index.toString()]);
if (_.isPlainObject(operation.authorizations)) {
_.each(operation.authorizations, function (authorization, name) {
recordAuth(authorization, name, oPath + '.authorizations[\'' + name + '\']');
recordAuth(authorization, name, oPath.concat(['authorizations', name]));
});

@@ -877,3 +871,3 @@ }

data: resource.resourcePath,
path: '$.resourcePath'
path: ['resourcePath']
});

@@ -885,3 +879,3 @@ } else if (seenResourcePaths.indexOf(resource.resourcePath) > -1) {

data: resource.resourcePath,
path: '$.resourcePath'
path: ['resourcePath']
});

@@ -910,3 +904,3 @@ } else {

data: resourceList.apis[index],
path: '$.apis[' + index + ']'
path: ['apis', index.toString()]
});

@@ -921,3 +915,3 @@ });

data: resourceList.authorizations[unused],
path: '$.authorizations[\'' + unused + '\']'
path: ['authorizations', unused]
});

@@ -927,3 +921,3 @@ });

_.each(authScopes, function (scopes, name) {
var path = '$.authorizations[\'' + name + '\']';
var path = ['authorizations', name];

@@ -938,3 +932,3 @@ // Identify unused authorization scope (declared but not referenced)

data: resourceList.authorizations[name].scopes[index],
path: path + '.scopes[' + index + ']'
path: path.concat(['scopes', index.toString()])
});

@@ -941,0 +935,0 @@ });

{
"name": "swagger-tools",
"version": "0.4.4",
"version": "0.4.5",
"description": "Various tools for using and integrating with Swagger.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,6 +6,9 @@ The project provides various tools for integrating and interacting with Swagger. This project is in its infancy but

## Project Badges
* [Travis](https://travis-ci.org/) build status: [![Build Status](https://img.shields.io/travis/apigee-127/swagger-tools.svg)](https://travis-ci.org/apigee-127/swagger-tools)
* [NPM](https://www.npmjs.org) dependencies: [![Dependencies](http://img.shields.io/david/apigee-127/swagger-tools.svg)](https://david-dm.org/apigee-127/swagger-tools)
* [NPM](https://www.npmjs.org) developer dependencies: [![Dev Dependencies](http://img.shields.io/david/dev/apigee-127/swagger-tools.svg)](https://david-dm.org/apigee-127/swagger-tools#info=devDependencies&view=table)
* Build status: [![Build Status](https://travis-ci.org/apigee-127/swagger-tools.svg)](https://travis-ci.org/apigee-127/swagger-tools)
* Dependencies: [![Dependencies](https://david-dm.org/apigee-127/swagger-tools.svg)](https://david-dm.org/apigee-127/swagger-tools)
* Developer dependencies: [![Dev Dependencies](https://david-dm.org/apigee-127/swagger-tools/dev-status.svg)](https://david-dm.org/apigee-127/swagger-tools#info=devDependencies&view=table)
* Downloads: [![NPM Downloads Per Month](http://img.shields.io/npm/dm/swagger-tools.svg)](https://www.npmjs.org/package/swagger-tools)
* Version: [![NPM Version](http://img.shields.io/npm/v/swagger-tools.svg)](https://www.npmjs.org/package/swagger-tools)
## Supported Swagger Versions

@@ -12,0 +15,0 @@

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