Comparing version 4.0.0-beta6 to 4.0.0-beta7
@@ -0,1 +1,6 @@ | ||
4.0.0-beta7 - October 4, 2016 | ||
- Fixed JS error when `body` is used as a property (#14) | ||
- Removed all the empty examples arrays | ||
- Fixed `key` properties that were sometimes integers | ||
4.0.0-beta6 - September 29, 2016 | ||
@@ -2,0 +7,0 @@ - Fixed examples array |
28
index.js
@@ -14,2 +14,6 @@ #!/usr/bin/env node | ||
function _isObject(obj) { | ||
return obj === Object(obj); | ||
} | ||
// EXAMPLE INPUT: | ||
@@ -28,4 +32,10 @@ // { | ||
function _objectToArray(obj) { | ||
if (Array.isArray(obj)) { | ||
return obj; | ||
} | ||
return Object.keys(obj).map((key) => { | ||
obj[key].key = key; | ||
if (_isObject(obj[key])) { | ||
obj[key].key = key; | ||
} | ||
return obj[key]; | ||
@@ -75,6 +85,2 @@ }); | ||
function _isObject(obj) { | ||
return obj === Object(obj); | ||
} | ||
function _expandTypes(arr, ramlObj) { | ||
@@ -96,11 +102,11 @@ return arr.map((obj) => { | ||
return arr.map((obj) => { | ||
if (typeof obj.examples === 'undefined') { | ||
obj.examples = []; | ||
if (obj.examples && obj.examples.length) { | ||
obj.examples = obj.examples.map(example => (example.value ? example.value : example)); | ||
} | ||
if (obj.examples.length) { | ||
obj.examples = obj.examples.map(example => example.value ? example.value : example); | ||
} | ||
if (obj.structuredExample) { | ||
if (typeof obj.examples === 'undefined') { | ||
obj.examples = []; | ||
} | ||
if (obj.structuredExample) { | ||
obj.examples.push(obj.structuredExample.value); | ||
@@ -107,0 +113,0 @@ delete obj.example; |
{ | ||
"name": "raml2obj", | ||
"description": "RAML to object", | ||
"version": "4.0.0-beta6", | ||
"version": "4.0.0-beta7", | ||
"author": { | ||
@@ -34,3 +34,3 @@ "name": "Kevin Renskers", | ||
"lintfix": "eslint --fix ./", | ||
"test": "mocha 'test/*.js' --reporter progress" | ||
"test": "mocha 'test/*.spec.js' --reporter progress" | ||
}, | ||
@@ -37,0 +37,0 @@ "files": [ |
@@ -18,3 +18,3 @@ # RAML to object | ||
## Usage | ||
``` | ||
```js | ||
var raml2obj = require('raml2obj'); | ||
@@ -21,0 +21,0 @@ |
12030
204