0.0.31 • Published 8 days ago
apipost-mock-schema v0.0.31
🚀 apipost-mock-schema
Simple utility to mock example objects based on JSON schema definitions
Features
Minimal & deterministic. Predictable single example with no randomisation involved
TypeScript types included
Supports $ref pointers
Thoroughly tested feature set
Supports example, default
Supports anyOf, allOf, oneOf
Built-in examples for following string formats:
- hostname
- ipv4
- ipv6
- uri
- uri-reference
- uri-template
- json-pointer
- date-time
- uuid
Install
$ npm install apipost-mock-schema
Usage
const schema = {
type: 'array',
items: {
type: 'object',
properties: {
id: {
type: 'integer',
minimum: 1,
},
name: {
type: 'string',
example: 'John Doe',
},
email: {
type: 'string',
format: 'email',
},
},
},
};
const MockSchema = require('apipost-mock-schema');
const myMockSchema = new MockSchema();
myMockSchema.mock(schema).then(res => {
console.log(res)
// will return
/*
[
{
"id": 7156472017141059,
"name": "John Doe",
"email": "y.hbm@tsqxod.dm"
}
]
*/
}).catch(err => {
console.log(err)
})
0.0.31
8 days ago
0.0.30
6 months ago
0.0.26
7 months ago
0.0.27
7 months ago
0.0.28
7 months ago
0.0.23
11 months ago
0.0.24
11 months ago
0.0.25
11 months ago
0.0.22
12 months ago
0.0.20
1 year ago
0.0.21
1 year ago
0.0.16
1 year ago
0.0.18
1 year ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.5
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago