Skip to content

Setting description of index mapped keys #402

Open
@Ririshi

Description

@Ririshi

I am trying to validate a JSON configuration using typescript-json-schema and ajv.
I would like to add a description to every field in the schema. This works for every field, except the [env: string] key, which is grabbing the comment that is written above the source code of PartialDeep<T> (from type-fest), instead of using the supplied description.

export type ConfigJson = {
  /**
   * Schema definition reference
   */
  $schema: string;
  /**
   * Configuration per environment
   */
  environments: {
    /**
     * Specific configuration for this environment
     */
    [env: string]: PartialDeep<Config>;
  };
  /**
   * Global configuration
   */
  global: PartialDeep<Config>;
};

The schema comes out like this:

"definitions": {
        "PartialObjectDeep<Config>": {
            "...": "...",
            "description": "Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.",
            "...": "...",
            },
            "type": "object"
        },
        ...
    },
    "properties": {
        "...": "...",
        "environments": {
            "additionalProperties": {
                "$ref": "#/definitions/PartialObjectDeep<Config>"
            },
            "description": "Configuration per environment",
            "type": "object"
        },
        "...": "...",
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions