0.0.53 • Published 1 year ago

apipost-mock-schema v0.0.53

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

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.50

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.41

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

2 years ago

0.0.33

2 years ago

0.0.31

2 years 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

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.22

3 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

4 years ago

0.0.5

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago