visual-studio-code - 如何在 vscode 上添加扩展设置架构?

标签 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"
        }
    },

最佳答案

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

关于visual-studio-code - 如何在 vscode 上添加扩展设置架构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52349980/

相关文章:

visual-studio-code - 在 Visual Studio Code 上集成 ZSH 时出现字体问题

visual-studio-code - 如何在 VS 代码扩展中访问文件内容

visual-studio-code - 键绑定(bind) : Is there a `when` clause for the index of the focused editor, 或者如果它是最后一个?

c++ - 远程服务器中的 VS 代码 C++ 代码运行程序设置

visual-studio-code - 在 VSCode 终端中将 WSL 设置为 CWD

visual-studio-code - 在vs代码中更改错误突出显示颜色

typescript - 使用vscode api补全功能时如何删除触发字符?

visual-studio-code - VSCode 扩展设置中的“添加项目”按钮

visual-studio-code - 如何在 Visual Studio Code 的 Rust 项目中查看外部库的源代码?

typescript - 如何告诉 TypeScript 我的函数参数是 Enum 键?