如何在vscode上添加扩展设置架构?

时间:2018-09-16 00:35:20

标签: visual-studio-code vscode-settings vscode-extensions

VS Code中的设置支持如下所示的图形面板:

enter image description here

我正在开发vscode中的扩展,但是找不到文档或示例来说明如何添加这些设置。有什么我可以阅读的教程吗?

我尝试了以下配置,但是GUI没有显示这些字段的面板:

"configuration": [
      {
        "type": "object",
        "title": "MongoDB Runner Configuration",
        "properties": {
          "mongoRunner": {
            "type": "object",
            "default": {},
            "description": "Complete connection configuration for your MongoDB.",
            "properties": {
              "connection": {
                "title": "MongoDB Runner Configuration",
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "default": "mongodb://",
                    "description": "MongoDB URI"
                  },
                  "activeOnStartUp": {
                    "type": "boolean",
                    "default": false,
                    "description": "whether launch mongodb runner on start up"
                  }
                }
              }
            }
          }
        }
      }
    ]

以下是我需要支持的json文件格式:

"mongoRunner": {
        "connection": {
            "activeOnStartUp": true,
            "url": "mongodb://localhost:27017"
        }
    },

1 个答案:

答案 0 :(得分:1)

您正在寻找this吗? 您可以在说明中使用markdown(属性 markdownDescription ),然后使用 boolean 类型显示该复选框。

示例:

"configuration": {
        "type": "object",
        "title": "Test configuration",
        "properties": {
                "test.usingUI": {
                        "type": "boolean",
                        "default": false,
                        "markdownDescription": "**Some bold text**\nYes or no?"
                },
                "test.text": {
                        "type": ["string", "null"],
                        "default": null,
                        "description": "You can't edit me now!"
                }
        }
    },

在UI中的外观类似 this


编辑-2:

在这种情况下,您的语法格式错误,请尝试以下操作:

    "configuration": {
        "type": "object",
        "title": "MongoDB Runner Configuration",
        "properties": {
            "mongoRunner.url": {
                "type": "string",
                "default": "mongodb://",
                "description": "MongoDB URI"
            },
            "mongoRunner.activeOnStartUp": {
                "type": "boolean",
                "default": false,
                "description": "whether launch mongodb runner on start up"
            }
        }
    },

-> UI