swagger编辑器中的多行文字?

时间:2015-01-26 23:25:17

标签: yaml swagger indentation swagger-editor

我试图在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的错误,表明问题是最终的Windows风格的换行符,我知道HTML textareas可以创建。这是我第一次真正使用YAML,那么只是我做错了什么,或者是Swagger编辑器中的错误?

4 个答案:

答案 0 :(得分:25)

我认为问题在于您在描述块上启动文本的方式。它必须在描述的右侧缩进一级:这是一个适合我的例子:

/{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

在我的实际代码中,描述是三行。

答案 1 :(得分:2)

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

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

出于某种原因,似乎需要双重换行符\n,至少对于要在Swagger编辑器上渲染的新行。但是,当我将官方Uber API YAML demo导出为JSON(文件 - >下载为JSON)时,生成的JSON只有单个换行符,其中演示了多行文字。怪异。

答案 2 :(得分:0)

是缩进。应该是这样的:

df = df1.set_index('node')
df.where(df.eq(-1)).combine_first(df2.set_index('node')).fillna(df)

      st1  st2
node          
a     8.0 -1.0
b     4.0  6.0
c     3.0  4.0

答案 3 :(得分:0)

就我而言,它只是一个 /,我应该将它放在永久链接的开头,在我的 category.md 中:

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