forked frombcherny/json-schema-to-typescript
- Notifications
You must be signed in to change notification settings - Fork0
purecloudlabs/json-schema-to-typescript
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
[In Alpha]: Bug reports appreciated!
Compile json schema to typescript typings
Input:
{"title":"Example Schema","type":"object","properties": {"firstName": {"type":"string" },"lastName": {"type":"string" },"age": {"description":"Age in years","type":"integer","minimum":0 },"hairColor": {"enum": ["black","brown","blue"],"type":"string" } },"required": ["firstName","lastName"]}Output:
exportinterfaceExampleSchema{firstName:string;lastName:string;age?:number;// Age in yearshairColor?:"black"|"brown"|"blue";}
npm install json-schema-to-typescript
import{compileFromFile}from'json-schema-to-typescript'fs.writeFileSync('foo.d.ts',awaitcompileFromFile('foo.json'))
npm test
title=>interface- Primitive types:
- array
- array of type
- boolean
- integer
- number
- null
- object
- string
- string enum
- number enum
- Non/extensible interfaces
- Custom JSON-schema extensions
- Nested properties
- Schema definitions
- Schema references
- Local (filesystem) schema references
- External (network) schema references
- Add support for running in browser
- default interface name
- infer unnamed interface name from filename
anyOf("union")allOf("intersection")additionalPropertiesof typeextendsrequiredproperties on objects (eg)validateRequired(eg)- literal objects in enum (eg)
- referencing schema by id (eg)
- clean up + refactor code
dependencies(single,multiple)divisibleBy(eg)format(eg)multipleOf(eg)maximum(eg)minimum(eg)maxItems(eg)minItems(eg)maxProperties(eg)minProperties(eg)not/disallowoneOf("xor", useanyOfinstead)pattern(string,regex)patternProperties(eg)uniqueItems(eg)
- JSON-schema spec:http://json-schema.org/latest/json-schema-core.html
- JSON-schema wiki:https://github.com/json-schema/json-schema/wiki
- JSON-schema test suite:https://github.com/json-schema/JSON-Schema-Test-Suite/blob/node
- TypeScript spec:https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md
About
compile json schema to typescript typings
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Languages
- TypeScript57.4%
- JavaScript42.6%