{"_id":"@df-legacy/json-schema-faker","_rev":"2-d47eeac2cd2f3b371621aeb00faff55d","name":"@df-legacy/json-schema-faker","dist-tags":{"latest":"0.2.16"},"versions":{"0.2.16":{"name":"@df-legacy/json-schema-faker","version":"0.2.16","description":"JSON-Schema + fake data generators","homepage":"http://json-schema-faker.js.org","main":"index.js","scripts":{"dev":"jasmine-node spec --color --coffee --noStack --verbose --autotest --watch lib","dev:lint":"eslint lib","dev:spec":"jasmine-node spec --coffee --captureExceptions","cover":"istanbul cover --root lib --x '**/spec/**' -- jasmine-node spec --coffee","cover:up":"codecov --file=coverage/lcov.info --disable=gcov -e TRAVIS_NODE_VERSION","test":"npm run dev:lint && npm run dev:spec","build":"node build/dist.js"},"contributors":[{"name":"Alvaro Cabrera","email":"pateketrueke@gmail.com"},{"name":"Tomasz Ducin","email":"tomasz@ducin.it","url":"http://ducin.it"}],"repository":{"type":"git","url":"git+https://github.com/json-schema-faker/json-schema-faker.git"},"bugs":{"url":"https://github.com/json-schema-faker/json-schema-faker/issues"},"license":"MIT","dependencies":{"faker":"5.5.3","chance":"~1.0.1","deref":"~0.6.3","randexp":"~0.4.2"},"devDependencies":{"browserify":"^13.0.0","clone":"^1.0.2","codecov":"^1.0.1","eslint":"^2.7.0","fs-extra":"^0.26.7","glob":"^7.0.3","istanbul":"^0.4.3","jasmine-node":"^2.0.0","jayschema":"^0.3.1","lodash.template":"^4.2.4","semver":"^5.1.0","tv4":"^1.2.7","uglify-js":"^2.6.2","z-schema":"^3.17.0"},"keywords":["json","jsonschema","fake","mocks"],"directories":{"lib":"lib"},"author":"","gitHead":"9376f19f875a8eea5bc2a3461a05946d08a180c0","_id":"@df-legacy/json-schema-faker@0.2.16","_nodeVersion":"14.17.6","_npmVersion":"6.14.15","dist":{"integrity":"sha512-0eE1q4gdai9XuJeENpaOf8e+wMIzVAHoG0fTJzPmIH7eQqUFfmXazqS6j21LajBhfC+g14GMrsCBkkvGI5ta2w==","shasum":"7ab4d304d83d88b135191273150a359c378905c2","tarball":"https://registry.npmjs.org/@df-legacy/json-schema-faker/-/json-schema-faker-0.2.16.tgz","fileCount":26,"unpackedSize":60911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzwanCRA9TVsSAnZWagAAAPQP/jEVjnyjO1A2eVum5gk4\n8Akwm+X0JAEPT3rTD2AuuOACIg9luYuLEFZ088pQGj7663A2xVnz1RIv9OSi\nEwmX+7V+rxCtEKx6HAPZvGqXv9Ilzww/yAJPTBO/WvsO729OW5hP8k9dfFNB\nIy5W7AyPbSw0GY0e+1EgEbzpn+4DAsqOrcLJmjZhURXi2IIzicsQ04fwA1lT\nrcwmV8v9Fbs3CyMmJVOBDEjNkC+PWo25jFgeAr6m5ZP4hDQVryQgRPpiOYPY\n8bwsS/Vn3RByuz8VlNni9BZenMKrCkJ15TdV2Y0eymXiHz3/v9UW12XtYZqZ\n0Da7rDiba+NL4Ycd8bHwWPGjFjTn+t9zn577bjrhXnUFl+SRs8xSmXhUPOtR\n5xRBBnsA0TZ1KWquUZdUAugseP5y14wHPkJdw1kJrKLtMZOuSO6ztVMluaPW\n6C8nmVcFFf5vvPL5oJt6EXAvF+BVUk2OFj22yeGvF5A6KiR4VGgR/fvdvJm8\nzFhpVRq21wFIP2YtLt9jpk31PyFs4pkdYJboRuQkqfOCjfZBxRDbTZtaXTd0\nkBgavOFMhn/wf4w/BOP1uy62RRT4jBc5ZB5izJH8ptLfzI0hZmPKkBidq/VF\npnICxYWJ+SvDnWw5xk9vYegGsFRDQlNaB/PylbOD7YSewGg5apcCiCKI/Kur\nwGQt\r\n=j1M/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBnH+9FpUd1ExPLHDHMHFzigU8mhYcMn8CP/krc8xFzfAiEAkJlZCe98vNvvyh6HRzDxIRdkxFh/ZlCkQm7BfCF+/Mo="}]},"_npmUser":{"name":"di9","email":"other@ytka.org"},"maintainers":[{"name":"di9","email":"other@ytka.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-schema-faker_0.2.16_1633329504578_0.5237583143793447"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-04T06:38:24.511Z","0.2.16":"2021-10-04T06:38:24.772Z","modified":"2022-04-05T04:13:03.483Z"},"maintainers":[{"name":"di9","email":"other@ytka.org"}],"description":"JSON-Schema + fake data generators","homepage":"http://json-schema-faker.js.org","keywords":["json","jsonschema","fake","mocks"],"repository":{"type":"git","url":"git+https://github.com/json-schema-faker/json-schema-faker.git"},"contributors":[{"name":"Alvaro Cabrera","email":"pateketrueke@gmail.com"},{"name":"Tomasz Ducin","email":"tomasz@ducin.it","url":"http://ducin.it"}],"bugs":{"url":"https://github.com/json-schema-faker/json-schema-faker/issues"},"license":"MIT","readme":"![JSON Schema Faker logo](logo/JSF_logo.png)\n\n[![Build Status](https://travis-ci.org/json-schema-faker/json-schema-faker.svg?branch=master)](https://travis-ci.org/json-schema-faker/json-schema-faker)\n[![NPM version](https://badge.fury.io/js/json-schema-faker.svg)](http://badge.fury.io/js/json-schema-faker)\n[![Bower version](https://badge.fury.io/bo/json-schema-faker.svg)](https://badge.fury.io/bo/json-schema-faker)\n[![Coverage Status](https://codecov.io/github/json-schema-faker/json-schema-faker/coverage.svg?branch=master)](https://codecov.io/github/json-schema-faker/json-schema-faker?branch=master)\n[![Inline docs](http://inch-ci.org/github/json-schema-faker/json-schema-faker.svg?branch=master)](http://inch-ci.org/github/json-schema-faker/json-schema-faker)\n\n[![Dependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker)\n[![devDependency Status](https://david-dm.org/json-schema-faker/json-schema-faker/dev-status.svg)](https://david-dm.org/json-schema-faker/json-schema-faker#info=devDependencies)\n\nUse [JSON Schema](http://json-schema.org/) along with fake generators to provide consistent fake data for your system.\n\n***Want to support `jsf`?*** We are looking for a free database hosting, please see the [call for providers](https://github.com/json-schema-faker/json-schema-faker/issues/89).\n\n### migrating to TypeScript\n\n![JSON Schema Faker migration to TypeScript](migration.jpg)\n\nJSON-Schema-Faker is being migrated into TypeScript.\n\n# Table of contents\n\n- Basics\n  - [JSON-schema-faker](#fake-your-schemas)\n  - [Online demo](#online-demo)\n  - [Install](#install)\n    - [npm](#npm)\n    - [bower](#bower)\n    - [cdnjs](#cdnjs)\n  - [Overview](#overview)\n  - [Example usage](#example-usage)\n    - [Gist demos](#gist-demos)\n- Advanced\n  - [Supported keywords](#supported-keywords)\n  - [Using references](#using-references)\n  - [Faking values](#faking-values)\n  - [Custom formats](#custom-formats)\n  - [Extending dependencies](#extending-dependencies)\n  - [Inferred Types](#inferred-types)\n  - [Bundling](#bundling)\n  - [Automation](#automation)\n    - [Grunt plugin](#grunt-plugin)\n- Misc\n  - [Resources](#resources)\n  - [Motivation](#motivation)\n  - [Contribution](#contribution)\n\n## Online demo\n\nSee [online demo](http://json-schema-faker.js.org/).\n\n## Install\n\n`jsf` is installable through 3 different channels:\n\n### npm\n\nInstall `json-schema-faker` with npm:\n\n    npm install json-schema-faker --save\n\n### bower\n\nInstall `json-schema-faker` with bower:\n\n    bower install json-schema-faker --save\n\n### cdnjs\n\nJSON-Schema-faker is also available at [cdnjs.com](https://www.cdnjs.com/libraries/json-schema-faker). This means you can just include the script file into your HTML:\n\n    # remember to update the version number!\n    <script type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/json-schema-faker/0.2.8/json-schema-faker.min.js\"></script>\n\nIt will be fetched from the [Content Delivery Network](https://en.wikipedia.org/wiki/Content_delivery_network) without installing any node.js package.\n\nYou can see [an example JS fiddle based on `jsf` loaded from cdnjs](https://jsfiddle.net/ftzhnmzq/).\n\n## Overview\n\nJSON-Schema-faker (or `jsf` for short) combines two things:\n\n * The [JSON-schema specification](http://json-schema.org/), that defines what is the allowed content of a JSON document\n * Fake data generators, that are used to generate basic or complex data, conforming to the schema. Following libraries come bundled with jsf:\n   * [faker.js](https://github.com/Marak/faker.js)\n   * [chance.js](https://github.com/victorquinn/chancejs)\n   * [randexp](https://github.com/fent/randexp.js)\n\n## Example usage\n\n```javascript\nvar jsf = require('json-schema-faker');\n\nvar schema = {\n  type: 'object',\n  properties: {\n    user: {\n      type: 'object',\n      properties: {\n        id: {\n          $ref: '#/definitions/positiveInt'\n        },\n        name: {\n          type: 'string',\n          faker: 'name.findName'\n        },\n        email: {\n          type: 'string',\n          format: 'email',\n          faker: 'internet.email'\n        }\n      },\n      required: ['id', 'name', 'email']\n    }\n  },\n  required: ['user'],\n  definitions: {\n    positiveInt: {\n      type: 'integer',\n      minimum: 0,\n      exclusiveMinimum: true\n    }\n  }\n};\n\nvar sample = jsf(schema);\n\nconsole.log(sample.user.name);\n// output: John Doe\n```\n\n### Gist demos\n\nClone these gists and execute them locally (each gist has its own readme with instructions):\n\n * [jsf console](https://gist.github.com/ducin/9f2364ccde2e9248fbcd) - minimal example of jsf working directly under command line\n * [jsf grunt](https://gist.github.com/ducin/87e0b55bddd1801d3d99) - example of jsf working under grunt.js\n\n## Supported keywords\n\nNote that `jsf` supports (currently) the JSON-Schema specification **draft-04** only. Below is the list of supported keywords:\n\n- **$ref** &mdash; Resolve internal references only, and/or external if provided.\n- **required** &mdash; All required properties are guaranteed, if not can be omitted.\n- **pattern** &mdash; Generate samples based on RegExp values.\n- **format** &mdash; Core formats only: date-time, email, hostname, ipv4, ipv6 and uri.\n- **enum** &mdash; Returns any of these enumerated values.\n- **minLength/maxLength** &mdash; Applies length constraints to string values.\n- **minimum/maximum** &mdash; Applies constraints to numeric values.\n- **exclusiveMinimum/exclusiveMaximum** &mdash; Adds exclusivity for numeric values.\n- **multipleOf** &mdash; Multiply constraints for numeric values.\n- **items** &mdash; Support for subschema and fixed item values.\n- **minItems/maxItems** &mdash; Adds length constraints for array items.\n- **uniqueItems** &mdash; Applies uniqueness constraints for array items.\n- **additionalItems** &mdash; Partially supported (?)\n- **allOf/oneOf/anyOf** &mdash; Subschema combinators.\n- **properties** &mdash; Object properties to be generated.\n- **minProperties/maxProperties** &mdash; Adds length constraints for object properties.\n- **patternProperties** &mdash; RegExp-based object properties.\n- **additionalProperties** &mdash; Partially supported (?)\n- **dependencies** &mdash; Not supported yet (?)\n- **not** &mdash; Not supported yet (?)\n\n## Using references\n\nInline references are fully supported (json-pointers) but external can't be resolved by `jsf`.\n\nIn order to achieve that you can use [refaker](https://github.com/json-schema-faker/refaker) and then use the resolved schemas:\n\n```javascript\nvar schema = {\n  type: 'object',\n  properties: {\n    someValue: {\n      $ref: 'otherSchema'\n    }\n  }\n};\n\nvar refs = [\n  {\n    id: 'otherSchema',\n    type: 'string'\n  }\n];\n\nvar sample = jsf(schema, refs);\n\nconsole.log(sample.someValue);\n// output: voluptatem\n```\n\n## Faking values\n\n`jsf` has built-in generators for core-formats, [Faker.js](http://marak.com/faker.js/) and [Chance.js](http://chancejs.com/) are also supported.\n\nYou can use **faker** or **chance** properties but they are optional:\n\n```json\n{\n  \"type\": \"string\",\n  \"faker\": \"internet.email\"\n}\n```\n\nThe above schema will invoke:\n\n```javascript\nrequire('faker').internet.email();\n```\n\nAnother example is passing arguments to the generator:\n\n```json\n{\n  \"type\": \"string\",\n  \"chance\": {\n    \"email\": {\n      \"domain\": \"fake.com\"\n    }\n  }\n}\n```\n\nAnd will invoke:\n\n```javascript\nvar Chance = require('chance'),\n  chance = new Chance();\n\nchance.email({ \"domain\": \"fake.com\" });\n```\n\nIf you pass an array, they will be used as raw arguments.\n\nNote that both generators has higher precedence than **format**.\n\nYou can also use standard JSON Schema keywords, e.g. `pattern`:\n\n```json\n{\n  \"type\": \"string\",\n  \"pattern\": \"yes|no|maybe|i don't know\"\n}\n```\n\n**BREAKING CHANGES**\n\n> Since `0.3.0` the `faker` and `chance` dependencies aren't shipped by default,\n> in order to use both generators you MUST install them with `npm install faker chance --save`.\n\n## Custom formats\n\nAdditionally, you can add custom generators for those:\n\n```javascript\njsf.formats('semver', function(gen, schema) {\n  return gen.randexp('^\\\\d\\\\.\\\\d\\\\.\\\\d{1,2}$');\n});\n```\n\nNow that format can be generated:\n\n```json\n{\n  \"type\": \"string\",\n  \"format\": \"semver\"\n}\n```\n\nUsage:\n\n- **formats()** &mdash; Return all registered formats (custom only)\n- **formats(obj)** &mdash; Register formats by key/value &rarr; name/callback\n- **formats(name)** &mdash; Returns that format generator (undefined if not exists)\n- **formats(name, callback)** &mdash; Register a custom format by name/callback\n\nCallback:\n\n- **gen** (object) &mdash; Built in generators\n  - **faker** (object) &mdash; Faker.js instance\n  - **chance** (object) &mdash; Chance.js instance\n  - **randexp** (function) &mdash; Randexp generator\n- **schema** (object) &mdash; The schema for input\n\nNote that custom generators has lower precedence than core ones.\n\n## Extending dependencies\n\nYou may extend [Faker.js](http://marak.com/faker.js/):\n\n```javascript\nvar jsf = require('json-schema-faker');\n\njsf.extend('faker', function(faker){\n  faker.locale = \"de\"; // or any other language\n  faker.custom = {\n    statement: function(length) {\n      return faker.name.firstName() + \" has \" + faker.finance.amount() + \" on \" + faker.finance.account(length) + \".\";\n    }\n  };\n  return faker;\n});\n\nvar schema = {\n  \"type\": \"string\",\n  \"faker\": {\n    \"custom.statement\": [19]\n  }\n}\n\nvar sample = jsf(schema);\n```\n\nor if you want to use [faker's *individual localization packages*](https://github.com/Marak/faker.js#individual-localization-packages), simply do the following:\n\n```js\njsf.extend('faker', function() {\n  // just ignore the passed faker instance\n  var faker = require('faker/locale/de');\n  // do other stuff\n  return faker;\n});\n```\n\nYou can also extend [Chance.js](http://chancejs.com/), using built-in [chance.mixin](http://chancejs.com/#mixin) function:\n\n```javascript\nvar jsf = require('json-schema-faker');\n\njsf.extend('chance', function(chance){\n  chance.mixin({\n    'user': function() {\n      return {\n        first: chance.first(),\n        last: chance.last(),\n        email: chance.email()\n      };\n    }\n  });\n\n  return chance;\n});\n\nvar schema = {\n  \"type\": \"string\",\n  \"chance\": \"user\"\n}\n\nvar sample = jsf(schema);\n```\n\nThe first parameter of `extend` function is the generator name (`faker` or `chance`). The second one is the function that accepts the dependency library; the function alters the library and **returns it**.\n\n## Inferred Types\n\nJSON Schema does not require you to provide the `type` property for your JSON Schema documents and document fragments.\n\nBut since `jsf` uses the `type` property to create the proper fake data, we attempt to infer the type whenever it is not provided. We do this based on the JSON Schema validation properties you use.\n\n> Now this means that if you do not use any of the JSON Schema validation properties, jsf will not be able to infer the type for you and you will need to **explicitly** set your `type` manually.)\n\nBelow is the list of JSON Schema validation properties and the inferred type based on the property:\n\n**array**\n\n* `additionalItems`\n* `items`\n* `maxItems`\n* `minItems`\n* `uniqueItems`\n\n**integer** *(Number uses the same properties so if you need `number`, set your `type` explicitly)*\n\n* `exclusiveMaximum`\n* `exclusiveMinimum`\n* `maximum`\n* `minimum`\n* `multipleOf`\n\n**object**\n\n* `additionalProperties`\n* `dependencies`\n* `maxProperties`\n* `minProperties`\n* `patternProperties`\n* `properties`\n* `required`\n\n**string**\n\n* `maxLength`\n* `minLength`\n* `pattern`\n\n## Bundling\n\nJSON-Schema-faker might be used in Node.js as well as in the browser. In order to execute `jsf` in a browser, you should include the distribution file from [`dist`](dist) directory. Each new version of `jsf` is bundled using [browserify](http://browserify.org/) and stored by the library maintainers. The bundle includes full versions of all dependencies.\n\nHowever, you may want to bundle a smaller package of `jsf`, because:\n* you want to reduce the bundle file size\n* you don't need all languages from faker.js\n* you wish to use chance.js only and get rid of other dependencies\n* or for any other reason...\nIn that case you may bundle the distribution yourself manually. It's easily achievable: just modify the [`lib/util/container.js`](lib/util/container.js) file and either remove o rmodify the `require` calls (they're directly used by browserify to include dependencies). Automation of this feature is expected in near future.\n\n## Automation\n\n### Grunt plugin\n\nUse [grunt-jsonschema-faker](https://github.com/json-schema-faker/grunt-jsonschema-faker)\nto automate running `json-schema-faker` against your JSON schemas.\n\n## Resources\n\n* [JSON, JSON Schema & JSON-schema-faker](https://www.youtube.com/watch?v=TkqiUG3j_Xw) - WarsawJS meetup presentation recording, a step-by-step guide to JSON-related tools, including `jsf`\n\n## Motivation\n\nThere were some existing projects or services trying to achieve similar goals as `jsf`:\n\n- http://www.json-generator.com/\n- https://github.com/unindented/fake-json\n- https://github.com/jonahkagan/schematic-ipsum\n- https://www.npmjs.org/package/json-schema-mock\n- https://github.com/thaume/json-schema-processor\n- https://github.com/andreineculau/json-schema-random\n- https://github.com/murgatroid99/json-schema-random-instance\n- https://github.com/tomarad/JSON-Schema-Instantiator\n\nbut they were either incomplete, outdated, broken or non-standard. That's why `jsf` was created.\n\n## Contribution\n\n* [Alvaro Cabrera](https://twitter.com/pateketrueke)\n* [Tomasz Ducin](https://twitter.com/tomasz_ducin)\n* [Jeremy Whitlock](https://twitter.com/whitlockjc)\n* artwork by [Ajay Karat](http://www.devilsgarage.com/)\n\nAny contribution is well received, please see [contribution guide](CONTRIBUTING.md).\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/json-schema-faker/json-schema-faker/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","readmeFilename":"README.md"}