New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

raml2obj

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml2obj - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0-beta1

.eslintrc.js

5

changelog.md

@@ -0,1 +1,6 @@

3.0.0-beta1 - August 7, 2016
- Updated code to use ES6 syntax
- The securitySchemeWithName helper function is now part of raml2obj
- Breaking change: Node 4 or higher is now required!
2.2.0 - July 16, 2015

@@ -2,0 +7,0 @@ - Update third party dependencies

93

index.js

@@ -5,5 +5,4 @@ #!/usr/bin/env node

var raml = require('raml-parser');
var fs = require('fs');
var Q = require('q');
const raml = require('raml-parser');
const fs = require('fs');

@@ -21,3 +20,3 @@ function _parseBaseUri(ramlObj) {

function _ltrim(str, chr) {
var rgxtrim = (!chr) ? new RegExp('^\\s+') : new RegExp('^' + chr + '+');
const rgxtrim = (!chr) ? new RegExp('^\\s+') : new RegExp(`^${chr}+`);
return str.replace(rgxtrim, '');

@@ -27,3 +26,3 @@ }

function _makeUniqueId(resource) {
var fullUrl = resource.parentUrl + resource.relativeUri;
const fullUrl = resource.parentUrl + resource.relativeUri;
return _ltrim(fullUrl.replace(/\W/g, '_'), '_');

@@ -34,33 +33,30 @@ }

// Add unique id's and parent URL's plus parent URI parameters to resources
for (var index in ramlObj.resources) {
if (ramlObj.resources.hasOwnProperty(index)) {
var resource = ramlObj.resources[index];
resource.parentUrl = parentUrl || '';
resource.uniqueId = _makeUniqueId(resource);
resource.allUriParameters = [];
if (!ramlObj.resources) {
return ramlObj;
}
if (allUriParameters) {
resource.allUriParameters.push.apply(resource.allUriParameters, allUriParameters);
}
ramlObj.resources.forEach((resource) => {
resource.parentUrl = parentUrl || '';
resource.uniqueId = _makeUniqueId(resource);
resource.allUriParameters = [];
if (resource.uriParameters) {
for (var key in resource.uriParameters) {
if (resource.uriParameters.hasOwnProperty(key)) {
resource.allUriParameters.push(resource.uriParameters[key]);
}
}
}
if (allUriParameters) {
resource.allUriParameters.push.apply(resource.allUriParameters, allUriParameters);
}
if (resource.methods) {
for (var methodkey in resource.methods) {
if (resource.methods.hasOwnProperty(methodkey)) {
resource.methods[methodkey].allUriParameters = resource.allUriParameters;
}
}
}
if (resource.uriParameters) {
Object.keys(resource.uriParameters).forEach((key) => {
resource.allUriParameters.push(resource.uriParameters[key]);
});
}
_traverse(resource, resource.parentUrl + resource.relativeUri, resource.allUriParameters);
if (resource.methods) {
Object.keys(resource.methods).forEach((methodkey) => {
resource.methods[methodkey].allUriParameters = resource.allUriParameters;
});
}
}
_traverse(resource, resource.parentUrl + resource.relativeUri, resource.allUriParameters);
});
return ramlObj;

@@ -71,8 +67,5 @@ }

// Add unique id's to top level documentation chapters
for (var idx in ramlObj.documentation) {
if (ramlObj.documentation.hasOwnProperty(idx)) {
var docSection = ramlObj.documentation[idx];
docSection.uniqueId = docSection.title.replace(/\W/g, '-');
}
}
ramlObj.documentation.forEach((docSection) => {
docSection.uniqueId = docSection.title.replace(/\W/g, '-');
});

@@ -85,2 +78,14 @@ return ramlObj;

ramlObj = _traverse(ramlObj);
// Add extra function for finding a security scheme by name
ramlObj.securitySchemeWithName = function (name) {
if (ramlObj.securitySchemes) {
const result = ramlObj.securitySchemes.find(s => s[name]);
if (result) {
return result[name];
}
}
return {};
};
return _addUniqueIdsToDocs(ramlObj);

@@ -97,15 +102,15 @@ }

// Parse as string or buffer
return raml.load('' + source);
return raml.load(String(source));
} else if (source instanceof Buffer) {
// Parse as buffer
return raml.load('' + source);
return raml.load(String(source));
} else if (typeof source === 'object') {
// Parse RAML object directly
return Q.fcall(function() {
return source;
return new Promise((resolve) => {
resolve(source);
});
}
return Q.fcall(function() {
throw new Error('_sourceToRamlObj: You must supply either file, url, data or obj as source.');
return new Promise((resolve, reject) => {
reject(new Error('_sourceToRamlObj: You must supply either file, url, data or obj as source.'));
});

@@ -115,7 +120,5 @@ }

function parse(source) {
return _sourceToRamlObj(source).then(function(ramlObj) {
return _enhanceRamlObj(ramlObj);
});
return _sourceToRamlObj(source).then((ramlObj) => _enhanceRamlObj(ramlObj));
}
module.exports.parse = parse;
{
"name": "raml2obj",
"description": "RAML to object",
"version": "2.2.0",
"version": "3.0.0-beta1",
"author": {

@@ -10,12 +10,12 @@ "name": "Kevin Renskers",

"bugs": {
"url": "https://github.com/kevinrenskers/raml2obj/issues"
"url": "https://github.com/raml2html/raml2obj/issues"
},
"dependencies": {
"q": "1.4.x",
"raml-parser": "0.8.x"
},
"devDependencies": {
"eslint": "0.24.x"
"eslint": "3.2.x",
"eslint-config-loopwerk": "4.1.x"
},
"homepage": "https://github.com/kevinrenskers/raml2obj",
"homepage": "https://github.com/raml2html/raml2obj",
"keywords": [

@@ -28,8 +28,12 @@ "RAML"

"type": "git",
"url": "git://github.com/kevinrenskers/raml2obj.git"
"url": "git://github.com/raml2html/raml2obj.git"
},
"preferGlobal": "false",
"scripts": {
"lint": "eslint ./"
"lint": "eslint index.js",
"lintfix": "eslint index.js --fix"
},
"engines": {
"node": ">=4"
}
}

@@ -37,3 +37,3 @@ # RAML to object

A big thank you goes out to everyone who helped with the project, the [contributors](https://github.com/kevinrenskers/raml2obj/graphs/contributors)
A big thank you goes out to everyone who helped with the project, the [contributors](https://github.com/raml2html/raml2obj/graphs/contributors)
and everyone who took the time to report issues and give feedback.

@@ -40,0 +40,0 @@

'use strict';
var raml2obj = require('..');
const raml2obj = require('..');
raml2obj.parse('example.raml').then(function(ramlObj) {
raml2obj.parse('example.raml').then((ramlObj) => {
console.log(ramlObj);
}, function(error) {
}, (error) => {
console.log('error:', error);
});

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