{"id":18484914,"url":"https://github.com/redocly/openapi-sampler","last_synced_at":"2025-12-12T04:24:57.481Z","repository":{"id":38751801,"uuid":"59937640","full_name":"Redocly/openapi-sampler","owner":"Redocly","description":":capital_abcd: Tool for generation samples based on OpenAPI(fka Swagger) payload/response schema","archived":false,"fork":false,"pushed_at":"2025-03-13T09:51:56.000Z","size":1358,"stargazers_count":198,"open_issues_count":10,"forks_count":51,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-05T18:14:01.031Z","etag":null,"topics":["fake","mock","openapi","openapi-sampler","openapi3","openapi31","payload","schema","swagger"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Redocly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-29T10:29:32.000Z","updated_at":"2025-05-01T15:39:16.000Z","dependencies_parsed_at":"2024-04-15T00:41:06.419Z","dependency_job_id":"f15818dc-feef-49b3-a903-3f54d079053d","html_url":"https://github.com/Redocly/openapi-sampler","commit_stats":{"total_commits":166,"total_committers":28,"mean_commits":5.928571428571429,"dds":0.2831325301204819,"last_synced_commit":"1b6adcbe0f202c225e1bd23f2dd2308aad4554bf"},"previous_names":["apis-guru/openapi-sampler"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redocly%2Fopenapi-sampler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redocly%2Fopenapi-sampler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redocly%2Fopenapi-sampler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Redocly%2Fopenapi-sampler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Redocly","download_url":"https://codeload.github.com/Redocly/openapi-sampler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253853409,"owners_count":21974106,"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":["fake","mock","openapi","openapi-sampler","openapi3","openapi31","payload","schema","swagger"],"created_at":"2024-11-06T12:43:34.290Z","updated_at":"2025-12-12T04:24:57.450Z","avatar_url":"https://github.com/Redocly.png","language":"JavaScript","readme":"# openapi-sampler\n\n[![Travis build status](http://img.shields.io/travis/Redocly/openapi-sampler.svg?style=flat)](https://travis-ci.org/Redocly/openapi-sampler) [![Coverage Status](https://coveralls.io/repos/Redocly/openapi-sampler/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/Redocly/openapi-sampler?branch=master) [![Dependency Status](https://david-dm.org/Redocly/openapi-sampler.svg)](https://david-dm.org/Redocly/openapi-sampler) [![devDependency Status](https://david-dm.org/Redocly/openapi-sampler/dev-status.svg)](https://david-dm.org/Redocly/openapi-sampler#info=devDependencies)\n\nTool for generation samples based on OpenAPI payload/response schema\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` with [`x-additionalPropertiesName`](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md#x-additionalpropertiesname)\n- Uses `const`, `examples`, `enum` and `default` where possible - in this order\n- Good array support: supports `contains`, `minItems`, `maxItems`, and tuples (`items` as an array)\n- Supports `minLength`, `maxLength`, `min`, `max`, `exclusiveMinimum`, `exclusiveMaximum`, ([limited](https://fakerjs.dev/api/helpers.html#fromregexp)) `pattern`\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- Has basic supports for JSON Schema draft 7 (thanks to [@P0lip](https://github.com/P0lip) from [@stoplightio](https://github.com/stoplightio) for contributing)\n\n## Installation\n\nInstall using [npm](https://docs.npmjs.com/getting-started/what-is-npm)\n\n    npm install openapi-sampler\n\nor using [yarn](https://yarnpkg.com)\n\n    yarn add openapi-sampler\n\nThen require it in your code:\n\n```js\nvar OpenAPISampler = require('openapi-sampler');\n```\n\n## Usage\n#### `OpenAPISampler.sample(schema, [options], [spec])`\n- **schema** (_required_) - `object`\nAn [OpenAPI Schema Object](http://swagger.io/specification/#schemaObject) or a 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- **spec** - whole specification where the schema is taken from. Required only when schema may contain `$ref`. **spec** must not contain any external references\n\n## Example\n```js\nconst OpenAPISampler = require('.');\nOpenAPISampler.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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredocly%2Fopenapi-sampler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredocly%2Fopenapi-sampler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredocly%2Fopenapi-sampler/lists"}