YamlLint 验证

标签 yaml snakeyaml

我有一个像这样的 Yaml 文件

    name: hhh_aaa_bbb 
arguments:
    - !argument
        name: inputsss
        description: hhh aaa bbb
        required: true
    - !argument
        name: lll
        description: lll
        required: true
    - !argument
        name: ccc
        description: ccc
        required: true
source:
    !!com.abc.bbc.sss
        uri: !arg input

但是当我使用 Yaml Lint 验证 yamllint 中的这个 yaml 文件时,它删除了所有的“!”或者 ”!!”用户参数。为什么会发生这种情况?

这是验证后我从 yaml lint 获得的输出

    --- 
arguments: 
  - 
    description: "hhh aaa bbb"
    name: inputsss
    required: true
  - 
    description: lll
    name: lll
    required: true
  - 
    description: ccc
    name: ccc
    required: true
name: hhh_aaa_bbb
source: 
  uri: input

最佳答案

如果您想在不进行转换的情况下验证 YAML 文件,请使用 yamllint (linter,而不是网站 - yamllint.com 不是 linter)。

对于您的具体输入,它将给出:

$ yamllint file.yaml
file.yaml
  1:1       warning  missing document start "---"  (document-start)
  1:18      error    trailing spaces  (trailing-spaces)
  4:9       error    wrong indentation: expected 6 but found 8  (indentation)
  8:9       error    wrong indentation: expected 6 but found 8  (indentation)
  12:9      error    wrong indentation: expected 6 but found 8  (indentation)
  17:9      error    wrong indentation: expected 4 but found 8  (indentation)

关于YamlLint 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38454142/

相关文章:

kubernetes - matchExpressions 如何在 NetWorkPolicy 中工作

validation - 验证Kubernetes配置文件(YAML)

java - 是否可以使用非 void 的 setter 反序列化 yaml 文档?

ruby-on-rails - 如何将 yaml 文件解析为 ruby​​ 哈希和/或数组?

java - SnakeYAML加载无法常规使用的对象

dictionary - Golang深深地融合了两张 map

parsing - 使用SnakeYaml进行解析时,将忽略yaml中的字段(无法在类中找到属性)

java - 使用 SnakeYAML 的嵌套结构

java - 我如何在 Java 编程中验证 YAML 结构