datatype-expansion
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "datatype-expansion", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Utility tool to expand a given RAML type and create a canonical form", | ||
@@ -39,3 +39,2 @@ "main": "src/index.js", | ||
"chai": "^4.1.1", | ||
"cross-env": "^5.0.5", | ||
"istanbul": "^0.4.5", | ||
@@ -42,0 +41,0 @@ "mkdirp": "^0.5.1", |
@@ -47,3 +47,3 @@ 'use strict' | ||
// 3.1. we initialize the variable `items` with the output of applying the algorithm to the value of the key `items` of the input `form` of type `Record[String]RAMLForm]` | ||
const items = toCanonical(form.items) | ||
const items = toCanonical(form.items || {type: 'any'}) | ||
const node = consistencyCheck(form) | ||
@@ -50,0 +50,0 @@ // 3.2. we initialize the variable `items-type` with the value of the `type` property of the `items` variable |
@@ -69,3 +69,3 @@ 'use strict' | ||
// 1.1. if `form` is a RAML built-in data type, we return `(Record "type" form)` | ||
if (types.indexOf(form) !== -1) { | ||
if (types.indexOf(form) !== -1 || form === 'object' || form === 'array') { | ||
return {type: form} | ||
@@ -170,3 +170,3 @@ } | ||
function expandArray (form, bindings, context) { | ||
form.items = expandForm(form.items, bindings, context) | ||
form.items = expandForm(form.items || 'any', bindings, context) | ||
return form | ||
@@ -173,0 +173,0 @@ } |
@@ -246,6 +246,12 @@ 'use strict' | ||
for (let elemSuper of sup.anyOf) { | ||
// 7.2.1. for each value `elem-sub` in the property `of` of `sub` | ||
for (let elemSub of sub.anyOf) { | ||
// 7.2.1.1. we add to `accum` the output of applying this algorithm to `elem-super` and `elem-sub` | ||
accum.push(minType(elemSuper, elemSub)) | ||
// 7.2.1. if `sub.of` is non-empty | ||
if (sub.anyOf.length > 0) { | ||
// 7.2.1.1. for each value `elem-sub` in the property `of` of `sub` | ||
for (let elemSub of sub.anyOf) { | ||
// 7.2.1.1.1. we add to `accum` the output of applying this algorithm to `elem-super` and `elem-sub` | ||
accum.push(minType(elemSuper, elemSub)) | ||
} | ||
} else { | ||
// 7.2.2. else if `sub.of` is empty, add `elem-super` to `accum` | ||
accum.push(elemSuper) | ||
} | ||
@@ -252,0 +258,0 @@ } |
@@ -173,2 +173,17 @@ 'use strict' | ||
}, | ||
ObjectInTypeArray: { | ||
properties: {}, | ||
type: 'object' | ||
}, | ||
ArrayInTypeArray: { | ||
items: { type: 'any' }, | ||
type: 'array' | ||
}, | ||
UnionInTypeArray: { | ||
anyOf: [ | ||
{ type: 'number' }, | ||
{ type: 'string' } | ||
], | ||
type: 'union' | ||
}, | ||
SimpleUnion: { | ||
@@ -175,0 +190,0 @@ additionalProperties: true, |
@@ -173,2 +173,21 @@ 'use strict' | ||
}, | ||
ObjectInTypeArray: { | ||
type: [{ type: 'object' }] | ||
}, | ||
ArrayInTypeArray: { | ||
type: [{ type: 'array' }] | ||
}, | ||
UnionInTypeArray: { | ||
type: [{ | ||
anyOf: [ | ||
{ | ||
type: 'number' | ||
}, | ||
{ | ||
type: 'string' | ||
} | ||
], | ||
type: 'union' | ||
}] | ||
}, | ||
SimpleUnion: { | ||
@@ -175,0 +194,0 @@ properties: { |
@@ -87,2 +87,11 @@ 'use strict' | ||
}, | ||
ObjectInTypeArray: { | ||
type: ['object'] | ||
}, | ||
ArrayInTypeArray: { | ||
type: ['array'] | ||
}, | ||
UnionInTypeArray: { | ||
type: ['number | string'] | ||
}, | ||
SimpleUnion: { | ||
@@ -89,0 +98,0 @@ properties: { |
Sorry, the diff of this file is too big to display
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
912030
16
3567