6

Swagger 2.0 を使用してエンドポイントの応答例を作成しようとしています。

    200:
      description: Successful response
      schema:
        type: object
        $ref: "#/definitions/User"
      examples:
        application/vnd.api+json:
            - data:
                attributes:
                  full_name: John Appleseed
            - data:
                attributes:
                  full_name: Mike Appleseed

私の API は を消費して生成しますapplication/vnd.api+jsonが、それを認識しません。例を削除すると、仕様が機能します。それを指定する方法はありますか?

エラー

4

1 に答える 1

9

次のように 1 つの例を定義できますが、まだ完全には実装されていません。

   responses:
    "200":
      description: Successful response
      schema: 
        $ref: '#/definitions/User'
      examples:
        application/json:
          data:
            id: 1
            attributes:
              attr1: value1
              attr2: value2

MIME タイプに関連するバグが 1 つあります。ドットを使用できないため、application/vnd.api+jsonを配置しませんでした

于 2015-07-29T01:24:15.360 に答える