json-schema-to-typescript
Advanced tools
Comparing version 14.0.3 to 14.0.4
{ | ||
"name": "json-schema-to-typescript", | ||
"version": "14.0.3", | ||
"version": "14.0.4", | ||
"description": "compile json schema to typescript typings", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -8,7 +8,10 @@ # 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) ![node] | ||
> Compile json/yaml schema to typescript typings | ||
> Compile JSONSchema to TypeScript typings. | ||
## Example | ||
Check out the [live demo](https://borischerny.com/json-schema-to-typescript-browser/). | ||
Input: | ||
```json | ||
@@ -41,2 +44,3 @@ { | ||
Output: | ||
```ts | ||
@@ -57,7 +61,3 @@ export interface ExampleSchema { | ||
```sh | ||
# Using Yarn: | ||
yarn add json-schema-to-typescript | ||
# Or, using NPM: | ||
npm install json-schema-to-typescript --save | ||
npm install json-schema-to-typescript | ||
``` | ||
@@ -67,2 +67,37 @@ | ||
json-schema-to-typescript is easy to use via the CLI, or programmatically. | ||
### CLI | ||
A CLI utility is provided with this package. | ||
```sh | ||
cat foo.json | json2ts > foo.d.ts | ||
# or | ||
json2ts foo.json > foo.d.ts | ||
# or | ||
json2ts foo.yaml foo.d.ts | ||
# or | ||
json2ts --input foo.json --output foo.d.ts | ||
# or | ||
json2ts -i foo.json -o foo.d.ts | ||
# or (quote globs so that your shell doesn't expand them) | ||
json2ts -i 'schemas/**/*.json' | ||
# or | ||
json2ts -i schemas/ -o types/ | ||
``` | ||
You can pass any of the options described below (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 | ||
``` | ||
### API | ||
To invoke json-schema-to-typescript from your TypeScript or JavaScript program, import it and call `compile` or `compileFromFile`. | ||
```js | ||
@@ -105,35 +140,9 @@ import { compile, compileFromFile } from 'json-schema-to-typescript' | ||
| $refOptions | object | `{}` | [$RefParser](https://github.com/APIDevTools/json-schema-ref-parser) Options, used when resolving `$ref`s | | ||
## CLI | ||
A CLI utility is provided with this package. | ||
## Tests | ||
```sh | ||
cat foo.json | json2ts > foo.d.ts | ||
# or | ||
json2ts foo.json > foo.d.ts | ||
# or | ||
json2ts foo.json foo.d.ts | ||
# or | ||
json2ts --input foo.json --output foo.d.ts | ||
# or | ||
json2ts -i foo.json -o foo.d.ts | ||
# or (quote globs so that your shell doesn't expand them) | ||
json2ts -i 'schemas/**/*.json' | ||
# or | ||
json2ts -i schemas/ -o types/ | ||
$ npm test | ||
``` | ||
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 | ||
`npm test` | ||
## Features | ||
@@ -140,0 +149,0 @@ |
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
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
2361742
229