glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL

Home Page:https://app.quicktype.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow `true` as a schema in `"items":true`

feefladder opened this issue · comments

slack discussion: https://json-schema.slack.com/archives/CT8QRGTK5/p1671466458144969?thread_ts=1671397459.161829&cid=CT8QRGTK5
Issue: radiantearth/stac-spec#1246
Basically, true is considered a schema, that just passes everything in validation (slack).
However, when trying to create a schema for JSON schema itself:

uicktype --src https://json-schema.org/draft/2020-12/schema --src-lang schema -l typescript --just-types -o schema.d.ts --debug all

This errors out, because enum is an array of any type, e.g.

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
        "enum": {
            "type": "array",
            "items": true
        }
   }
}

gives

resolving # relative to schema.json# (schema.json#)
trying to fetch schema.json
successully fetched schema.json
resolved to # (schema.json#)
resolving # relative to schema.json# (schema.json#)
resolved to # (schema.json#)
Error: Array items must be an array or an object, but is true.