/ etherpad / src / node_modules / mock-json-schema /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[   ]LICENSE3 months ago1.1K 
[TXT]README.md3 months ago3.8K 
[TXT]index.d.ts3 months ago 72  
[   ]index.js3 months ago800  
[TXT]mock.d.ts3 months ago155  
[   ]mock.js3 months ago4.7K 
[   ]package.json3 months ago1.5K 
README.md

mock-json-schema

CI Dependencies npm version npm downloads Total alerts Language grade: JavaScript License Sponsored Buy me a coffee

Simple utility to mock example objects based on JSON schema definitions

Features

Usage

const { mock } = require('mock-json-schema');
const assert = require('assert');

const schema = {
  type: 'array',
  items: {
    type: 'object',
    properties: {
      id: {
        type: 'integer',
        minimum: 1,
      },
      name: {
        type: 'string',
        example: 'John Doe',
      },
      email: {
        type: 'string',
        format: 'email',
      },
    },
  },
};

assert.deepEqual(mock(schema), [{ id: 1, name: 'John Doe', email: 'user@example.com' }]);

View more examples

Contributing

mock-json-schema is Free and Open Source Software. Issues and pull requests are more than welcome!

The Chilicorn

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80