raml-typesystem
Advanced tools
Comparing version 0.0.38 to 0.0.39
@@ -127,3 +127,3 @@ "use strict"; | ||
try { | ||
so = su.getXMLSchema(strVal); | ||
so = su.getXMLSchema(strVal, this.provider); | ||
} | ||
@@ -148,2 +148,5 @@ catch (e) { | ||
} | ||
if (e.message == "Maximum call stack size exceeded") { | ||
return new ts.Status(ts.Status.ERROR, 0, "JSON schema contains circular references", this); | ||
} | ||
return new ts.Status(ts.Status.ERROR, 0, "Example does not conform to schema:" + e.message, this); | ||
@@ -150,0 +153,0 @@ } |
@@ -61,3 +61,3 @@ /// <reference path="../../typings/main.d.ts" /> | ||
export declare function getJSONSchema(content: string, provider: IContentProvider): any; | ||
export declare function getXMLSchema(content: string): any; | ||
export declare function getXMLSchema(content: string, provider: IContentProvider): any; | ||
export declare function createSchema(content: string, provider: IContentProvider): Schema; |
@@ -66,2 +66,5 @@ "use strict"; | ||
}()); | ||
var exampleKey = function (content, schema, contextPath) { | ||
return "__EXAMPLE_" + content + schema + contextPath; | ||
}; | ||
var JSONSchemaObject = (function () { | ||
@@ -231,3 +234,3 @@ function JSONSchemaObject(schema, provider) { | ||
if (alreadyAccepted === void 0) { alreadyAccepted = []; } | ||
var key = content + this.schema + this.provider.contextPath(); | ||
var key = exampleKey(content, this.schema, this.provider.contextPath()); | ||
var error = globalCache.getValue(key); | ||
@@ -424,3 +427,4 @@ if (error) { | ||
function getJSONSchema(content, provider) { | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(key) : false; | ||
if (rs && rs.provider) { | ||
@@ -430,7 +434,16 @@ return rs; | ||
var res = new JSONSchemaObject(content, provider); | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
return res; | ||
} | ||
exports.getJSONSchema = getJSONSchema; | ||
function getXMLSchema(content) { | ||
var schemaKey = function (provider, content) { | ||
var contextPath = ""; | ||
if (provider) { | ||
contextPath = provider.contextPath(); | ||
} | ||
var key = "__SCHEMA_" + content + contextPath; | ||
return key; | ||
}; | ||
function getXMLSchema(content, provider) { | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
@@ -448,3 +461,4 @@ if (rs) { | ||
function createSchema(content, provider) { | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(key) : false; | ||
if (rs) { | ||
@@ -456,3 +470,3 @@ return rs; | ||
if (useLint) { | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
} | ||
@@ -465,3 +479,3 @@ return res; | ||
if (useLint) { | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
} | ||
@@ -472,3 +486,3 @@ return res; | ||
if (useLint) { | ||
globalCache.setValue(content, new Error("Can not parse schema")); | ||
globalCache.setValue(key, new Error("Can not parse schema")); | ||
} | ||
@@ -475,0 +489,0 @@ return null; |
{ | ||
"name": "raml-typesystem", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -127,3 +127,3 @@ /// <reference path="../typings/main.d.ts" /> | ||
try { | ||
so = su.getXMLSchema(strVal); | ||
so = su.getXMLSchema(strVal, this.provider); | ||
} catch (e){ | ||
@@ -146,2 +146,5 @@ return ts.ok(); | ||
} | ||
if (e.message == "Maximum call stack size exceeded"){ | ||
return new ts.Status(ts.Status.ERROR,0,"JSON schema contains circular references",this); | ||
} | ||
return new ts.Status(ts.Status.ERROR,0,"Example does not conform to schema:"+e.message,this); | ||
@@ -148,0 +151,0 @@ } |
@@ -103,2 +103,5 @@ /// <reference path="../typings/main.d.ts" /> | ||
var exampleKey = function (content:any, schema:string, contextPath:string) { | ||
return "__EXAMPLE_" + content + schema + contextPath; | ||
}; | ||
export class JSONSchemaObject { | ||
@@ -302,3 +305,3 @@ jsonSchema: any; | ||
validate(content: any, alreadyAccepted: any[] = []): void { | ||
var key = content + this.schema + this.provider.contextPath(); | ||
var key = exampleKey(content,this.schema,this.provider.contextPath()); | ||
@@ -571,3 +574,4 @@ var error = globalCache.getValue(key); | ||
export function getJSONSchema(content: string, provider: IContentProvider) { | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(key) : false; | ||
if (rs && rs.provider) { | ||
@@ -577,7 +581,16 @@ return rs; | ||
var res = new JSONSchemaObject(content, provider); | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
return res; | ||
} | ||
export function getXMLSchema(content: string) { | ||
var schemaKey = function (provider:IContentProvider, content:string) { | ||
var contextPath = ""; | ||
if (provider) { | ||
contextPath = provider.contextPath(); | ||
} | ||
var key = "__SCHEMA_" + content + contextPath; | ||
return key; | ||
}; | ||
export function getXMLSchema(content: string, provider: IContentProvider) { | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
@@ -598,3 +611,4 @@ if (rs) { | ||
var rs = useLint ? globalCache.getValue(content) : false; | ||
var key = schemaKey(provider, content); | ||
var rs = useLint ? globalCache.getValue(key) : false; | ||
if (rs) { | ||
@@ -606,3 +620,3 @@ return rs; | ||
if (useLint) { | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
} | ||
@@ -615,3 +629,3 @@ return res; | ||
if (useLint) { | ||
globalCache.setValue(content, res); | ||
globalCache.setValue(key, res); | ||
} | ||
@@ -622,3 +636,3 @@ return res; | ||
if (useLint) { | ||
globalCache.setValue(content, new Error("Can not parse schema")) | ||
globalCache.setValue(key, new Error("Can not parse schema")) | ||
} | ||
@@ -625,0 +639,0 @@ return null; |
Sorry, the diff of this file is not supported yet
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
1806638
40541