在我使用YAML编辑的招摇文件中。我打算使用GFM语法插入代码块,这是swagger根据this document所期望的。
description: >-
Some description of the object here.
More Here. An example to for this is as follows:
```json
{
"Key": {
"name": "myName",
"id": 100
}
}
```
然而,这并没有显示为格式化为JSON,而是所有这些都最终出现在这样的一行:
Some description of the object here. More Here. An example to for this is as follows: ```json { "Key": { "name": "myName", "id": 100 } } ```
答案 0 :(得分:6)
这一切都以一行结束,因为您使用folded style block scalar指定>
(-
用于删除扼流指示符)。
您要使用的是literal style block scalar,其中包含换行符和间距。您可能还想使用默认的剪辑选择(在JSON代码的末尾留下一个换行符):
description: |
Some description of the object here.
More Here. An example to for this is as follows:
```json
{
"Key": {
"name": "myName",
"id": 100
}
}
```
(唯一的更改是在第一行>-
到|
)