Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
raml-parser
Advanced tools
A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
![Gitter](https://badges.gitter.im/Join Chat.svg)
This is a JavaScript parser for RAML version 0.8 as defined in the 0.8 RAML specification
A newer version is now available as a beta. It supports RAML 1.0 as well as RAML 0.8.
If you are interested in contributing some code to this project, thanks! Please first read and accept the Contributors Agreement.
To discuss this project, please use its github issues or the RAML forum.
Loading a RAML file is as easy as follows:
var raml = require('raml-parser');
raml.loadFile('myAPI.raml').then( function(data) {
console.log(data);
}, function(error) {
console.log('Error parsing: ' + error);
});
You can alternatively load from a string containing the api definition:
var raml = require('raml-parser');
var definition = [
'#%RAML 0.8',
'---',
'title: MyApi',
'baseUri: http://myapi.com',
'/Root:'
].join('\n');
raml.load(definition).then( function(data) {
console.log(data);
}, function(error) {
console.log('Error parsing: ' + error);
});
The shape of the returned object is (unofficially) documented in this Typescript interface.
Generating an AST from a RAML file is as easy as follows:
var raml = require('raml-parser');
var myAPI;
raml.composeFile('myAPI.raml').then( function(rootNode) {
console.log('Root Node: ' + rootNode)
}, function(error) {
console.log('Error parsing: ' + error);
});
you can also alternatively generate an AST from a string containing the api definition:
var raml = require('raml-parser');
var definition = [
'#%RAML 0.8',
'---',
'title: MyApi',
'baseUri: http://myapi.com',
'/Root:'
].join('\n');
raml.compose(definition).then( function(rootNode) {
console.log('Root Node: ' + rootNode)
}, function(error) {
console.log('Error parsing: ' + error);
});
Using the RAML parser from inside the browser requires the user to actually include the RAML javascript file in a script tag as follows:
<script src="raml-parser.min.js"></script>
from there on the usage is pretty much the same as NodeJS, the script defines a RAML.Parser object globally which can be used as follows:
RAML.Parser.loadFile('http://localhost:9001/myAPI.raml').then( function(data) {
console.log(data)
}, function(error) {
console.log('Error parsing: ' + error);
});
Notice that the in-browser version can fetch remote API definitions via XHR.
FAQs
A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
The npm package raml-parser receives a total of 22,270 weekly downloads. As such, raml-parser popularity was classified as popular.
We found that raml-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.