{"_id":"rm-json-schema-to-typescript","_rev":"1-84ede94b114a12fe926d232a0e74da80","name":"rm-json-schema-to-typescript","dist-tags":{"latest":"10.2.0"},"versions":{"10.2.0":{"name":"rm-json-schema-to-typescript","version":"10.2.0","description":"compile json schema to typescript typings. Fork from original json-schema-to-typescript with changed reference resolving. Will be deprecated when original repo accepts changes","main":"dist/src/index.js","bin":{"json2ts":"dist/src/cli.js"},"typings":"dist/src/index.d.ts","engines":{"node":">=10.0.0"},"scripts":{"build":"npm run lint && npm run clean && npm run build:browser && npm run build:server","build:browser":"browserify src/index.ts -s jstt -p tsify > dist/bundle.js","build:server":"tsc -d","clean":"shx rm -rf dist && mkdir dist","lint":"eslint src/*.ts test/*.ts","tdd":"concurrently -r -p '' -k 'npm run watch' 'npm run watch:test'","test":"ava --timeout=300s --verbose","stresstest":"seq 1 10 | xargs -I{} npm test","prepublishOnly":"npm test","pretest":"npm run clean && npm run build:server","watch":"tsc -w","watch:test":"ava -w"},"repository":{"type":"git","url":"git+https://github.com/bcherny/json-schema-to-typescript.git"},"keywords":["json","schema","typescript","compile","transpile","api","interface","typing","share"],"author":{"name":"Boris Cherny","email":"boris@performancejs.com","url":"http://performancejs.com/"},"license":"MIT","bugs":{"url":"https://github.com/bcherny/json-schema-to-typescript/issues"},"homepage":"https://github.com/bcherny/json-schema-to-typescript#readme","dependencies":{"@types/json-schema":"^7.0.6","@types/lodash":"^4.14.168","@types/prettier":"^2.1.5","cli-color":"^2.0.0","get-stdin":"^8.0.0","glob":"^7.1.6","glob-promise":"^3.4.0","is-glob":"^4.0.1","json-schema-ref-parser":"^9.0.6","json-stringify-safe":"^5.0.1","lodash":"^4.17.20","minimist":"^1.2.5","mkdirp":"^1.0.4","mz":"^2.7.0","prettier":"^2.2.0"},"devDependencies":{"@ava/typescript":"^2.0.0","@types/cli-color":"^2.0.0","@types/glob":"^7.1.3","@types/is-glob":"^4.0.1","@types/minimist":"^1.2.1","@types/mkdirp":"^1.0.1","@types/mz":"^2.7.2","@types/node":"^14.14.10","@types/rimraf":"^3.0.0","@typescript-eslint/eslint-plugin":"^4.8.2","@typescript-eslint/parser":"^4.8.2","ava":"^3.15.0","browserify":"^17.0.0","browserify-shim":"^3.8.14","concurrently":"^5.3.0","eslint":"^7.14.0","eslint-config-prettier":"^6.15.0","eslint-plugin-prettier":"^3.1.4","rimraf":"^3.0.2","shx":"^0.3.3","ts-node":"^10.4.0","tsify":"^5.0.2","typescript":"^4.1.2"},"ava":{"files":["dist/test/test.js"],"typescript":{"extensions":["ts","tsx"],"compile":"tsc","rewritePaths":{"source/":"build/"}},"verbose":true,"snapshotDir":"./test/__snapshots__","ignoredByWatcher":["./src"]},"browserify":{"transform":["browserify-shim"]},"browserify-shim":{"prettier":"global:prettier"},"gitHead":"5d1be8a6b8218ec0c2439db1605d73decb514421","_id":"rm-json-schema-to-typescript@10.2.0","_nodeVersion":"17.3.1","_npmVersion":"8.3.0","dist":{"integrity":"sha512-a27AL7dCkIsEi5Mvaa5bu/SPqaODAllbnOeeTBwOIZck1Lv3OBJEZElIbhhIH6l/mKhdkZ22N1ur4zjzKx+3Dw==","shasum":"e7e520fba3734199f040fdf3d0180ecfb315baef","tarball":"https://registry.npmjs.org/rm-json-schema-to-typescript/-/rm-json-schema-to-typescript-10.2.0.tgz","fileCount":57,"unpackedSize":1323723,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3owICRA9TVsSAnZWagAApwMP/2Z57BvfAiU8vStgsUvM\nNNKqIxRHwQD34Ffn03Ow4lJQyzCU7ShphwnfBWZK0DVwm03Q7VSEdBxvO3jc\napl447eGnzVn5fZXjciVvuedZsmrTL4/YlBiqhSb/wbQGcrWUgEuN5ugVTCR\n+EwpXG6DwOhb7oVCpOGs/nB/OirNI6lTn651IvK7uywMeRQVKrXhYANmMChT\nkCxTtVdKl+PCOAOp/A1kat7MHFGfMr1fWHgRxxB1nT+rBtTxkpLo+A9B3kAe\no42N5LYgBOpWGd8b7ydwDYXdHJMvxaNTGimsuFSikx8lRX1jmCNLlf5gvQE4\nMia+o+S60P7RZuphgrEoEr3DthmNKRWMOuQNRMqiiz7vtSWJ0IDLszDMUUv/\n6J3oGGgExa1Ef40jeVw3VjCdiF/Q4ax2K5BFRISPZfbk+BXxqe88KocG7DWi\nY86tI9N+00+8LyoQu3jaZkriDkvfmF0MZH8fpvwgQZBtPX7xWqdZxeQkQEA6\nZONWEo71dS1e8r7bxOM0hyU8nB+8EJ58K7+xps8+7qoFFYhYXiZouq9U3jAy\nQmiWCTTDFsL8TF1Kbp5xNWOCXzp/0hnr89e45ztMKZubj4NygDuTgj0yKGdO\nJuw3i65NvzGXbLl4/8kTrfgh2UDf7stKlH3OBf5OBO04d6y+eKdfRysxmMMB\ny83J\r\n=1Ssq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHyo7AaiuA1qThETFfMeBR4bt9Yv4CtxNa9xAJl8++LRAiEAhLiry8MJyprX/4jLd/AVAg7lWA5XVEQnBcKASyieHzw="}]},"_npmUser":{"name":"relief.melone","email":"relief.melone@gmail.com"},"directories":{},"maintainers":[{"name":"relief.melone","email":"relief.melone@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rm-json-schema-to-typescript_10.2.0_1641974792738_0.8549644257684323"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-12T08:06:32.737Z","10.2.0":"2022-01-12T08:06:32.890Z","modified":"2022-05-16T01:54:41.912Z"},"maintainers":[{"name":"relief.melone","email":"relief.melone@gmail.com"}],"description":"compile json schema to typescript typings. Fork from original json-schema-to-typescript with changed reference resolving. Will be deprecated when original repo accepts changes","homepage":"https://github.com/bcherny/json-schema-to-typescript#readme","keywords":["json","schema","typescript","compile","transpile","api","interface","typing","share"],"repository":{"type":"git","url":"git+https://github.com/bcherny/json-schema-to-typescript.git"},"author":{"name":"Boris Cherny","email":"boris@performancejs.com","url":"http://performancejs.com/"},"bugs":{"url":"https://github.com/bcherny/json-schema-to-typescript/issues"},"license":"MIT","readme":"# json-schema-to-typescript [![Build Status][build]](https://github.com/bcherny/json-schema-to-typescript/actions?query=branch%3Amaster+workflow%3ACI) [![npm]](https://www.npmjs.com/package/json-schema-to-typescript) [![mit]](https://opensource.org/licenses/MIT)\n\n[build]: https://img.shields.io/github/workflow/status/bcherny/json-schema-to-typescript/CI/master?style=flat-square\n[npm]: https://img.shields.io/npm/v/json-schema-to-typescript.svg?style=flat-square\n[mit]: https://img.shields.io/npm/l/json-schema-to-typescript.svg?style=flat-square\n\n> Compile json schema to typescript typings\n\n## Example\n\nInput:\n```json\n{\n  \"title\": \"Example Schema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"firstName\": {\n      \"type\": \"string\"\n    },\n    \"lastName\": {\n      \"type\": \"string\"\n    },\n    \"age\": {\n      \"description\": \"Age in years\",\n      \"type\": \"integer\",\n      \"minimum\": 0\n    },\n    \"hairColor\": {\n      \"enum\": [\"black\", \"brown\", \"blue\"],\n      \"type\": \"string\"\n    }\n  },\n  \"additionalProperties\": false,\n  \"required\": [\"firstName\", \"lastName\"]\n}\n```\n\nOutput:\n```ts\nexport interface ExampleSchema {\n  firstName: string;\n  lastName: string;\n  /**\n   * Age in years\n   */\n  age?: number;\n  hairColor?: \"black\" | \"brown\" | \"blue\";\n}\n```\n\n## Installation\n\n```sh\n# Using Yarn:\nyarn add json-schema-to-typescript\n\n# Or, using NPM:\nnpm install json-schema-to-typescript --save\n```\n\n## Usage\n\n```js\nimport { compile, compileFromFile } from 'json-schema-to-typescript'\n\n// compile from file\ncompileFromFile('foo.json')\n  .then(ts => fs.writeFileSync('foo.d.ts', ts))\n\n// or, compile a JS object\nlet mySchema = {\n  properties: [...]\n}\ncompile(mySchema, 'MySchema')\n  .then(ts => ...)\n```\n\nSee [server demo](example) and [browser demo](https://github.com/bcherny/json-schema-to-typescript-browser) for full examples.\n\n## Options\n\n`compileFromFile` and `compile` accept options as their last argument (all keys are optional):\n\n| key | type | default | description |\n|-|-|-|-|\n| bannerComment | string | `\"/* tslint:disable */\\n/**\\n* This file was automatically generated by json-schema-to-typescript.\\n* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,\\n* and run json-schema-to-typescript to regenerate this file.\\n*/\"` | Disclaimer comment prepended to the top of each generated file |\n| cwd | string | `process.cwd()` | Root directory for resolving [`$ref`](https://tools.ietf.org/id/draft-pbryan-zyp-json-ref-03.html)s |\n| declareExternallyReferenced | boolean | `true` | Declare external schemas referenced via `$ref`? |\n| enableConstEnums | boolean | `true` | Prepend enums with [`const`](https://www.typescriptlang.org/docs/handbook/enums.html#computed-and-constant-members)? |\n| format | boolean | `true` | Format code? Set this to `false` to improve performance. |\n| ignoreMinAndMaxItems | boolean | `false` | Ignore maxItems and minItems for `array` types, preventing tuples being generated. |\n| style | object | `{ bracketSpacing: false,  printWidth: 120,  semi: true,  singleQuote: false,  tabWidth: 2,  trailingComma: 'none',  useTabs: false }` | A [Prettier](https://prettier.io/docs/en/options.html) configuration |\n| unknownAny | boolean | `true` | Use `unknown` instead of `any` where possible |\n| unreachableDefinitions | boolean | `false` | Generates code for `definitions` that aren't referenced by the schema. |\n| strictIndexSignatures | boolean | `false` | Append all index signatures with `\\| undefined` so that they are strictly typed. |\n| $refOptions | object | `{}` | [$RefParser](https://github.com/BigstickCarpet/json-schema-ref-parser) Options, used when resolving `$ref`s |\n## CLI\n\nA CLI utility is provided with this package.\n\n```sh\ncat foo.json | json2ts > foo.d.ts\n# or\njson2ts foo.json > foo.d.ts\n# or\njson2ts foo.json foo.d.ts\n# or\njson2ts --input foo.json --output foo.d.ts\n# or\njson2ts -i foo.json -o foo.d.ts\n# or (quote globs so that your shell doesn't expand them)\njson2ts -i 'schemas/**/*.json'\n# or\njson2ts -i schemas/ -o types/\n```\n\nYou can pass any of the options described above (including style options) as CLI flags. Boolean values can be set to false using the `no-` prefix.\n\n```sh\n# generate code for definitions that aren't referenced\njson2ts -i foo.json -o foo.d.ts --unreachableDefinitions\n# use single quotes and disable trailing semicolons\njson2ts -i foo.json -o foo.d.ts --style.singleQuote --no-style.semi\n```\n\n## Tests\n\n`npm test`\n\n## Features\n\n- [x] `title` => `interface`\n- [x] Primitive types:\n  - [x] array\n  - [x] homogeneous array\n  - [x] boolean\n  - [x] integer\n  - [x] number\n  - [x] null\n  - [x] object\n  - [x] string\n  - [x] homogeneous enum\n  - [x] heterogeneous enum\n- [x] Non/extensible interfaces\n- [ ] Custom JSON-schema extensions\n- [x] Nested properties\n- [x] Schema definitions\n- [x] [Schema references](http://json-schema.org/latest/json-schema-core.html#rfc.section.7.2.2)\n- [x] Local (filesystem) schema references\n- [x] External (network) schema references\n- [x] Add support for running in browser\n- [x] default interface name\n- [x] infer unnamed interface name from filename\n- [x] `allOf` (\"intersection\")\n- [x] `anyOf` (\"union\")\n- [x] `oneOf` (treated like `anyOf`)\n- [x] `maxItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L166))\n- [x] `minItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L165))\n- [x] `additionalProperties` of type\n- [x] `patternProperties` (partial support)\n- [x] [`extends`](https://github.com/json-schema/json-schema/wiki/Extends/014e3cd8692250baad70c361dd81f6119ad0f696)\n- [x] `required` properties on objects ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L130))\n- [ ] `validateRequired` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L124))\n- [x] literal objects in enum ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L236))\n- [x] referencing schema by id ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L331))\n- [x] custom typescript types via `tsType`\n\n## Custom schema properties:\n\n- `tsType`: Overrides the type that's generated from the schema. Useful for forcing a type to `any` or when using non-standard JSON schema extensions ([eg](https://github.com/sokra/json-schema-to-typescript/blob/f1f40307cf5efa328522bb1c9ae0b0d9e5f367aa/test/e2e/customType.ts)).\n- `tsEnumNames`: Overrides the names used for the elements in an enum. Can also be used to create string enums ([eg](https://github.com/johnbillion/wp-json-schemas/blob/647440573e4a675f15880c95fcca513fdf7a2077/schemas/properties/post-status-name.json)).\n\n## Not expressible in TypeScript:\n\n- `dependencies` ([single](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L261), [multiple](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L282))\n- `divisibleBy` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L185))\n- [`format`](https://github.com/json-schema/json-schema/wiki/Format) ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L209))\n- `multipleOf` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L186))\n- `maximum` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L183))\n- `minimum` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L182))\n- `maxProperties` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L113))\n- `minProperties` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L112))\n- `not`/`disallow`\n- `oneOf` (\"xor\", use `anyOf` instead)\n- `pattern` ([string](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L203), [regex](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L207))\n- `uniqueItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L172))\n\n## FAQ\n\n### JSON-Schema-to-TypeScript is crashing on my giant file. What can I do?\n\nPrettier is known to run slowly on really big files. To skip formatting and improve performance, set the `format` option to `false`.\n\n## Further Reading\n\n- JSON-schema spec: https://tools.ietf.org/html/draft-zyp-json-schema-04\n- JSON-schema wiki: https://github.com/json-schema/json-schema/wiki\n- JSON-schema test suite: https://github.com/json-schema/JSON-Schema-Test-Suite/blob/node\n- TypeScript spec: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md\n\n## Who uses JSON-Schema-to-TypeScript?\n\n- [AWS](https://github.com/aws/aws-toolkit-vscode), [AWSLabs](https://github.com/awslabs/cdk8s)\n- [FormatJS](https://github.com/formatjs/formatjs)\n- [Microsoft](https://github.com/microsoft/mixed-reality-extension-sdk)\n- [Sourcegraph](https://github.com/sourcegraph/sourcegraph)\n- [Stryker](https://github.com/stryker-mutator/stryker)\n- [Webpack](https://github.com/webpack/webpack)\n- [See more](https://github.com/bcherny/json-schema-to-typescript/network/dependents?package_id=UGFja2FnZS0xNjUxOTM5Mg%3D%3D)\n","readmeFilename":"README.md"}