raml-typesystem
Advanced tools
Comparing version 0.0.76 to 0.0.77
@@ -6,3 +6,3 @@ "use strict"; | ||
var jsonUtil = require("./jsonUtil"); | ||
///var DOMParser = require('xmldom').DOMParser; | ||
var DOMParser = require('xmldom').DOMParser; | ||
var ts = require("./typesystem"); | ||
@@ -665,3 +665,3 @@ var typesystem_1 = require("./typesystem"); | ||
} | ||
this.schemaString = schema; | ||
this.schemaString = this.handleReferenceElement(schema); | ||
} | ||
@@ -694,3 +694,3 @@ XMLSchemaObject.prototype.getType = function () { | ||
var doc; | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(xmlString); | ||
var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
@@ -726,3 +726,3 @@ var imports = elementChildrenByName(schema, 'import', this.namspacePrefix); | ||
var doc; | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(this.schemaString); | ||
var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
@@ -745,3 +745,3 @@ var imports = elementChildrenByName(schema, 'import', this.namspacePrefix); | ||
var doc; | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(xmlString); | ||
var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
@@ -806,3 +806,3 @@ var imports = elementChildrenByName(schema, 'import', this.namspacePrefix); | ||
XMLSchemaObject.prototype.handleReferenceElement = function (content) { | ||
var doc = ""; | ||
var doc = new DOMParser(domParserOptions).parseFromString(content); | ||
this.namspacePrefix = extractNamespace(doc); | ||
@@ -809,0 +809,0 @@ var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; |
{ | ||
"name": "raml-typesystem", | ||
"version": "0.0.76", | ||
"version": "0.0.77", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -14,3 +14,3 @@ import {XMLSchemaReference} from "raml-xml-validation"; | ||
///var DOMParser = require('xmldom').DOMParser; | ||
var DOMParser = require('xmldom').DOMParser; | ||
import ts = require("./typesystem"); | ||
@@ -830,3 +830,3 @@ import {messageRegistry} from "./typesystem"; | ||
private extraElementData: any = null; | ||
private namspacePrefix:string; | ||
@@ -845,3 +845,3 @@ | ||
this.schemaString = schema; | ||
this.schemaString = this.handleReferenceElement(schema); | ||
} | ||
@@ -880,3 +880,3 @@ | ||
} | ||
this.validate(xmlUtil.jsonToXml(object)); | ||
@@ -888,3 +888,3 @@ } | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(xmlString); | ||
@@ -912,3 +912,3 @@ var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
var patchedContent: string; | ||
try { | ||
@@ -928,3 +928,3 @@ patchedContent = this.collectReferences(loadedContent, fullPath, references); | ||
}); | ||
return doc.toString(); | ||
@@ -936,3 +936,3 @@ } | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(this.schemaString); | ||
@@ -945,5 +945,5 @@ var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
var refElements: any = imports.concat(includes); | ||
var result: string[] = []; | ||
refElements.forEach((refElement: any) => { | ||
@@ -958,3 +958,3 @@ var refString = refElement.getAttribute('schemaLocation'); | ||
}); | ||
return result; | ||
@@ -966,3 +966,3 @@ } | ||
doc = ""; | ||
doc = new DOMParser(domParserOptions).parseFromString(xmlString); | ||
@@ -983,3 +983,3 @@ var schema = elementChildrenByName(doc, 'schema', this.namspacePrefix)[0]; | ||
var reference: XMLSchemaReference = references[fullPath]; | ||
if(reference) { | ||
@@ -1011,3 +1011,3 @@ refElement.setAttribute('schemaLocation', "file_" + reference.virtualIndex + ".xsd"); | ||
} | ||
loadSchemaReferencesAsync(): Promise { | ||
@@ -1020,13 +1020,13 @@ return this.collectReferencesAsync(this.schemaString, this.provider.contextPath(), {}); | ||
var rs = this.contentToResult[xml]; | ||
if(rs === false) { | ||
return; | ||
} | ||
if(rs) { | ||
throw rs; | ||
} | ||
var references: any = {}; | ||
var patchedSchema = this.collectReferences(this.schemaString, this.provider.contextPath(), references); | ||
@@ -1039,9 +1039,9 @@ | ||
} | ||
var validationErrors = validator.validate(xml, Object.keys(references).map((key: string) => references[key])); | ||
this.acceptErrors("key", validationErrors, true); | ||
this.contentToResult[xml]=false; | ||
if(Object.keys(this.contentToResult).length>MAX_EXAMPLES_TRESHOLD){ | ||
@@ -1052,3 +1052,3 @@ this.contentToResult={} | ||
this.contentToResult[xml]=e; | ||
throw e; | ||
@@ -1059,3 +1059,3 @@ } | ||
private handleReferenceElement(content: string): string { | ||
var doc = ""; | ||
var doc = new DOMParser(domParserOptions).parseFromString(content); | ||
this.namspacePrefix = extractNamespace(doc); | ||
@@ -1092,3 +1092,3 @@ | ||
} | ||
private acceptErrors(key: any, errors: any[], throwImmediately = false): void { | ||
@@ -1095,0 +1095,0 @@ if(errors && errors.length>0){ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2004489