Skip to content

RickyLi79/json-schema-mock

Repository files navigation

@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

About

Generate data base on given JSON Schema

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published