vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Description not showing for some fields

Open roedoejet opened this issue 1 year ago • 4 comments

Describe the bug

I have a JSON schema generated by Pydantic has descriptions of certain fields. When I create a json file and validate it with the schema, the descriptions show in VSCode without exception. However, when using the YAML extension and creating a YAML file, some of the descriptions display, and some of them do not (see screenshots below).

Expected Behavior

The description should be present when hovering over all fields that contain a description in the schema.

Current Behavior

Only certain fields display the description.

Steps to Reproduce

  1. Here is an example schema:
{
    "$defs": {
        "FastSpeech2TrainingConfig": {
            "$schema": "http://json-schema.org/draft-07/schema#",
            "additionalProperties": false,
            "properties": {
                "batch_size": {
                    "default": 16,
                    "description": "The number of samples to include in each batch when training. If you are running out of memory, consider lowering your batch_size.",
                    "title": "Batch Size",
                    "type": "integer"
                },
                "save_top_k_ckpts": {
                    "default": 5,
                    "description": "The number of checkpoints to save.",
                    "title": "Save Top K Ckpts",
                    "type": "integer"
                },
                "ckpt_steps": {
                    "anyOf": [{
                            "type": "integer"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "default": null,
                    "description": "The interval (in steps) for saving a checkpoint. By default checkpoints are saved every epoch using the 'ckpt_epochs' hyperparameter",
                    "title": "Ckpt Steps"
                },
                "ckpt_epochs": {
                    "anyOf": [{
                            "type": "integer"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "default": 1,
                    "description": "The interval (in epochs) for saving a checkpoint. You can also save checkpoints after n steps by using 'ckpt_steps'",
                    "title": "Ckpt Epochs"
                },

                "$schema": "http://json-schema.org/draft-07/schema#"
            }
        }
    },
    "additionalProperties": false,
    "properties": {
        "path_to_model_config_file": {
            "anyOf": [{
                    "format": "file-path",
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
            "title": "Path To Model Config File"
        },
        "training": {
            "$ref": "#/$defs/FastSpeech2TrainingConfig"
        },
        "path_to_training_config_file": {
            "anyOf": [{
                    "format": "file-path",
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
            "title": "Path To Training Config File"
        },
        "path_to_preprocessing_config_file": {
            "anyOf": [{
                    "format": "file-path",
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
            "title": "Path To Preprocessing Config File"
        },
        "path_to_text_config_file": {
            "anyOf": [{
                    "format": "file-path",
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "default": null,
            "title": "Path To Text Config File"
        }
    },
    "title": "FastSpeech2Config",
    "type": "object"
}
  1. Create a json file:

{
    "$schema": "/path/to/the/schema/above.json",
    "training": { "ckpt_epochs": 1 }
}

  1. Hover over the "ckpt_epochs" key and you will see a description:

image

  1. Create a yaml file and associate it with the same schema, and you will see a description for some fields (i.e. batch_size shown below), but you will not see a description for others (e.g. ckpt_epochs)

image image

Environment

Tested on macOS Monterey and Windows. For Mac:

Version: 1.84.2 (Universal) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:52:33.687Z (1 wk ago) Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 21.6.0

  • [x] Windows
  • [x] Mac
  • [ ] Linux
  • [ ] other (please specify)

roedoejet avatar Nov 22 '23 00:11 roedoejet

I have a similar use case and am getting the same issue

LevonW-IIS avatar Mar 22 '24 12:03 LevonW-IIS

I also have this issue and found that this is the case for schema entries that use anyOf instead of type. This also seems to be true for the case in the bug report form @roedoejet where path_to_preprocessing_config_file uses anyOf and batch_size uses type. There is an identical issue on the LSP-server repo, so depending on which is the right tree to bark at one of the issues is a duplicate.

s-weigand avatar Apr 23 '24 21:04 s-weigand