l5-Swagger数据类型未定义

时间:2018-04-18 11:15:07

标签: laravel-5.2 swagger-2.0 swagger-php

我正在使用laravel 5.2.*,我正在使用darkaonline/l5-swagger : ~3.0获取API的文档。我在标题正文中发送参数,当我看到Swagger UI时,它显示如下。

  

数据类型未定义

有关详细信息,请参见下图。

Swagger UI

/**
 * @SWG\Post(
 *   path="/api/v1/compaign_attr",
 *   summary="List compaign attributes",
 *   @SWG\Parameter(
 *     name="campaign_id",
 *     in="body",
 *     description="ID to fetch the targeted compaigns",
 *     required=true,
 *     @SWG\Property(property="request", type="json", example={ "campaign_id": 818, "code":"PLATFORM", "type":"Message"}  )
 *   ),
 * @SWG\Parameter(
 *     name="x-api-key",
 *     in="header",
 *     description="api key validation",
 *     required=true,
 *     type="string",
 *   ),
 *   @SWG\Response(response=200, description="successful operation", @SWG\Property(property="result", type="json", example={ "aa": { "bb", "cc" } }  )),
 *   @SWG\Response(response=401, description="not authorized"),
 *   @SWG\Response(response=500, description="internal server error")
 * )
 *
 */

1 个答案:

答案 0 :(得分:1)

L5-Swagger没有数据类型json。您需要通过大范围定义或内联模式将参数模式设置为对象。

 *   @SWG\Parameter(
 *     in="body",
 *     name="body",
 *     required=true,
 *     description="ID to fetch the targeted campaigns.",
 *     @SWG\Schema(
 *         @SWG\Property(property="campaign_id", type="integer", example=818),
 *         @SWG\Property(property="code", type="string", example="PLATFORM"),
 *         @SWG\Property(property="type", type="string", example="Message")
 *     ),
 *   )

This his how it looks.