Comparing version 1.2.0 to 1.3.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
const schemeToJSON = require('schema-to-json'); | ||
const formatLeafApiValue = require('format-leaf-api-value'); | ||
@@ -23,3 +24,3 @@ module.exports = () => { | ||
const apiData = yield genApiData(apiFilePath); | ||
this.body = removeSplitLine(apiData); | ||
this.body = formatLeafApiValue(apiData); | ||
}; | ||
@@ -163,30 +164,1 @@ }; | ||
// } | ||
function getValue(value) { | ||
const arr = value.split('|'); | ||
if (arr.length < 2) return value; | ||
const maps = { | ||
string: arr[0], | ||
number: Number(arr[0]), | ||
boolean: arr[0] === 'true', | ||
}; | ||
return maps[arr[1]] ? maps[arr[1]] : arr[0]; | ||
} | ||
function removeSplitLine(obj) { | ||
if (obj === null || typeof obj !== 'object') { | ||
return obj; | ||
} | ||
const temp = obj.constructor(); | ||
for (const key in obj) { | ||
if (typeof obj[key] === 'string') { | ||
temp[key] = getValue(obj[key]); | ||
} else { | ||
temp[key] = removeSplitLine(obj[key]); | ||
} | ||
} | ||
return temp; | ||
} |
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.3.0"></a> | ||
# [1.3.0](https://github.com/eggjs/egg-leaf/compare/v1.2.0...v1.3.0) (2017-12-26) | ||
### Features | ||
* use format-leaf-api-value ([236d4e1](https://github.com/eggjs/egg-leaf/commit/236d4e1)) | ||
<a name="1.2.0"></a> | ||
@@ -7,0 +17,0 @@ # [1.2.0](https://github.com/eggjs/egg-leaf/compare/v1.1.0...v1.2.0) (2017-12-26) |
{ | ||
"name": "egg-leaf", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Mock server for egg", | ||
@@ -17,3 +17,4 @@ "eggPlugin": { | ||
"decomment": "^0.9.0", | ||
"md-to-schema": "^1.1.0", | ||
"format-leaf-api-value": "^1.0.0", | ||
"md-to-schema": "^1.1.1", | ||
"mockjs": "^1.0.1-beta3", | ||
@@ -20,0 +21,0 @@ "schema-to-json": "^1.0.0" |
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
7069
6
155
+ Addedformat-leaf-api-value@^1.0.0
+ Addedformat-leaf-api-value@1.0.0(transitive)
Updatedmd-to-schema@^1.1.1