Skip to content

Annotations are ignored when added to an index signature #626

Description

@macno

Given this interface

interface MyObject {
    /**
     * We need at least one item
     *
     * @minItems 1
     */
    alist: string[];
    /**
     * We need at least one item
     *
     * @minItems 1
     */
    [key: string]: string[];
}

The expected schema is

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": {
    "items": {
      "type": "string"
    },
    "minItems": 1,
    "type": "array"
  },
  "properties": {
    "alist": {
      "description": "We need at least one item",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "type": "array"
    }
  },
  "type": "object"
}

but the generated schema is missing "minItems": 1 in additionalProperties

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "additionalProperties": {
        "items": {
            "type": "string"
        },
        "type": "array"
    },
    "properties": {
        "alist": {
            "description": "We need at least one item",
            "items": {
                "type": "string"
            },
            "minItems": 1,
            "type": "array"
        }
    },
    "type": "object"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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