{"id":42313151,"url":"https://github.com/mjwwit/tson-schema","last_synced_at":"2026-01-27T11:38:01.634Z","repository":{"id":44157145,"uuid":"172572438","full_name":"mjwwit/tson-schema","owner":"mjwwit","description":"A TypeScript API to create JSON-Schemas and TypeScript types","archived":false,"fork":false,"pushed_at":"2022-02-11T17:26:31.000Z","size":153,"stargazers_count":3,"open_issues_count":12,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T21:08:05.647Z","etag":null,"topics":["json-schema","ts","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjwwit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-25T19:40:46.000Z","updated_at":"2023-09-19T17:40:40.000Z","dependencies_parsed_at":"2022-09-09T16:01:58.405Z","dependency_job_id":null,"html_url":"https://github.com/mjwwit/tson-schema","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mjwwit/tson-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjwwit%2Ftson-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjwwit%2Ftson-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjwwit%2Ftson-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjwwit%2Ftson-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjwwit","download_url":"https://codeload.github.com/mjwwit/tson-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjwwit%2Ftson-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28319519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json-schema","ts","typescript"],"created_at":"2026-01-27T11:38:01.055Z","updated_at":"2026-01-27T11:38:01.625Z","avatar_url":"https://github.com/mjwwit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tson-schema\n\nThis project aims to bring you an easy way to create json-schemas and TypeScript types using a single API. This API is kept as close as possible to json-schema so you don't have to worry about learning yet another API. Support for new json-schema versions and new TypeScript versions is added on a best effort basis.\n\n__This is a work in progress! Known missing json-schema features include:__\n\n- `array.additionalItems`\n- `object.additionalProperties`\n- `$ref`\n- JSON-Schema conditional schemas (`if`/`else`)\n- Limited TypeScript support for:\n   - big enum schemas\n   - big allOf schemas\n\n## Installing\n\n```\nnpm install -S tson-schema\n```\n\nOr\n\n```\nyarn add tson-schema\n```\n\n## Usage\n\n```ts\nimport * as t from 'tson-schema'\n\n/**\n * Array\n */\nconst numberArraySchema = t.array({\n  items: t.number({\n    minimum: 1\n  }),\n  minItems: 2,\n  uniqueItems: true\n})\n\nnumberArraySchema.getSchema() // { type: 'array', items: { type: 'number', minimum: 1 }, minItems: 2, uniqueItems: true }\nnumberArraySchema.type        // number[]\n\n/**\n * Object\n */\nconst objectSchema = t.object({\n  properties: {\n    req: t.string(),\n    opt: t.tuple({\n      items: [t.integer()]\n    })\n  },\n  required: ['req']\n})\n\nobjectSchema.getSchema() // { type: 'object', properties: { req: { type: 'string' }, opt: { type: 'array', items: [{ type: 'integer' }] } }, required: ['req'] }\nobjectSchema.type        // { req: 'string', opt?: [number] }\n\n/**\n * Enum\n */\nconst enumSchema = t.enum(['A', 2, 'C', 4])\n\nenumSchema.getSchema() // { enum: ['A', 2, 'C', 4] }\nenumSchema.type        // 'A' | 2 | 'C' | 4\n\n/**\n * anyOf\n */\nconst anyOfSchema = t.anyOf([\n  s.const('A'),\n  s.integer()\n])\n\nenumSchema.getSchema() // { anyOf: [{ const: 'A' }, { type: 'integer' }] }\nenumSchema.type        // 'A' | number\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjwwit%2Ftson-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjwwit%2Ftson-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjwwit%2Ftson-schema/lists"}