{"id":15365430,"url":"https://github.com/epiphone/json-schema-type-mapper","last_synced_at":"2026-02-12T02:38:48.016Z","repository":{"id":51566612,"uuid":"221367576","full_name":"epiphone/json-schema-type-mapper","owner":"epiphone","description":"Type-level conversion of JSON Schema into Typescript types","archived":false,"fork":false,"pushed_at":"2022-12-04T20:31:19.000Z","size":131,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-05T11:56:18.718Z","etag":null,"topics":["json-schema","json-schema-generator","jsonschema","typescript-types"],"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/epiphone.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-11-13T03:49:16.000Z","updated_at":"2024-08-26T12:20:08.000Z","dependencies_parsed_at":"2023-01-22T23:30:56.698Z","dependency_job_id":null,"html_url":"https://github.com/epiphone/json-schema-type-mapper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/epiphone/json-schema-type-mapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fjson-schema-type-mapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fjson-schema-type-mapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fjson-schema-type-mapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fjson-schema-type-mapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epiphone","download_url":"https://codeload.github.com/epiphone/json-schema-type-mapper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epiphone%2Fjson-schema-type-mapper/sbom","scorecard":{"id":379085,"data":{"date":"2025-08-11","repo":{"name":"github.com/epiphone/json-schema-type-mapper","commit":"e84d36a39483a2bada5e3948bbed98d3589a994c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/epiphone/json-schema-type-mapper/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/epiphone/json-schema-type-mapper/test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T14:58:12.271Z","repository_id":51566612,"created_at":"2025-08-18T14:58:12.271Z","updated_at":"2025-08-18T14:58:12.271Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29355212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","json-schema-generator","jsonschema","typescript-types"],"created_at":"2024-10-01T13:14:45.110Z","updated_at":"2026-02-12T02:38:47.996Z","avatar_url":"https://github.com/epiphone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-schema-type-mapper\n[![npm version](https://badge.fury.io/js/json-schema-type-mapper.svg)](https://badge.fury.io/js/json-schema-type-mapper)\n\n## Caution! Experimental software ahead. Use at your own peril.\n\nType-level conversion of JSON Schema (draft 7) into TypeScript types: **handle JSON Schemas as TypeScript types without code generation**.\n\n```typescript\nimport { Schema } from `json-schema-type-mapper`\n\ndeclare const myString: Schema\u003c{ type: 'string' }\u003e\n//      resolves to --\u003e string\n```\n\n## Install\n\n`yarn add json-schema-type-mapper`\n\n## Use case\n\nSuppose you're dealing with the following JSON Schema:\n\n```typescript\ninterface User {\n  type: 'object'\n  properties: {\n    id: {\n      type: 'number'\n    }\n    name: {\n      type: 'string'\n    }\n  }\n  required: ['id']\n  additionalProperties: false\n}\n```\n\nAnd a function whose input conforms to that schema:\n\n```typescript\nfunction saveUser(user: any) {\n  // ...\n}\n```\n\nThe question is, how would you define `user` parameter's type? There's a couple of ways to go about it. Either\n- a) manually write out a TypeScript type definition that matches the above JSON Schema, or\n- b) use a code generation tool such as [`json-schema-to-typescript`](https://github.com/bcherny/json-schema-to-typescript) to convert the JSON Schema to a TypeScript interface.\n\nI'd probably go the manual route in a simple case like this and opt for code generation with more complex schemas. This library, however, provides a bit of a middle ground between the two by leveraging the type system:\n\n```typescript\nimport { Schema } from 'json-schema-type-mapper'\n\nfunction saveUser(user: Schema\u003cUser\u003e) {\n  // ...\n}\n```\n\nNow `user`'s type resolves to `{ id: number; name?: string }`. We get automatic conversion from JSON Schema to TypeScript, all by leveraging the type system.\n\nCompared to code generation, this method has a number of [limitations](#Unsupported) resulting from the type system's limitations. We get pretty far though, which in itself is testament to the impressive capabilities of TypeScript's type system.\n\nFor a thorough list of supported features and examples check [the test file](./index.test-d.ts).\n\n## Complex example\n\n```typescript\ntype User = Schema\u003c{\n  definitions: {\n    address: {\n      $id: '#address'\n      properties: {\n        city: { type: 'string' }\n        country: { type: 'string'; enum: ['FI', 'SV', 'NO'] }\n      }\n      required: ['city', 'country']\n    }\n  }\n  allOf: [\n    { $ref: '#address' },\n    {\n      type: 'object'\n      properties: {\n        id: {\n          anyOf: [\n            { type: 'number' },\n            { type: 'array'; items: { type: 'number' } }\n          ]\n        }\n        name: {\n          type: ['string', 'null']\n        }\n      }\n      required: ['name']\n    }\n  ]\n}\u003e\n\n// resolves to:\n\ntype User = {\n  [x: string]: JSONValue\n  name: string | null\n  id?: number | number[] | undefined\n  city: string\n  country: \"FI\" | \"SV\" | \"NO\"\n}\n```\n\n## TODO\n\n- [ ] define schema as variable (`const schema = { ... } as const`) instead of interface\n    - requires handling something like `DeepReadonly\u003cJSONSchema\u003e` since `as const` turns everything `readonly`\n- [ ] [object `dependencies`](https://json-schema.org/understanding-json-schema/reference/object.html#dependencies)\n    - [ ] [property dependencies](https://json-schema.org/understanding-json-schema/reference/object.html#property-dependencies)\n    - [ ] [schema dependencies](https://json-schema.org/understanding-json-schema/reference/object.html#schema-dependencies)\n- [x] [`allOf`, `anyOf`](https://json-schema.org/understanding-json-schema/reference/combining.html)\n- [ ] [`if`, `then`, `else`](https://json-schema.org/understanding-json-schema/reference/conditionals.html)\n- [x] [`$id`](https://json-schema.org/understanding-json-schema/structuring.html#using-id-with-ref)\n\n## Unsupported\n\n- path references like `{ \"$ref\": \"#/definitions/User\" }`; consider [using `$id`s](https://json-schema.org/understanding-json-schema/structuring.html#using-id-with-ref) instead!\n- `not` only works on primitive types such as `{ \"not\": { \"type\": [\"number\", \"string\"] } }`\n- [object `propertyNames`](https://json-schema.org/understanding-json-schema/reference/object.html#property-names)\n- [object `minProperties`/`maxProperties`](https://json-schema.org/understanding-json-schema/reference/object.html#size)\n- [object `patternProperties`](https://json-schema.org/understanding-json-schema/reference/object.html#pattern-properties)\n- [tuple `items: [...]`](https://json-schema.org/understanding-json-schema/reference/array.html#list-validation) limited to a maximum of 6 items for now\n- [array `contains`](https://json-schema.org/understanding-json-schema/reference/array.html#list-validation)\n- [array `minItems`/`maxItems`](https://json-schema.org/understanding-json-schema/reference/array.html#length)\n    - hardcoding might work when list length is below a reasonable number...?\n- [array `uniqueness`](https://json-schema.org/understanding-json-schema/reference/array.html#uniqueness)\n    - [maybe feasible](https://stackoverflow.com/a/57021889/1763012) for primitives, not so much for objects?\n- [`oneOf`](https://json-schema.org/understanding-json-schema/reference/combining.html)\n\n\n## Related projects\n\n- [as-typed](https://github.com/wix-incubator/as-typed) with a similar effort of type-level Schema-to-Typescript conversion\n- [json-schema-typed](https://github.com/typeslick/json-schema-typed) provides TypeScript definitions for JSON Schema objects\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiphone%2Fjson-schema-type-mapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepiphone%2Fjson-schema-type-mapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepiphone%2Fjson-schema-type-mapper/lists"}