2015-12-16 6 views
9

私のアプリの応答は次のようになります。Swagger PHP:スキーマ定義を使用するためにプロパティを宣言する方法は?

{ 
    "status": "success", 
    "data": { 
     "status": "ready" 
    }, 
    "request_id": "string" 
} 

私が闊歩

*   @SWG\Response (
*    response=200, 
*    description="Success response", 
*    @SWG\Schema (
*     @SWG\Property(
*      property="status", 
*      type="string", 
*      default="success" 
*     ), 
*     @SWG\Property(
*      property="data", 
*      @SWG\Schema(
*       ref="#/definitions/Service/models/Status" 
*      ) 
*     ), 
*     @SWG\Property(
*      property="request_id", 
*      type="string" 
*     ), 
*    ) 
*   ), 

に応答を定義しようとしました。しかし、私の応答が実際のように見えるので、それは、ステータスのためのスキーマ定義を使用していません:

{ 
    "status": "success", 
    "data": {}, 
    "request_id": "string" 
} 

スキーマ定義を使用するにはどのようにデータプロパティを定義できますか?それとも別のやり方でできますか?

答えて

10

実際には、質問を投稿した直後に答えが見つかることがあります。

回答は次のとおりです。

*   @SWG\Response (
*    response=200, 
*    description="Success response", 
*    @SWG\Schema (
*     @SWG\Property(
*      property="status", 
*      type="string", 
*      default="success" 
*     ), 
*     @SWG\Property(
*      property="data", 
*      ref="#/definitions/Service/models/Status" 
*     ), 
*     @SWG\Property(
*      property="request_id", 
*      type="string" 
*     ), 
*    ) 
*   ), 
+0

は、あなたが他のケースの誰かが同じ質問を持っているに正しいとあなたの答えをマークしたいですか? –

+0

こんにちは@JJHunterしかし、これは私のために働いていない、私は同じクエリを持って、あなたの答えを適用するが、あなたは私の質問を確認することができませんhttp://stackoverflow.com/questions/43627098/how-to-show-api-response-甘やかされた –

関連する問題