YAMLException:映射条目的缩进错误

Mr.*_*ous 7 yaml node.js

在下面的 OpenAPI 定义中,参数 LayoutId 导致解析器错误“映射条目的缩进错误”。

yaml 文件:

---
name: 1x1+1x1_1x1  
  LayoutId: 3A1B6753-4F92-4DCD-A1E3-6462374EC897
  LayoutType: ControlRoomGrid
  ConfiguredSegments:
    SegmentConfiguration:
      Height: 50
      Id: None
      Left: 0
      SerializationId: true
      Top: 0
      Width: 50
      Index: 0
    SegmentConfiguration:
      Height: 50
      Id: None
      Left: 0
      SerializationId: true
      Top: 50
      Width: 50
      Index: 0
    SegmentConfiguration:
      Height: 100
      Id: None
      Left: 50
      SerializationId: true
      Top: 0
      Width: 50
      Index: 0
  IntendedResolution:
    Height:
      100
    Width:
      100
  PlaneType: A
---
Run Code Online (Sandbox Code Playgroud)

我花了将近一个小时来解决这个问题,但无法找到问题所在。

Mur*_*ran 7

你不能创建这样的对象。如果你想创建一个名为的对象,name你应该像这样使用它:

name:  
  LayoutId: 3A1B6753-4F92-4DCD-A1E3-6462374EC897
  LayoutType: ControlRoomGrid
  ConfiguredSegments:
    ...
Run Code Online (Sandbox Code Playgroud)

否则,如果您不想创建名为 的对象name,则需要将该name字段与其他字段保持在同一行。

name: 1x1+1x1_1x1  
LayoutId: 3A1B6753-4F92-4DCD-A1E3-6462374EC897
LayoutType: ControlRoomGrid
ConfiguredSegments:
  ...
Run Code Online (Sandbox Code Playgroud)