{"id":15662,"library":"json-schema-test-data-generator","title":"JSON Schema Test Data Generator","description":"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.","status":"abandoned","version":"0.1.1","language":"javascript","source_language":"en","source_url":"git://github.com/bojand/json-schema-test-data-generator","tags":["javascript","json","jsonschema","json-schema","test","data","generator"],"install":[{"cmd":"npm install json-schema-test-data-generator","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-test-data-generator","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-test-data-generator","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only. Direct ESM imports are not supported and will require transpilation or a CommonJS wrapper.","wrong":"import generate from 'json-schema-test-data-generator';","symbol":"generate","correct":"const generate = require('json-schema-test-data-generator');"}],"quickstart":{"code":"const generate = require('json-schema-test-data-generator');\n\nconst schema = {\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"minLength\": 5\n    },\n    \"active\": {\n      \"type\": \"boolean\"\n    },\n    \"email\": {\n      \"type\": \"string\",\n      \"format\": \"email\"\n    },\n    \"accountNumber\": {\n      \"type\": \"number\"\n    }\n  },\n  \"required\": [\"name\", \"email\"]\n}\n\nconsole.dir(generate(schema));","lang":"javascript","description":"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."},"warnings":[{"fix":"Consider migrating to actively maintained alternatives like `json-schema-faker` or `json-schema-generator` for better support and features, especially if working with modern JSON Schema drafts or requiring `$ref` resolution.","message":"The project is abandoned, with the last code changes dating back 8 years. This means there will be no further updates, bug fixes, or security patches, which could lead to unaddressed vulnerabilities or compatibility issues with newer Node.js versions or JSON Schema drafts.","severity":"breaking","affected_versions":"0.1.1"},{"fix":"Manually dereference your JSON schemas using a separate tool or library (e.g., `json-schema-deref`) before passing them to `json-schema-test-data-generator`. Alternatively, use a generator that natively supports `$ref`.","message":"The generator does not support `$ref` keywords in JSON schemas. Schemas must be 'fully expanded' before being passed to the `generate` function, meaning all references must be resolved beforehand.","severity":"gotcha","affected_versions":"0.1.1"},{"fix":"Manually review the generated test data to ensure all critical schema paths and edge cases are covered. For comprehensive testing, consider supplementing with hand-crafted test cases or using more robust, actively developed schema fakers.","message":"The utility generates 'various (but not all) combinations' of test data. This means complex JSON Schema constructs (e.g., `oneOf`, `anyOf`, `not`, advanced array/object constraints, specific string patterns) might not be fully covered, potentially leading to incomplete test suites.","severity":"gotcha","affected_versions":"0.1.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use the CommonJS `require` syntax: `const generate = require('json-schema-test-data-generator');`","cause":"Attempting to use `import generate from 'json-schema-test-data-generator';` in a modern ESM environment without proper CommonJS interoperability.","error":"TypeError: generate is not a function"},{"fix":"This package is noted to cover 'various (but not all)' combinations. For schemas using advanced keywords like `allOf`, `anyOf`, `oneOf`, or `not`, manual inspection of generated tests is required. If the coverage is insufficient, consider a different, more actively maintained library that explicitly lists support for these keywords, such as `json-schema-faker`.","cause":"The generator has limited support for complex JSON Schema keywords and might not correctly interpret or generate data for all possible combinations.","error":"Generated data does not match schema expectations for complex types (e.g., allOf, anyOf)"}],"ecosystem":"npm"}