0.0.53 • Published 5 months ago

apipost-mock-schema v0.0.53

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

🚀 apipost-mock-schema

Package Quality

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:

  • email
  • 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.51

5 months ago

0.0.52

5 months ago

0.0.53

5 months ago

0.0.50

6 months ago

0.0.42

7 months ago

0.0.43

7 months ago

0.0.44

7 months ago

0.0.46

7 months ago

0.0.47

7 months ago

0.0.48

7 months ago

0.0.49

7 months ago

0.0.41

8 months ago

0.0.40

10 months ago

0.0.39

10 months ago

0.0.38

10 months ago

0.0.37

10 months ago

0.0.34

10 months ago

0.0.35

10 months ago

0.0.36

10 months ago

0.0.32

12 months ago

0.0.33

11 months ago

0.0.31

1 year ago

0.0.30

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.22

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.16

3 years ago

0.0.18

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.5

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago