npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

json-schema-mock

0.0.8 • Public • Published

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
}

install

npm i json-schema-mock

Downloadsweekly downloads

1

version

0.0.8

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability