JSON Schema Test Data Generator

0.1.1 · abandoned · verified Tue Apr 21

The `json-schema-test-data-generator` utility is designed to create sample test data objects based on a provided JSON schema. It generates an array of test scenarios, each indicating whether the generated data is `valid` against the schema, the `data` itself, a descriptive `message`, and an optional `property` key. As of version 0.1.1, the package is considered abandoned, with its last commit occurring 8 years ago. It focuses on covering various combinations for testing against a schema, including required and optional properties, and basic type mismatches. Its primary differentiator is generating both valid and intentionally invalid data scenarios with descriptive messages, helping users quickly create a test suite without manual data construction. Due to its abandoned status, users should be aware that it will not receive bug fixes, security updates, or new features, and might not support newer JSON Schema drafts or complex constructs.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the generator and use it with a basic JSON schema to produce an array of test data objects, including both valid and invalid scenarios.

const generate = require('json-schema-test-data-generator');

const schema = {
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 5
    },
    "active": {
      "type": "boolean"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "accountNumber": {
      "type": "number"
    }
  },
  "required": ["name", "email"]
}

console.dir(generate(schema));

view raw JSON →