bcherny/json-schema-to-typescript

oneOf convert to unknown after update from v9 to v10

Open

#378 建立於 2021年3月29日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)TypeScript (449 fork)github user discovery
buggood first issuehelp wanted

倉庫指標

Star
 (3,302 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

If I use the following schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "title": "Condition",
  "properties": {
    "conditions": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "items": {
          "oneOf": [
            {
              "$ref": "#/definitions/conditionA"
            },
            {
              "type": "string"
            }
          ]
        }
      }
    }
  },
  "definitions": {
    "conditionA": {
      "title": "ConditionA",
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "ConditionA"
        }
      },
      "additionalProperties": false,
      "required": ["type"]
    }
  },
  "additionalProperties": false
}

In 9.10,

export interface Condition {
  conditions?: {
    [k: string]: (ConditionA | string)[]
  }
}
export interface ConditionA {
  type: string
}

in 10.1.0,

export interface Condition {
  conditions?: {
    [k: string]: {
      [k: string]: unknown;
    };
  };
}

貢獻者指南