0.0.8 • Published 10 years ago

json-schema-mock v0.0.8

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
10 years ago

json-schema-mock

data mocker for json-schema.

Available keywords ( for now )

  • enum
  • properties
  • items
  • minItems
  • maxItems
  • minLength
  • maxLength
  • multipleOf
  • minimum
  • maximum
  • exclusiveMinimum
  • exclusiveMaximum
  • allOf,oneOf,anyOf
  • format 具体类型支持参考:json-schema-format

Usage

var DataMocker = require( 'json-schema-mock' );
var schema = {
     "type": "object",
     "description": "activity info",
     "properties": {
         "state": {
             "type": "string",
             "description": "current activity state",
             "enum": ["wait", "process", "over"]
         },
         "deadline": {
             "type": "number",
             "description": "deadline of the activity"
         },
         "remainDays": {
             "type": "integer",
             "description": "days left."
         }
     },
     "required": ["state", "deadline", "remainDays", "needDays", "seasonNum"]
}

console.log( DataMocker( schema ) );

Will output:

{
    state: 'wait',
    deadline: 5268.8,
    remainDays: 1460,
    needDays: 3315,
    seasonNum: 4
}
0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago