![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | LICENSE | 3 months ago | 1.1K | |
![]() | README.md | 3 months ago | 3.8K | |
![]() | index.d.ts | 3 months ago | 72 | |
![]() | index.js | 3 months ago | 800 | |
![]() | mock.d.ts | 3 months ago | 155 | |
![]() | mock.js | 3 months ago | 4.7K | |
![]() | package.json | 3 months ago | 1.5K |
Simple utility to mock example objects based on JSON schema definitions
example
, default
anyOf
, allOf
, oneOf
email
hostname
ipv4
ipv6
uri
uri-reference
uri-template
json-pointer
date-time
uuid
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
mock-json-schema is Free and Open Source Software. Issues and pull requests are more than welcome!