swagger编辑器中的多行文字?

uemypmqf  于 2023-08-05  发布在  其他
关注(0)|答案(5)|浏览(161)

我试图在Swagger编辑器中获得多行文字(顺便说一下,这是一个很棒的工具!)).

post:
    summary: Translate one or more identifiers
    description: |
Translate one or more identifiers for one entity into the
identifiers of another entity. Translate one or more
identifiers for one entity into the identifiers of another entity.

    consumes:
    - application/json

字符串
我已经试过了|和>,具有不同的结尾(增加缩进与空行),以及我能想到的每一种方法,但它总是给出相同的错误:

YAML Syntax Error
Can not read a block mapping entry; a multiline key may not be an implicit  
key at line 24, column 15: consumes: ^


我看到JS-YAML的bug,表明问题是结尾处的Windows风格的换行符,我知道HTML文本区域可以创建。这是我第一次真正使用YAML,所以是我做错了什么,还是Swagger编辑器中的一个bug?

chy5wohz

chy5wohz1#

我认为问题出在你的描述块上的文本开头的方式。它必须在说明右侧缩进一级:这里有一个对我有用的例子:

/{user-id}:
get:
  summary: Facebook User
  description: |
    Displays all information about a Facebook user, depending on access privileges.  Displays all information about a Facebook user, depending on access privileges.
  parameters:
    - name: user-id
      in: path
      description: The Facebook user ID
      required: true
      type: string

字符串
在我的实际代码中,描述只有三行。

oymdgrw7

oymdgrw72#

是压痕。应该是这样的:

post:
    summary: Translate one or more identifiers
    description: |
      Translate one or more identifiers for one entity into the
      identifiers of another entity. Translate one or more
      identifiers for one entity into the identifiers of another entity.

字符串

dxpyg8gm

dxpyg8gm3#

我想添加JSON方法。我在Swagger编辑器中使用纯JSON来避免双重语法的问题(学习、调试、解析web documentation等)。

"get": {
    "description": "Hi\n\nThere",

字符串
出于某种原因,似乎需要双换行符\n,至少对于在Swagger编辑器上呈现的新行来说是这样。然而,当我将官方的Uber API YAML演示导出为JSON(File -> Download as JSON)时,生成的JSON只有一个换行符,其中演示了多行文字。真奇怪

xzv2uavs

xzv2uavs4#

在我的例子中,它只是一个**/,我应该放在永久链接的开头,在我的类别中。md**:

permalink: /{{ blog.catPermalinkPrefix }}/{{ category.slug }}/

字符串

rlcwz9us

rlcwz9us5#

在我的例子中,复制/粘贴一些在文本前面有制表符的文本使它“看起来”很好,但导致了这个错误

相关问题