bcherny/json-schema-to-typescript

Support for boolean `required` property at attribute level

Open

#440 opened on Feb 21, 2022

View on GitHub
 (2 comments) (4 reactions) (0 assignees)TypeScript (449 forks)github user discovery
buggood first issuehelp wanted

Repository metrics

Stars
 (3,302 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Currently, only the required array at the top of the object definition will result in non optional attributes. However, json-schema draft does support for required as a boolean at the property level

// test.json

{
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "required": true
        }
    }
}

CURRENT

interface Test {
  name?: string
}

EXPECTED

interface Test {
  name: string
}

Contributor guide