{"id":18447774,"url":"https://github.com/stoplightio/json-schema-sampler","last_synced_at":"2025-09-01T14:41:24.007Z","repository":{"id":40275601,"uuid":"357899758","full_name":"stoplightio/json-schema-sampler","owner":"stoplightio","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-27T09:45:48.000Z","size":1912,"stargazers_count":10,"open_issues_count":18,"forks_count":2,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-05T22:43:21.957Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stoplightio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-14T12:36:02.000Z","updated_at":"2025-03-15T18:34:47.000Z","dependencies_parsed_at":"2024-06-18T18:33:13.923Z","dependency_job_id":"4632a071-012d-4578-b55d-105b28cf9c53","html_url":"https://github.com/stoplightio/json-schema-sampler","commit_stats":{"total_commits":145,"total_committers":19,"mean_commits":7.631578947368421,"dds":"0.31034482758620685","last_synced_commit":"750b1bc1e6a5043212649d8edc4af281b0867d22"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fjson-schema-sampler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fjson-schema-sampler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fjson-schema-sampler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stoplightio%2Fjson-schema-sampler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stoplightio","download_url":"https://codeload.github.com/stoplightio/json-schema-sampler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755457,"owners_count":20990618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T07:14:23.891Z","updated_at":"2025-04-08T00:32:20.742Z","avatar_url":"https://github.com/stoplightio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @stoplight/json-schema-sampler\n\nIt's a fork of [openapi-sampler](https://github.com/Redocly/openapi-sampler) by Redocly, with focus on supporting JSON Schema Draft 7.\n\nTool for generation samples based on JSON Schema Draft 7.\n\n## Features\n\n- Deterministic (given a particular input, will always produce the same output)\n- Supports compound keywords: `allOf`, `oneOf`, `anyOf`, `if/then/else`\n- Supports `additionalProperties`\n- Uses `default`, `const`, `enum` and `examples` where possible\n- Good array support: supports `contains`, `minItems`, `maxItems`, and tuples (`items` as an array)\n- Supports `minLength`, `maxLength`, `min`, `max`, `exclusiveMinimum`, `exclusiveMaximum`\n- Supports the following `string` formats:\n  - email\n  - idn-email\n  - password\n  - date-time\n  - date\n  - time\n  - ipv4\n  - ipv6\n  - hostname\n  - idn-hostname\n  - uri\n  - uri-reference\n  - uri-template\n  - iri\n  - iri-reference\n  - uuid\n  - json-pointer\n  - relative-json-pointer\n  - regex\n- Infers schema type automatically following same rules as [json-schema-faker](https://www.npmjs.com/package/json-schema-faker#inferred-types)\n- Support for `$ref` resolving\n\n## Installation\n\nInstall using [npm](https://docs.npmjs.com/getting-started/what-is-npm)\n\n    npm install @stoplight/json-schema-sampler --save\n\nor using [yarn](https://yarnpkg.com)\n\n    yarn add @stoplight/json-schema-sampler\n\nThen require it in your code:\n\n```js\nconst JSONSchemaSampler = require('@stoplight/json-schema-sampler');\n```\n\n## Usage\n#### `JSONSchemaSampler.sample(schema, [options], [spec])`\n- **schema** (_required_) - `object`\nA JSON Schema Draft 7 document.\n- **options** (_optional_) - `object`\nAvailable options:\n  - **skipNonRequired** - `boolean`\n  Don't include non-required object properties not specified in [`required` property of the schema object](https://swagger.io/docs/specification/data-models/data-types/#required)\n  - **skipReadOnly** - `boolean`\n  Don't include `readOnly` object properties\n  - **skipWriteOnly** - `boolean`\n  Don't include `writeOnly` object properties\n  - **quiet** - `boolean`\n  Don't log console warning messages\n  - **maxSampleDepth** - `number`\n    Max depth sampler should traverse\n- **doc** - the whole schema where the schema is taken from. Might be useful when the `schema` passed is only a portion of the whole schema and $refs aren't resected. **doc** must not contain any external references\n\n## Example\n```js\nconst JSONSchemaSampler = require('@stoplight/json-schema-sampler');\nJSONSchemaSampler.sample({\n  type: 'object',\n  properties: {\n    a: {type: 'integer', minimum: 10},\n    b: {type: 'string', format: 'password', minLength: 10},\n    c: {type: 'boolean', readOnly: true}\n  }\n}, {skipReadOnly: true});\n// { a: 10, b: 'pa$$word_q' }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoplightio%2Fjson-schema-sampler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstoplightio%2Fjson-schema-sampler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstoplightio%2Fjson-schema-sampler/lists"}