【发布时间】:2014-01-22 00:41:48
【问题描述】:
我正在尝试使用 Swagger-php,但我不断收到错误
通过 bash: [username@dev swagger-php]$ ./bin/swagger [codeigniter 控制器目录的路径]/controllers -o [targetoutput path]/swagger
Swagger 设置在下载时位于原始供应商目录中
[WARN] [Syntax Error] Expected PlainValue, got ')' at position 546 in Tools_Data->tool_get(...) in /usr/local/apache2/htdocs/jh-intranet/application/controllers/v1/tools_data.php on line 27.
[ERROR] no valid resources found
第 27 行是 /**
第 28 行是 * @SWG\Resource(
存在语法错误,但看起来不在该行。 我已经检查了多个在线信息来源,但似乎无法摆脱错误。 没有单引号,并且开/关括号匹配。 如果这类事情有 Swagger/Doctrine 注释 lint 那就太好了。
接下来我应该探索什么?
文档/代码摘录:
use Swagger\Annotations as SWG;
/**
* @package
* @category
* @subpackage
*
* @SWG\Model(id="Tool",required="id")
*/
class Tools_Data extends REST_Controller
{
function __construct()
{
parent::__construct();
}
/**
* @SWG\Resource(
* resourcePath="/v1/tool_data/tool",
* @SWG\Api(
* path="/v1/tool_data/tool/toolId",
* @SWG\Operation(
* method="GET",
* summary="Find tool by ID or other filters",
* notes="Returns tool listing",
* type="Tools",
* nickname="getTools",
* @SWG\Parameters(
* @SWG\Parameter(
* name="id",
* paramType="path",
* format="int",
* required="false",
* description="Tool ID",
* notes="Can also be a JSON parameter",
* )
* @SWG\Parameter(
* name="clean",
* paramType="query",
* format="bool",
* required="false",
* description="Returns a reduced field listing",
* notes="Returns date_added,title,id,tool_tab_id,resource_id,last_modified omits published",
* )
* )
* )
* )
* )
*/
编辑: 工作/更正注释:
/**
* @SWG\Resource(
* resourcePath="/v1/tool_data/tool",
* @SWG\Api(
* path="/v1/tool_data/tool/toolId",
* @SWG\Operation(
* method="GET",
* summary="Find tool by ID or other filters",
* notes="Returns tool listing",
* type="Tools",
* nickname="getTools",
* @SWG\Parameters(
* @SWG\Parameter(
* name="id",
* paramType="path",
* format="int",
* required=false,
* description="Tool ID"
* ),
* @SWG\Parameter(
* name="clean",
* paramType="query",
* format="bool",
* required=false,
* description="Returns a reduced field listing"
* )
* )
* )
* )
* )
*/
【问题讨论】:
-
大括号在哪里(学说的注释数组语法)?看看documentation 的另一个例子。
-
我删除了大括号和 -- ,但仍然出现错误(上面的帖子已相应更新
标签: php api documentation swagger