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

raml-1-parser

Package Overview
Dependencies
Maintainers
4
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raml-1-parser - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

24

dist/raml1/ast.core/builder.js

@@ -79,2 +79,23 @@ /// <reference path="../../../typings/main.d.ts" />

var ad = 0;
/**
* Checks if a node is type declaration by a type shortcut having multiple inheritance TE as a value
* @param node
*/
function isMultipleInheritanceTypeExpressionTypeDeclaration(node) {
var definition = node.definition();
if (!definition || !universeHelpers.isTypeDeclarationDescendant(definition))
return false;
var lowLevel = node.lowLevel();
if (lowLevel.valueKind() !== yaml.Kind.SEQ)
return false;
var children = lowLevel.children();
if (children == null)
return false;
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
var child = children_1[_i];
if (child.kind() !== yaml.Kind.SCALAR)
return false;
}
return true;
}
var BasicNodeBuilder = (function () {

@@ -190,3 +211,4 @@ function BasicNodeBuilder() {

}
if (node.lowLevel().valueKind() === yaml.Kind.SEQ) {
if (node.lowLevel().valueKind() === yaml.Kind.SEQ
&& !isMultipleInheritanceTypeExpressionTypeDeclaration(node)) {
var error = new hlimpl.BasicASTNode(node.lowLevel(), aNode);

@@ -193,0 +215,0 @@ error.errorMessage = {

@@ -83,2 +83,10 @@ /// <reference path="../../../typings/main.d.ts" />

//props.forEach(x=> console.log(' prop: ' + x.name()));
var llchilds = where.lowLevel().children();
if (universeHelpers.isTraitsProperty(node.property())) {
return _.find(llchilds, function (llch) {
if (!llch.isMapping())
return false;
llch.asMapping().key.value === node.property().nameId();
});
}
var pindex = cls.propertyIndex(pname);

@@ -88,3 +96,2 @@ if (pindex < 0) {

}
var llchilds = where.lowLevel().children();
//console.log('lookup: ' + pname + ' index: ' + pindex + ' childs: ' + llchilds.length);

@@ -91,0 +98,0 @@ for (var i = 0; i < llchilds.length; i++) {

@@ -861,2 +861,6 @@ "use strict";

this._mode = _mode;
var l = this._name.length;
if (this._name.charAt(l - 1) == "?") {
this._name = this._name.substring(0, l - 1);
}
}

@@ -863,0 +867,0 @@ PatchedReference.prototype.namespace = function () { return this._namespace; };

@@ -84,2 +84,8 @@ "use strict";

});
describe('ReferencesPatching/NilableTypes', function () {
it("test001/api.raml", function () {
this.timeout(15000);
tckUtil.testAPILibExpand("LibraryExpansion/ReferencesPatching/NilableTypes/test001/api.raml");
});
});
describe('ReferencesPatching/ResourceTypes', function () {

@@ -86,0 +92,0 @@ it("test001/api.raml", function () {

4

dist/raml1/test/parserTests2.js

@@ -487,4 +487,4 @@ "use strict";

});
it('Should parse alternatively use additionalProperties', function () {
testErrors(util.data('parser/objectTypes/oType12.raml'));
it('Should not parse alternatively use additionalProperties', function () {
testErrors(util.data('parser/objectTypes/oType12.raml'), ["Value of 'additionalProperties' facet should be boolean"]);
});

@@ -491,0 +491,0 @@ it('Should parse inline type expression gets expanded to a proper type declaration', function () {

@@ -15,2 +15,9 @@ import hl = require("../highLevelAST");

/**
* These calculators are only applied when default calculator is generally disabled (this.enabled==false)
* and should cover the cases when we -need- to insert some calculated value in any case
* and helpers should be avoided for some reason.
* @type {UnconditionalRequiredPropertyCalculator[]}
*/
unconditionalValueCalculators: ValueCalculator[];
/**
* Return attribute default value if defaults calculator is enabled.

@@ -20,2 +27,3 @@ * If attribute value is null or undefined, returns attribute default.

attributeDefaultIfEnabled(node: hl.IHighLevelNode, attributeProperty: hl.IProperty): any;
getUnconditionalAttributeDefault(attributeProperty: hl.IProperty, node: hl.IHighLevelNode): any;
/**

@@ -22,0 +30,0 @@ * Returns attribute default.

@@ -26,2 +26,11 @@ "use strict";

];
/**
* These calculators are only applied when default calculator is generally disabled (this.enabled==false)
* and should cover the cases when we -need- to insert some calculated value in any case
* and helpers should be avoided for some reason.
* @type {UnconditionalRequiredPropertyCalculator[]}
*/
this.unconditionalValueCalculators = [
new UnconditionalRequiredPropertyCalculator(),
];
}

@@ -34,5 +43,19 @@ /**

if (!this.enabled)
return null;
return this.getUnconditionalAttributeDefault(attributeProperty, node);
return this.getAttributeDefault(node, attributeProperty);
};
AttributeDefaultsCalculator.prototype.getUnconditionalAttributeDefault = function (attributeProperty, node) {
if (!node || !attributeProperty)
return null;
for (var i = 0; i < this.unconditionalValueCalculators.length; i++) {
var calculator = this.unconditionalValueCalculators[i];
if (calculator.matches(attributeProperty, node)) {
var value = calculator.calculate(attributeProperty, node);
if (value != null) {
return value;
}
}
}
return null;
};
/**

@@ -390,2 +413,35 @@ * Returns attribute default.

}());
/**
* This calculator inserts "required=false" if the key property ends with question mark.
* All other cases are handled in the regular RequiredPropertyCalculator
*/
var UnconditionalRequiredPropertyCalculator = (function () {
function UnconditionalRequiredPropertyCalculator() {
}
UnconditionalRequiredPropertyCalculator.prototype.calculate = function (attributeProperty, node) {
var nodeDefinition = node.definition();
if (nodeDefinition == null)
return null;
//if node key is ending with question mark, it optional, thus its "required" == false
var adapter = nodeDefinition.getAdapter(services.RAMLService);
if (adapter == null)
return null;
var keyProperty = adapter.getKeyProp();
if (keyProperty == null)
return null;
var attribute = node.attr(keyProperty.nameId());
if (attribute == null)
return null;
if (attribute.optional())
return false;
return null;
};
UnconditionalRequiredPropertyCalculator.prototype.matches = function (attributeProperty, node) {
return universeHelpers.isRequiredProperty(attributeProperty);
};
UnconditionalRequiredPropertyCalculator.prototype.kind = function () {
return InsertionKind.BY_DEFAULT;
};
return UnconditionalRequiredPropertyCalculator;
}());
//# sourceMappingURL=defaultCalculator.js.map
"use strict";
var xmlutil = require('./xmlutil');
var contentprovider = require('./contentprovider');

@@ -11,3 +12,3 @@ var def = require('raml-definition-system');

catch (exception) {
return false;
return xmlutil.isXmlScheme(content);
}

@@ -17,2 +18,5 @@ }

function startDownloadingReferencesAsync(schemaContent, unit) {
if (xmlutil.isXmlScheme(schemaContent)) {
return su.getXMLSchema(schemaContent, new contentprovider.ContentProvider(unit)).loadSchemaReferencesAsync().then(function () { return unit; });
}
var schemaObject = su.getJSONSchema(schemaContent, new contentprovider.ContentProvider(unit));

@@ -29,3 +33,3 @@ var missedReferences = schemaObject.getMissingReferences([]).map(function (reference) { return schemaObject.contentAsync(reference); });

function getReferences(schemaContent, unit) {
var schemaObject = su.getJSONSchema(schemaContent, new contentprovider.ContentProvider(unit));
var schemaObject = su.createSchema(schemaContent, new contentprovider.ContentProvider(unit));
return schemaObject.getMissingReferences([], true);

@@ -32,0 +36,0 @@ }

declare function parseXML(value: string): any;
export = parseXML;
export declare function isXmlScheme(content: string): boolean;
export declare function parseXML(value: string): any;

@@ -0,4 +1,26 @@

"use strict";
/// <reference path="../../typings/main.d.ts" />
"use strict";
var DomParser = require("xmldom");
function elementChildrenByName(parent, tagName) {
var elements = parent.getElementsByTagName(tagName);
var result = [];
for (var i = 0; i < elements.length; i++) {
var child = elements[i];
if (child.parentNode === parent) {
result.push(child);
}
}
return result;
}
function isXmlScheme(content) {
try {
var doc = new DomParser().parseFromString(content);
var schemas = elementChildrenByName(doc, 'xs:schema');
return schemas.length > 0;
}
catch (exception) {
return false;
}
}
exports.isXmlScheme = isXmlScheme;
function xmlToJson(xml) {

@@ -88,3 +110,3 @@ // Create the return object

}
module.exports = parseXML;
exports.parseXML = parseXML;
//# sourceMappingURL=xmlutil.js.map
{
"name": "raml-1-parser",
"version": "1.1.12",
"version": "1.1.13",
"main": "dist/index.js",

@@ -39,3 +39,3 @@ "scripts": {

"q": "^1.0.0",
"raml-definition-system": "0.0.54",
"raml-definition-system": "0.0.55",
"then-request": "^2.2.0",

@@ -42,0 +42,0 @@ "ts-structure-parser": "0.0.12",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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