2016-09-27 9 views
0

私は以下の応答を返すいくつかのAPIを持っています。ドキュメンテーションを行うにはどうすればいいですか?私はswagger responseContainerがMapをサポートしていることを知っていますが、マップの値の型は同じ型でなければならないようです。しかし、私の場合、値は異なる型にあります:foosはListの型で、2番目のキー "count"は整数に対応します。スワッガーはimmutableMap(値の異なるタイプ)のレスポンスとどのように反応しますか?

Response.ok(ImmutableMap.of("result", foos, "count", foos.size())).build(); 

APIの応答は次のようなものです:あなたの応答は次のように説明することができ

{ 
    "result": [ 
    { 
     "f1": "v1", 
     "f2": "v2" 
    }, 
    { 
     "f1": "v3", 
     "f2": "v4" 
    } 
    ], 
    "count": 2 
} 

答えて

0

definitions: 
    MyResponse: 
    type: object 
    required: 
     - result 
     - count 
    properties: 
     result: 
     type: array 
     items: 
      $ref: '#/definitions/Foo' 
     count: 
     type: integer 

    Foo: 
    type: object 
    additionalProperties: 
     type: string 
関連する問題