/json-schema-typescript

Generate typescript interfaces and deserializer from a JSON schema

Primary LanguageTypeScriptMIT LicenseMIT

json-schema-typescript

Generate typescript interfaces and deserializer logic from a JSON schema

Features

  • Generate named interfaces and enums for to the root of the schema ane each definition in the top-level "$defs" property
  • Generate inline interfaces and enums for each property that doesn't have an explicit definition in "$defs"
  • Handle references to external schemas by importing using the relative path
  • JSON deserializer that uses autogenerated type information.

Assumptions:

  • All definitions are in the top-level "$defs" property
  • External schema references use relative paths
  • The name of the schema file is used as the root type name of the schema

Note:

  • Features in JSON schema which result in ambiguous during deserialization are not supported.

Implementation Notes

  • The JSON schema is first converted to an intermediate representation that drives the generator the generate the top-level types and also the type information used by the JSON deserializer.