@rickyli79/json-schema-mock
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

@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

Dependencies (3)

Dev Dependencies (7)

Package Sidebar

Install

npm i @rickyli79/json-schema-mock

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

97.8 kB

Total Files

33

Last publish

Collaborators

  • rickyli79