1.0.3 • Published 3 years ago

@rickyli79/json-schema-mock v1.0.3

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

@rickyli79/json-schema-mock

NPM version npm download NPM

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

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 in allOf may cannot valid by schema
  • FLAW : anyOf and oneOf will randomly use first aviable subSchema to generate data

Dependencies

LICENSE

MIT License

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago