Skip to content

Schema for object with number index #245

@CaselIT

Description

@CaselIT

The typescript type

interface MyType {
  [index: number]: number
}

is parsed into the schema

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "items": {
        "type": "number"
    },
    "type": "array"
}

while it should be parsed into

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "patternProperties": {
        "^[0-9]+$": {
            "type": "number"
        }
    },
    "additionalProperties": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions