mock-from-json-schema
v0.1.4
Published
[![Build Status](https://travis-ci.org/boycgit/mock-from-json-schema.svg?branch=master)](https://travis-ci.org/boycgit/mock-from-json-schema) [![Coverage Status](https://coveralls.io/repos/github/boycgit/mock-from-json-schema/badge.svg?branch=master)](htt
Downloads
37
Readme
mock-from-json-schema
Simple utility to mock example objects based on JSON schema definitions. Copy from mock-json-schema, but not use lodash (less bundle size)
Installation
Node.js / Browserify
npm install mock-from-json-schema --save
import mock from "mock-from-json-schema";
var schema = {
"title": "配置",
"description": "",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "商品名称",
"title": "name"
},
"list": {
"type": "array",
"title": "list",
"description": "列表",
"items": {
"title": "",
"description": "",
"type": "object",
"properties": {
"itemName": {
"type": "string",
"description": "子项名称",
"title": "itemName"
}
},
"required": [
"itemName"
]
}
}
},
"required": [
"name"
]
};
console.log(555, mock(schema));
// 输出:
// {
// "name": "string",
// "list": [
// {
// "itemName": "string"
// }
// ]
// }
Build & test
npm run build
npm test
npm run doc
then open the generated out/index.html
file in your browser.
License
MIT.