{"_id":"@csys.pub/json-schema-to-typescript","_rev":"4-574be3cf404bf805c2e7f53d4f6197e1","name":"@csys.pub/json-schema-to-typescript","dist-tags":{"latest":"5.4.0-patch.0"},"versions":{"5.4.0-patch.0":{"name":"@csys.pub/json-schema-to-typescript","version":"5.4.0-patch.0","description":"compile json schema to typescript typings","main":"dist/src/index.js","publishConfig":{"access":"public"},"bin":{"json2ts":"dist/src/cli.js"},"typings":"dist/src/index.d.ts","engines":{"node":">=4.5.0"},"scripts":{"build":"npm run clean && mkdir dist && 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","lint":"tslint -c tslint.json src/*.ts","tdd":"concurrently -r -p '' -k 'npm run watch' 'npm run watch:test'","test":"ava --verbose","prepublishOnly":"npm test","pretest":"npm run build","watch":"tsc -w","watch:test":"ava -w","preversion":"git pull","postversion":"git push && git push --tags","pub-pr":"npm version prerelease && npm publish"},"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/cli-color":"^0.3.29","@types/json-schema":"^4.0.0","@types/lodash":"^4.14.88","@types/minimist":"^1.2.0","@types/mz":"0.0.32","@types/node":"^8.0.50","@types/prettier":"^1.7.2","cli-color":"^1.2.0","json-schema-ref-parser":"^4.0.4","json-stringify-safe":"^5.0.1","lodash":"^4.17.4","minimist":"^1.2.0","mz":"^2.7.0","prettier":"^1.8.2","stdin":"0.0.1"},"devDependencies":{"ava":"^0.23.0","browserify":"^14.5.0","concurrently":"^3.5.0","shx":"^0.2.2","tsify":"^3.0.3","tslint":"^5.8.0","typescript":"^2.6.1"},"ava":{"files":["./dist/test/test.js"],"snapshotDir":"./test/__snapshots__","source":["./dist/test/e2e/*.js","./dist/test/normalizer/*.json","./dist/src/*.js","./test/resources/*.json"],"vebose":true},"gitHead":"1f0daeea0d89ce4c0f3aae4b8b2ecbf343f85f76","_id":"@csys.pub/json-schema-to-typescript@5.4.0-patch.0","_npmVersion":"6.4.0","_nodeVersion":"8.11.2","_npmUser":{"name":"iwan.aucamp.cs","email":"iwan.aucamp@concurrent.systems"},"dist":{"integrity":"sha512-p5nPZp9gOK7MMFm9/p3vVpsyCYKAf328mOhgBm+NA5JIU5pnNO8M+WRilwtNCUvTAXzABuBtIVdoSS9BY0kejA==","shasum":"52c6d185541e5df9b53245da52cf264fc18a1edd","tarball":"https://registry.npmjs.org/@csys.pub/json-schema-to-typescript/-/json-schema-to-typescript-5.4.0-patch.0.tgz","fileCount":52,"unpackedSize":7174408,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbhr49CRA9TVsSAnZWagAAHPoP/RPO5pOLnqXwg/Q3hw7P\no8MBppJw9+2Sx7wnL1H7kMpvrMHX+WrLPOwbGOIPrYvS3Lgh8a7Zdp18pCeU\nqCTkvI9PJdYRMAMC0DNnZdtp3hdHWuS2YR1ren4veJrg29LiVBtPA6Ur3BqY\npFF93Gcnm9zK9nZ8/jrPiH+8AdJdi+i5r6sH9KGUIIyZt9pSLe2Kisuju+Iq\nlwpZKXJDBBoIWTYz/zOZ5ZJF3MP08UJwud8qtvFf4hvfsM1wH8bRkXoKjqyx\n8gl2vimlzrG7h+dmb/chegkQmDO4xo80t9ymXcqedjYidtjJ70XEQfFdwVdd\ndmFxEnP5FJZDiGauE4QnMB9UjkUmzDc0cUfXSS9as3aRrv8W60FoSJ6HGKnK\nhLlfySIrX/ihXtbCJDiqP/Nc6D7VGwpbzWYF1zJbuSR+sEq1wmG4+zZE1iS8\nbQPIPEBmepP10xkvlUhMZfywOqvH0ebKP5TAun0rlBlicWwT5V+6RuMk/NRS\n6C1VlY3KJI6uke4z/k0ExcTmYDCRMXnNIBdWhJWg9Qe8RZq6+jIpowrqQG//\nMhwzTZ96Yn03RmZ2ZH+y88P78APcC5UbWWwFHF2cVYkmrsv3/xm/dbmvMYg0\n18Y1JGI06t542rxi8XIWkGtaQu+JV8/4QTqs5u7+3a8wwLvm3plJrNMmjsV+\nG/lX\r\n=F7Dx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICGCO9h306bEMUSIAlMX4AjXK5PDEMAsrDRp9sOD/CWvAiEA0Bc7jMtGWTvMZObuqZrTpW26fFg5rCGRjVvrNlrn65M="}]},"maintainers":[{"name":"iwan.aucamp.cs","email":"iwan.aucamp@concurrent.systems"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/json-schema-to-typescript_5.4.0-patch.0_1535557180426_0.04352733008898069"},"_hasShrinkwrap":false}},"time":{"created":"2018-08-29T15:39:40.352Z","5.4.0-patch.0":"2018-08-29T15:39:40.625Z","modified":"2022-04-05T02:03:44.625Z"},"maintainers":[{"email":"sysadmin@concurrent.systems","name":"nathaliek"},{"email":"braam.van.heerden@concurrent.systems","name":"braamvh"},{"email":"martin.cooper@concurrent.systems","name":"martincooper"},{"email":"iwan.aucamp@concurrent.systems","name":"iwan.aucamp.cs"}],"description":"compile json schema to typescript typings","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://circleci.com/gh/bcherny/json-schema-to-typescript) [![npm]](https://www.npmjs.com/package/json-schema-to-typescript) [![mit]](https://opensource.org/licenses/MIT)\n\n[build]: https://img.shields.io/circleci/project/bcherny/json-schema-to-typescript.svg?branch=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 | `\"/**\\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| 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| unreachableDefinitions | boolean | `false` | Generates code for `definitions` that aren't referenced by the schema. |\n## CLI\n\nA simple 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```\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] `additionalProperties` of type\n- [x] `patternProperties` (partial support)\n- [x] [`extends`](https://github.com/json-schema/json-schema/wiki/Extends)\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\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- `maxItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L166))\n- `minItems` ([eg](https://github.com/tdegrunt/jsonschema/blob/67c0e27ce9542efde0bf43dc1b2a95dd87df43c3/examples/all.js#L165))\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## 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## Projects That Use JSON-Schema-to-TypeScript\n\n- [RAML-to-TypeScript](https://github.com/ducin/raml-to-typescript)\n- See more: https://www.npmjs.com/browse/depended/json-schema-to-typescript\n","readmeFilename":"README.md"}