0.0.53 • Published 8 months ago

apipost-mock-schema v0.0.53

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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

8 months ago

0.0.52

8 months ago

0.0.53

8 months ago

0.0.50

8 months ago

0.0.42

9 months ago

0.0.43

9 months ago

0.0.44

9 months ago

0.0.46

9 months ago

0.0.47

9 months ago

0.0.48

9 months ago

0.0.49

9 months ago

0.0.41

10 months ago

0.0.40

1 year ago

0.0.39

1 year ago

0.0.38

1 year ago

0.0.37

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.32

1 year ago

0.0.33

1 year 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

3 years ago

0.0.21

3 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