json-schema-to-typescript
Advanced tools
Comparing version 5.2.2 to 5.3.0
# Changelog | ||
## 5.3.0 | ||
- 83e4a29 Add support for passing options in CLI | ||
## 5.2.0 | ||
- 9187237 Add support for generating typings from `definitions` that are not directly referenced by a schema (#133) | ||
- 7d864b9 Add support for generating typings from `patternProperties` (#124) | ||
## 5.0.0 | ||
@@ -4,0 +13,0 @@ |
@@ -70,3 +70,3 @@ #!/usr/bin/env node | ||
schema = _b.apply(_a, [_c.sent()]); | ||
return [4 /*yield*/, index_1.compile(schema, argIn)]; | ||
return [4 /*yield*/, index_1.compile(schema, argIn, argv)]; | ||
case 3: | ||
@@ -108,4 +108,4 @@ ts = _c.sent(); | ||
var pkg = require('../../package.json'); | ||
process.stdout.write("\n" + pkg.name + " " + pkg.version + "\nUsage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE]\n\nWith no IN_FILE, or when IN_FILE is -, read standard input.\nWith no OUT_FILE and when IN_FILE is specified, create .d.ts file in the same directory.\nWith no OUT_FILE nor IN_FILE, write to standard output.\n"); | ||
process.stdout.write("\n" + pkg.name + " " + pkg.version + "\nUsage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE] [OPTIONS]\n\nWith no IN_FILE, or when IN_FILE is -, read standard input.\nWith no OUT_FILE and when IN_FILE is specified, create .d.ts file in the same directory.\nWith no OUT_FILE nor IN_FILE, write to standard output.\n\nYou can use any of the following options by adding them at the end.\nBoolean values can be set to false using the 'no-' prefix.\n\n --cwd=XXX\n Root directory for resolving $ref\n --declareExternallyReferenced\n Declare external schemas referenced via '$ref'?\n --enableConstEnums\n Prepend enums with 'const'?\n --style.XXX=YYY\n Prettier configuration\n --unreachableDefinitions\n Generates code for definitions that aren't referenced by the schema\n"); | ||
} | ||
//# sourceMappingURL=cli.js.map |
{ | ||
"name": "json-schema-to-typescript", | ||
"version": "5.2.2", | ||
"version": "5.3.0", | ||
"description": "compile json schema to typescript typings", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
# 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) | ||
[build]: https://img.shields.io/circleci/project/bcherny/json-schema-to-typescript.svg?branch=master&style=flat-square | ||
[npm]: https://img.shields.io/npm/v/json-schema-to-typescript.svg?style=flat-square | ||
[mit]: https://img.shields.io/npm/l/json-schema-to-typescript.svg?style=flat-square | ||
> Compile json schema to typescript typings | ||
## Example | ||
@@ -108,2 +102,11 @@ | ||
You 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. | ||
```sh | ||
# generate code for definitions that aren't referenced | ||
json2ts -i foo.json -o foo.d.ts --unreachableDefinitions | ||
# use single quotes and disable trailing semicolons | ||
json2ts -i foo.json -o foo.d.ts --style.singleQuote --no-style.semi | ||
``` | ||
## Tests | ||
@@ -110,0 +113,0 @@ |
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
import stdin = require('stdin') | ||
import { compile } from './index' | ||
import { compile, Options } from './index' | ||
@@ -31,3 +31,3 @@ main(minimist(process.argv.slice(2), { | ||
const schema: JSONSchema4 = JSON.parse(await readInput(argIn)) | ||
const ts = await compile(schema, argIn) | ||
const ts = await compile(schema, argIn, argv as Partial<Options>) | ||
await writeOutput(ts, argOut) | ||
@@ -66,3 +66,3 @@ } catch (e) { | ||
${pkg.name} ${pkg.version} | ||
Usage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE] | ||
Usage: json2ts [--input, -i] [IN_FILE] [--output, -o] [OUT_FILE] [OPTIONS] | ||
@@ -72,4 +72,18 @@ With no IN_FILE, or when IN_FILE is -, read standard input. | ||
With no OUT_FILE nor IN_FILE, write to standard output. | ||
You can use any of the following options by adding them at the end. | ||
Boolean values can be set to false using the 'no-' prefix. | ||
--cwd=XXX | ||
Root directory for resolving $ref | ||
--declareExternallyReferenced | ||
Declare external schemas referenced via '$ref'? | ||
--enableConstEnums | ||
Prepend enums with 'const'? | ||
--style.XXX=YYY | ||
Prettier configuration | ||
--unreachableDefinitions | ||
Generates code for definitions that aren't referenced by the schema | ||
` | ||
) | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55
3888
173
6142396