An open API service indexing awesome lists of open source software.

https://github.com/sourcemeta/codegen

A code generator to output type definitions from JSON Schema in a growing amount of programming languages
https://github.com/sourcemeta/codegen

code-generation code-generator codegen json-schema jsonschema programming-language types typescript

Last synced: about 1 month ago
JSON representation

A code generator to output type definitions from JSON Schema in a growing amount of programming languages

Awesome Lists containing this project

README

          

# JSON Schema Codegen

> Generate type definitions from JSON Schema for multiple programming languages

Existing tools in this space typically support limited subsets of JSON Schema
with varying compliance levels. This project, maintained by a member of the
[JSON Schema Technical Steering Committee](https://github.com/jviotti),
prioritizes specification compliance and comprehensive keyword coverage.

**We currently only support TypeScript (given demand) but we will extend
support to other programming languages once we make the foundations stable.**

## Keyword Support

Not every JSON Schema keyword maps directly to type system constructs. This
implementation aims to provide complete structural typing, and you are expected
to use a JSON Schema validator at runtime to enforce remaining constraints.

| Vocabulary | Keyword | TypeScript |
|------------|---------|------------|
| Core (2020-12) | `$schema` | Yes |
| Core (2020-12) | `$id` | Yes |
| Core (2020-12) | `$ref` | Yes |
| Core (2020-12) | `$defs` | Yes |
| Core (2020-12) | `$anchor` | Yes |
| Core (2020-12) | `$dynamicAnchor` | Yes |
| Core (2020-12) | `$dynamicRef` | Yes |
| Core (2020-12) | `$vocabulary` | Ignored |
| Core (2020-12) | `$comment` | Ignored |
| Applicator (2020-12) | `properties` | Yes |
| Applicator (2020-12) | `additionalProperties` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Applicator (2020-12) | `items` | Yes |
| Applicator (2020-12) | `prefixItems` | Yes |
| Applicator (2020-12) | `anyOf` | Yes |
| Applicator (2020-12) | `patternProperties` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Applicator (2020-12) | `propertyNames` | Ignored |
| Applicator (2020-12) | `dependentSchemas` | Pending |
| Applicator (2020-12) | `contains` | Ignored |
| Applicator (2020-12) | `allOf` | Yes |
| Applicator (2020-12) | `oneOf` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Applicator (2020-12) | `not` | **CANNOT SUPPORT** |
| Applicator (2020-12) | `if` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Applicator (2020-12) | `then` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Applicator (2020-12) | `else` | **PARTIAL GIVEN LANGUAGE LIMITATIONS** |
| Validation (2020-12) | `type` | Yes |
| Validation (2020-12) | `enum` | Yes |
| Validation (2020-12) | `required` | Yes |
| Validation (2020-12) | `const` | Yes |
| Validation (2020-12) | `minLength` | Ignored |
| Validation (2020-12) | `maxLength` | Ignored |
| Validation (2020-12) | `pattern` | Ignored |
| Validation (2020-12) | `minimum` | Ignored |
| Validation (2020-12) | `maximum` | Ignored |
| Validation (2020-12) | `exclusiveMinimum` | Ignored |
| Validation (2020-12) | `exclusiveMaximum` | Ignored |
| Validation (2020-12) | `multipleOf` | Ignored |
| Validation (2020-12) | `minProperties` | Ignored |
| Validation (2020-12) | `maxProperties` | Ignored |
| Validation (2020-12) | `dependentRequired` | Pending |
| Validation (2020-12) | `minItems` | Ignored |
| Validation (2020-12) | `maxItems` | Ignored |
| Validation (2020-12) | `minContains` | Ignored |
| Validation (2020-12) | `maxContains` | Ignored |
| Validation (2020-12) | `uniqueItems` | Ignored |
| Unevaluated (2020-12) | `unevaluatedItems` | Pending |
| Unevaluated (2020-12) | `unevaluatedProperties` | Pending |
| Meta-Data (2020-12) | `title` | Ignored |
| Meta-Data (2020-12) | `description` | Ignored |
| Meta-Data (2020-12) | `default` | Ignored |
| Meta-Data (2020-12) | `deprecated` | Ignored |
| Meta-Data (2020-12) | `examples` | Ignored |
| Meta-Data (2020-12) | `readOnly` | Ignored |
| Meta-Data (2020-12) | `writeOnly` | Ignored |
| Format Annotation (2020-12) | `format` | Ignored |
| Format Assertion (2020-12) | `format` | Ignored |
| Content (2020-12) | `contentEncoding` | Ignored |
| Content (2020-12) | `contentMediaType` | Ignored |
| Content (2020-12) | `contentSchema` | Ignored |

Support for other JSON Schema dialects coming soon.