@api-components/api-example-generator
Advanced tools
Comparing version
@@ -641,20 +641,3 @@ import {PolymerElement} from '@polymer/polymer/polymer-element.js'; | ||
} | ||
let prefix = this._getAmfKey(this.ns.w3.xmlSchema); | ||
if (prefix !== this.ns.w3.xmlSchema) { | ||
prefix += ':'; | ||
} | ||
switch (dt) { | ||
case prefix + 'boolean': | ||
case this.ns.w3.xmlSchema + 'boolean': | ||
return value === 'true' ? true : false; | ||
case prefix + 'integer': | ||
case this.ns.w3.xmlSchema + 'integer': | ||
case prefix + 'number': | ||
case this.ns.w3.xmlSchema + 'number': | ||
if (isNaN(value)) { | ||
return 0; | ||
} | ||
return Number(value); | ||
default: return value; | ||
} | ||
return this._typeToValue(value, dt); | ||
} | ||
@@ -783,2 +766,19 @@ /** | ||
} | ||
const dtKey = this._getAmfKey(this.ns.w3.shacl.name + 'datatype'); | ||
let dt = range[dtKey]; | ||
if (!dt) { | ||
return value || ''; | ||
} | ||
if (dt instanceof Array) { | ||
dt = dt[0]; | ||
} | ||
return this._typeToValue(value, dt['@id']); | ||
} | ||
/** | ||
* Casts the value to given data type represented in AMF notation. | ||
* @param {String} value Value encoded in AMF | ||
* @param {String} type AMF data type | ||
* @return {String|Number|Boolean} Casted value. | ||
*/ | ||
_typeToValue(value, type) { | ||
let prefix = this._getAmfKey(this.ns.w3.xmlSchema); | ||
@@ -792,11 +792,3 @@ if (prefix !== this.ns.w3.xmlSchema) { | ||
} | ||
const dtKey = this._getAmfKey(this.ns.w3.shacl.name + 'datatype'); | ||
let dt = range[dtKey]; | ||
if (!dt) { | ||
return value || ''; | ||
} | ||
if (dt instanceof Array) { | ||
dt = dt[0]; | ||
} | ||
switch (dt['@id']) { | ||
switch (type) { | ||
case prefix + 'boolean': | ||
@@ -803,0 +795,0 @@ case ramlPrefix + 'boolean': |
@@ -6,3 +6,4 @@ { | ||
"tracked-examples/tracked-to-linked.raml": "RAML 1.0", | ||
"APIC-188/APIC-188.raml": "RAML 1.0" | ||
"APIC-188/APIC-188.raml": "RAML 1.0", | ||
"APIC-187/APIC-187.raml": "RAML 1.0" | ||
} |
@@ -11,3 +11,3 @@ { | ||
"name": "@api-components/api-example-generator", | ||
"version": "3.0.0-preview.1", | ||
"version": "3.0.0-preview.2", | ||
"license": "Apache-2.0", | ||
@@ -14,0 +14,0 @@ "main": "api-example-generator.js", |
@@ -66,9 +66,7 @@ { | ||
"thresholds": { | ||
"thresholds": { | ||
"global": { | ||
"statements": 80, | ||
"branches": 80, | ||
"functions": 90, | ||
"lines": 80 | ||
} | ||
"global": { | ||
"statements": 80, | ||
"branches": 80, | ||
"functions": 90, | ||
"lines": 80 | ||
} | ||
@@ -75,0 +73,0 @@ } |
Sorry, the diff of this file is too big to display
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
5326452
11.32%71
7.58%314485
12.68%