【问题标题】:Doctrine / Swagger-php Syntax error: [Syntax Error] Expected PlainValue, got ')' at position [closed]Doctrine / Swagger-php 语法错误:[语法错误] 预期的 PlainValue,在位置得到 ')' [关闭]
【发布时间】: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


【解决方案1】:

omits published" 后面有一个逗号,所以当从第 27 行开始的注释的第 546 个字符处看到 ) 时,教义感到很惊讶。

如果你找到了 linter,请告诉我,我还希望有更多描述性的错误消息。

【讨论】:

  • 这终于让我开始了 :) 删除了逗号,并做了一些其他的清理工作 - 对于有同样问题的人,请参阅原始帖子以获取工作注释
猜你喜欢
  • 1970-01-01
  • 2021-09-14
  • 2012-08-02
  • 2013-07-16
  • 1970-01-01
  • 2021-08-30
  • 2019-02-20
  • 1970-01-01
相关资源
最近更新 更多