项目作者: TuRing-CDS

项目描述 :
模拟生成数据,基于mockjs和jsonschema
高级语言: JavaScript
项目地址: git://github.com/TuRing-CDS/cds-mock.git
创建时间: 2017-03-02T13:03:05Z
项目社区:https://github.com/TuRing-CDS/cds-mock

开源协议:

下载


TuRing-CDS

cds-mock

How to use

  1. npm install cds-mock --save

Example

schema.json

  1. {
  2. "title":"user",
  3. "properties":{
  4. "id":{
  5. "description":"The unique identifier for user",
  6. "type":"integer"
  7. },
  8. "userName":{
  9. "description":"Name of the user",
  10. "type":"string",
  11. "minLength":"6",
  12. "maxLength":"12"
  13. },
  14. "nickName":{
  15. "description":"NickName of the user",
  16. "type":"string",
  17. }
  18. },
  19. "required":["id","userName"]
  20. }

Test.js

  1. const Mock = require('cds-mock')
  2. const schema = require('./schema.json');
  3. Mock.mock(schema)
  4. => { id: 10001, userName:"xxaegxgxg", nickName: "乱七八糟啥的"}