{"id":13772763,"url":"https://github.com/meeshkan/json-schema-fast-check","last_synced_at":"2025-05-11T05:33:36.019Z","repository":{"id":44078349,"uuid":"204938973","full_name":"meeshkan/json-schema-fast-check","owner":"meeshkan","description":"json-schema + fast-check = Property testing in JS with JSON Schema","archived":true,"fork":false,"pushed_at":"2022-02-12T13:02:17.000Z","size":491,"stargazers_count":21,"open_issues_count":10,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T11:05:23.680Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/meeshkan.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}},"created_at":"2019-08-28T13:30:47.000Z","updated_at":"2025-03-15T12:37:36.000Z","dependencies_parsed_at":"2022-09-20T12:24:39.666Z","dependency_job_id":null,"html_url":"https://github.com/meeshkan/json-schema-fast-check","commit_stats":null,"previous_names":["unmock/json-schema-fast-check"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fjson-schema-fast-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fjson-schema-fast-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fjson-schema-fast-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meeshkan%2Fjson-schema-fast-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meeshkan","download_url":"https://codeload.github.com/meeshkan/json-schema-fast-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253523689,"owners_count":21921815,"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-08-03T17:01:07.588Z","updated_at":"2025-05-11T05:33:35.672Z","avatar_url":"https://github.com/meeshkan.png","language":"TypeScript","funding_links":[],"categories":["Packages","📦 Modules/Packages"],"sub_categories":["Testing"],"readme":"[![CircleCI](https://circleci.com/gh/unmock/json-schema-fast-check.svg?style=svg)](https://circleci.com/gh/unmock/json-schema-fast-check)\n[![codecov](https://codecov.io/gh/unmock/json-schema-fast-check/branch/master/graph/badge.svg)](https://codecov.io/gh/unmock/json-schema-fast-check)\n\n# json-schema-fast-check\n\n[JSON Schema](https://json-schema.org) is a useful way to define input and output schemas.\n\nProperty testing is a useful way to make sure that a function behaves as expected with *any* valid input.\n\n`json-schema-fast-check` implements arbitrary JSON Schema values using the [`fast-check`](https://github.com/dubzzz/fast-check) library for property testing.\n\n## Example\n\n```typescript\nimport jsfc from \"json-schema-fast-check\";\nimport fc from \"fast-check\";\n\nconst getAge = (data: any) =\u003e\n    typeof data === \"object\" \u0026\u0026 typeof data.age === \"number\"\n    ? Math.floor(data.age)\n    : null;\n\nconst userSchema = {\n    type: \"object\",\n    properties: {\n        required: [\"name\", \"id\"],\n        name: {\n            type: \"string\"\n        },\n        age: {\n            type: \"integer\",\n            minimum: 0\n        },\n        id: {\n            type: \"integer\"\n        }\n    }\n}\n\ntest(\"my function yields positive age or null\", () =\u003e {\n    fc.assert(fc.property(jsfc(userSchema), user =\u003e {\n        const age = getAge(user);\n        return age === null || age \u003e= 0;\n    }));\n});\n```\n\n## API\n\nThe API has only two functions - the default one (which we call `jsfc` just cuz) and a helper function called `generate`.\n\n### `jsfc` (default)\n\n```typescript\nconst arbitrary = jsfc(mySchema);\n```\n\nCreates a [`fast-check` arbitrary](https://github.com/dubzzz/fast-check/blob/master/documentation/1-Guides/Arbitraries.md) from valid JSON schema.\n\n### `generate`\n\n```typescript\nconst json = generate(mySchema);\n```\n\nGenerates a single valid JSON object that conforms to the schema.\n\n## A note on JSON Schema\n\nThe actual schema used here is not JSON Schema but rather a subset of JSON Schema called \"The Subest of JSON Schema I Was Not Too Lazy To Define.\" I also added some `faker-js` sugar (see the tests).\n\n## Contributing\n\nThanks for wanting to contribute! We will soon have a contributing page detaling how to contribute. Meanwhile, there are plenty of features that haven't been implemented yet. Please check out our [open issues](https://github.com/meeshkan/json-schema-fast-check/issues). We'd really appreciate your help!\n\nPlease note that this project is governed by the [Meeshkan Community Code of Conduct](https://github.com/meeshkan/code-of-conduct). By participating in this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeshkan%2Fjson-schema-fast-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeeshkan%2Fjson-schema-fast-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeeshkan%2Fjson-schema-fast-check/lists"}