25

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: ^

問題が最後にある Windows スタイルの改行であることを示す JS-YAML のバグが見られます。これは、HTML テキストエリアが作成できることがわかっています。YAML を本格的に使うのはこれが初めてなので、何か間違ったことをしているだけなのか、それとも Swagger エディターのバグなのか?

4

4 に答える 4

47

問題は、説明ブロックのテキストの開始方法にあると思います。説明の右側に 1 レベルインデントする必要があります。

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

私の実際のコードでは、説明は 3 行の長さです。

于 2015-01-27T16:32:26.503 に答える
4

JSON アプローチを追加したかった。Swagger Editor で純粋な JSON を使用して、二重構文の問題 (学習、デバッグ、Web ドキュメントの解析など) を回避しています。

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

何らかの理由\nで、少なくとも Swagger Editor で新しい行をレンダリングするには、二重の改行文字が必要なようです。しかし、公式の Uber API YAMLデモを JSON (ファイル -> JSON としてダウンロード) としてエクスポートしたとき、結果の JSON には、複数行のリテラルが示された単一の改行文字しかありませんでした。変。

于 2016-12-02T08:24:19.327 に答える