raml-typesystem
Advanced tools
Comparing version 0.0.67 to 0.0.68
@@ -672,3 +672,2 @@ "use strict"; | ||
} | ||
var provider = n.contentProvider ? n.contentProvider() : null; | ||
if (n.kind() == NodeKind.SCALAR) { | ||
@@ -681,3 +680,3 @@ var valString = n.value(); | ||
else { | ||
sp = typeExpressions.parseToType("" + valString, r, provider); | ||
sp = typeExpressions.parseToType("" + valString, r, n); | ||
} | ||
@@ -696,3 +695,3 @@ if (name == null) { | ||
n.children().forEach(function (x) { | ||
supers.push(typeExpressions.parseToType("" + x.value(), r, provider)); | ||
supers.push(typeExpressions.parseToType("" + x.value(), r, n)); | ||
}); | ||
@@ -755,3 +754,3 @@ var res = ts.derive(name, supers); | ||
var typeAttributeContentProvider = tp.contentProvider ? tp.contentProvider() : null; | ||
superTypes = [typeExpressions.parseToType("" + valString, r, provider, typeAttributeContentProvider)]; | ||
superTypes = [typeExpressions.parseToType("" + valString, r, n, typeAttributeContentProvider)]; | ||
} | ||
@@ -776,3 +775,3 @@ } | ||
return x.value(); | ||
}).map(function (y) { return typeExpressions.parseToType("" + y, r, provider); }); | ||
}).map(function (y) { return typeExpressions.parseToType("" + y, r, n); }); | ||
} | ||
@@ -842,3 +841,3 @@ else if (tp.kind() == NodeKind.MAP) { | ||
else { | ||
componentTypes = [typeExpressions.parseToType("" + valString, r, provider)]; | ||
componentTypes = [typeExpressions.parseToType("" + valString, r, n)]; | ||
} | ||
@@ -863,3 +862,3 @@ } | ||
return y.value(); | ||
}).map(function (y) { return typeExpressions.parseToType("" + y, r, provider); }); | ||
}).map(function (y) { return typeExpressions.parseToType("" + y, r, n); }); | ||
var err = ts.error(messageRegistry.ITEMS_SHOULD_BE_REFERENCE_OR_INLINE_TYPE, actualResult); | ||
@@ -866,0 +865,0 @@ err.setValidationPath({ name: "items" }); |
@@ -31,2 +31,3 @@ /// <reference path="../../typings/main.d.ts" /> | ||
private patchSchema(schema); | ||
private removeFragmentPartOfIDs(obj); | ||
private collectRefContainers(rootObject, refContainers); | ||
@@ -33,0 +34,0 @@ validate(content: any, alreadyAccepted?: any[]): void; |
@@ -256,2 +256,29 @@ /// <reference path="../typings/main.d.ts" /> | ||
}; | ||
JSONSchemaObject.prototype.removeFragmentPartOfIDs = function (obj) { | ||
var _this = this; | ||
if (!obj) { | ||
return; | ||
} | ||
if (Array.isArray(obj)) { | ||
obj.forEach(function (x) { return _this.removeFragmentPartOfIDs(x); }); | ||
return; | ||
} | ||
else if (typeof obj != "object") { | ||
return; | ||
} | ||
var idValue = obj.id; | ||
if (idValue && typeof obj.id == "string") { | ||
var ind = idValue.indexOf("#"); | ||
if (ind >= 0) { | ||
idValue = idValue.substring(0, ind).trim(); | ||
if (!idValue) { | ||
delete obj.id; | ||
} | ||
else { | ||
obj.id = idValue; | ||
} | ||
} | ||
} | ||
Object.keys(obj).forEach(function (x) { return _this.removeFragmentPartOfIDs(obj[x]); }); | ||
}; | ||
JSONSchemaObject.prototype.collectRefContainers = function (rootObject, refContainers) { | ||
@@ -422,2 +449,3 @@ var _this = this; | ||
} | ||
this.removeFragmentPartOfIDs(json); | ||
if (json.id) { | ||
@@ -424,0 +452,0 @@ json.id = json.id.trim(); |
import ts = require("./typesystem"); | ||
import schemaUtil = require('./schemaUtil'); | ||
import { ParseNode } from "./parse"; | ||
import typeExpressionDefs = require("./typeExpressionUtil"); | ||
@@ -8,3 +9,3 @@ export declare type BaseNode = typeExpressionDefs.BaseNode; | ||
export declare type Parens = typeExpressionDefs.Parens; | ||
export declare function parseToType(val: string, t: ts.TypeRegistry, contentProvider?: schemaUtil.IContentProvider, typeAttributeContentProvider?: schemaUtil.IContentProvider): ts.AbstractType; | ||
export declare function parseToType(val: string, t: ts.TypeRegistry, contentProvidingNode?: ParseNode, typeAttributeContentProvider?: schemaUtil.IContentProvider): ts.AbstractType; | ||
export declare function storeToString(t: ts.AbstractType): string; | ||
@@ -11,0 +12,0 @@ export declare function visit(node: BaseNode, action: (n: BaseNode) => void): void; |
@@ -5,4 +5,3 @@ "use strict"; | ||
var restrictions_1 = require("./restrictions"); | ||
function parseToType(val, t, contentProvider, typeAttributeContentProvider) { | ||
if (contentProvider === void 0) { contentProvider = null; } | ||
function parseToType(val, t, contentProvidingNode, typeAttributeContentProvider) { | ||
if (typeAttributeContentProvider === void 0) { typeAttributeContentProvider = null; } | ||
@@ -14,2 +13,9 @@ try { | ||
if (json || (q.charAt(0) == '<' && q.length > 1 && q.charAt(1) != '<')) { | ||
var typeChild = contentProvidingNode; | ||
var n = void 0; | ||
do { | ||
n = typeChild; | ||
typeChild = n.childWithKey("type"); | ||
} while (typeChild); | ||
var contentProvider = n && n.contentProvider && n.contentProvider(); | ||
return new ts.ExternalType("", q, json, contentProvider, typeAttributeContentProvider); | ||
@@ -16,0 +22,0 @@ } |
@@ -7,5 +7,5 @@ var gulp = require('gulp'); | ||
var join = require('path').join; | ||
var ts = require('gulp-typescript'); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
var rename = require('gulp-rename') | ||
//var ts = require('gulp-typescript'); | ||
//var sourcemaps = require('gulp-sourcemaps'); | ||
//var rename = require('gulp-rename') | ||
var fs = require('fs'); | ||
@@ -15,5 +15,5 @@ var path = require('path'); | ||
var tsProject = ts.createProject('tsconfig.json', { | ||
typescript: require('typescript') | ||
}); | ||
// var tsProject = ts.createProject('tsconfig.json', { | ||
// typescript: require('typescript') | ||
// }); | ||
@@ -20,0 +20,0 @@ gulp.task("typedoc", function() { |
{ | ||
"name": "raml-typesystem", | ||
"version": "0.0.67", | ||
"version": "0.0.68", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -735,5 +735,2 @@ import ts=require("./typesystem"); | ||
var provider: su.IContentProvider = (<any>n).contentProvider ? (<any>n).contentProvider() : null; | ||
if (n.kind()==NodeKind.SCALAR){ | ||
@@ -746,3 +743,3 @@ var valString = n.value(); | ||
else{ | ||
sp = typeExpressions.parseToType(""+valString,r, provider) | ||
sp = typeExpressions.parseToType(""+valString,r, n) | ||
} | ||
@@ -761,3 +758,3 @@ if (name==null){ | ||
n.children().forEach(x=>{ | ||
supers.push(typeExpressions.parseToType(""+x.value(),r, provider)) | ||
supers.push(typeExpressions.parseToType(""+x.value(),r, n)) | ||
}) | ||
@@ -822,3 +819,3 @@ var res=ts.derive(name,supers); | ||
(<any>tp).contentProvider ? (<any>tp).contentProvider() : null; | ||
superTypes=[typeExpressions.parseToType(""+valString,r, provider, typeAttributeContentProvider)]; | ||
superTypes=[typeExpressions.parseToType(""+valString,r, n, typeAttributeContentProvider)]; | ||
} | ||
@@ -843,3 +840,3 @@ } | ||
return x.value(); | ||
}).map(y=>typeExpressions.parseToType(""+y,r, provider)); | ||
}).map(y=>typeExpressions.parseToType(""+y,r, n)); | ||
} | ||
@@ -911,3 +908,3 @@ else if (tp.kind()==NodeKind.MAP){ | ||
else{ | ||
componentTypes=[typeExpressions.parseToType(""+valString,r, provider)]; | ||
componentTypes=[typeExpressions.parseToType(""+valString,r, n)]; | ||
} | ||
@@ -932,3 +929,3 @@ } | ||
return y.value(); | ||
}).map(y=>typeExpressions.parseToType(""+y,r, provider)); | ||
}).map(y=>typeExpressions.parseToType(""+y,r, n)); | ||
@@ -935,0 +932,0 @@ var err=ts.error(messageRegistry.ITEMS_SHOULD_BE_REFERENCE_OR_INLINE_TYPE,actualResult); |
@@ -345,2 +345,32 @@ /// <reference path="../typings/main.d.ts" /> | ||
private removeFragmentPartOfIDs(obj:any){ | ||
if(!obj){ | ||
return; | ||
} | ||
if(Array.isArray(obj)){ | ||
obj.forEach((x:any)=>this.removeFragmentPartOfIDs(x)); | ||
return; | ||
} | ||
else if(typeof obj != "object"){ | ||
return; | ||
} | ||
let idValue = obj.id; | ||
if(idValue && typeof obj.id=="string"){ | ||
let ind = idValue.indexOf("#"); | ||
if(ind>=0){ | ||
idValue = idValue.substring(0,ind).trim(); | ||
if(!idValue){ | ||
delete obj.id; | ||
} | ||
else{ | ||
obj.id = idValue; | ||
} | ||
} | ||
} | ||
Object.keys(obj).forEach(x=>this.removeFragmentPartOfIDs(obj[x])); | ||
} | ||
private collectRefContainers(rootObject: any, refContainers: any): void { | ||
@@ -565,2 +595,4 @@ Object.keys(rootObject).forEach(key => { | ||
this.removeFragmentPartOfIDs(json); | ||
if(json.id) { | ||
@@ -567,0 +599,0 @@ json.id = json.id.trim(); |
@@ -5,3 +5,3 @@ import typeExpression=require("./typeExpressionParser") | ||
import {ComponentShouldBeOfType} from "./restrictions"; | ||
import {AdditionalPropertyIs} from "./restrictions"; | ||
import {ParseNode} from "./parse"; | ||
import typeExpressionDefs = require("./typeExpressionUtil") | ||
@@ -15,6 +15,6 @@ | ||
export function parseToType(val:string,t:ts.TypeRegistry, contentProvider: schemaUtil.IContentProvider = null, | ||
export function parseToType(val:string,t:ts.TypeRegistry, contentProvidingNode?:ParseNode, | ||
typeAttributeContentProvider: schemaUtil.IContentProvider = null):ts.AbstractType{ | ||
try { | ||
var q=val.trim(); | ||
@@ -26,2 +26,13 @@ | ||
let typeChild = contentProvidingNode; | ||
let n:ParseNode; | ||
do { | ||
n = typeChild; | ||
typeChild = n.childWithKey("type"); | ||
} | ||
while(typeChild); | ||
let contentProvider: schemaUtil.IContentProvider = | ||
n && (<any>n).contentProvider && (<any>n).contentProvider(); | ||
return new ts.ExternalType("", q, json, contentProvider, typeAttributeContentProvider); | ||
@@ -28,0 +39,0 @@ } |
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
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
2249205
49336