@rickyli79/json-schema-mock
v1.0.3
Published
Generate data base on given JSON Schema
Downloads
3
Maintainers
Readme
@rickyli79/json-schema-mock
English | 简体中文
Generate data base on given JSON Schema
Features
- As rich as possible, generate data base on schema
- Analyze and filter the impossible rules.
- View full test list : Test List
DEMO
- https://rickyli79.github.io/json-schema-mock/
- https://rickyli79.gitee.io/json-schema-mock/
Install
$ npm install @rickyli79/json-schema-mock
Usage
import {SchemaMock, Schema } from "json-schema-mock";
const schema: Schema = { type:"string" , minLength:1, maxLength:5 };
SchemaMock.parser(schema).then( (schemaMock)=>{
const data = schemaMock.mock();
console.log(JSON.stringify(data));
} );
Usage Examples
Not support & BUG
- Not support
$id
and$ref
- Not support
not
- BUG : mock data by
oneOf
may cannot valid by schema - BUG : mock data by
additionalProperties
inallOf
may cannot valid by schema - FLAW :
anyOf
andoneOf
will randomly use first aviable subSchema to generate data
Dependencies
- JSON validator : tdegrunt/jsonschema
- base data type mock : Mock.js