【问题标题】:Lack of response and typing info in API ExplorerAPI Explorer 中缺少响应和输入信息
【发布时间】:2013-01-22 14:15:51
【问题描述】:

我使用的是最新版本的 Restler v3(提交 0d79cd8),但我的基于 Swagger 的 UI 看起来与示例中的相同时遇到了一些问题。我注意到的两个问题是没有显示变量类型和@return 对象。

在 Restler 网站上,这里有一个很好的例子来说明这两种方法的工作原理:

example

相反,在我的 Actions 类中,我得到了这个:

从类的定义中可以看出,类型信息和响应对象都被指定:

class Actions {
    /**
    * LIST action types
    *
    * List all the action-types available
    *
    * @url GET /
    */
    function list_actions() {
        throw new RestException(501);
    }

    /**
     * GET today's Actions
     *
     * Get the set of actions done today
     *
     * @url GET /{user_id}
     * @param integer $user_id The user_id for whom the actions apply; you can insert the text "self" and it will resolve to the current/default user
     * @param string $time_of_day {@from url} Allow's you to optionally set a time-of-day; if set then actions are only returned after that. Time should be in the format of HH:MM:SS
     * @return ActionList
    */
    public function action_today ($user_id, $time_of_day = false )
    {
        throw new RestException(501, "Today's actions for user '{$user_id}' not implemented.");
    }

而我对 ActionList 类的定义是:

class ActionList {

    /**
     * Unique identifier of action
     *
     * @var     integer
    */
    public $action_id;
    /**
     * String based unique identifier
     *
     * @var     string
    */
    public $action_slug;

}

【问题讨论】:

    标签: restler swagger


    【解决方案1】:

    如果您的课程是版本化的,例如在命名空间 v1\Actions 中,您也必须在命名空间中注释返回类型,例如@return v1\ActionList

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多