GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — 几个建议(我可以协助完成) · Issue #89 · phalapi/phalapi Open Description首先第一步, 注释规范化. . 建议使用apidocjs的方案. 比如下面是我的代码: /** * @api {post} /auth/register/email 邮箱注册 * @apiDescription 注册时, 请求体将不可避免地用明文传参.所以建议开启SSL. * @apiVersion 2.0.0 * @apiPermission none * @apiName registerByEmail * @apiGroup Auth * * @apiParam {String{3..16}} username 用户名. * @apiParam {String{..32}} email 用户邮箱. * @apiParam {String{6}} captch 验证码. * @apiParam {String} password 密码. * * @apiSuccessExample 成功响应: { "ret": 200, "data": {}, "msg": "" } */ public function registerByEmail() { $domain = new Domain(); /** ============== 格式检查 ============== */ /** ------- 用户名检查 ------- */ $this->username = trim($this->username); if (!\App\Helper\Validator::checkUsernameFormat($this->username)) { throw new BadRequestException('用户名格式错误, 请检查用户名格式是否正确. 只可以含有?.@_所有中英文和emoji.'); } /** ------- 邮箱检查 ------- */ $this->email = trim($this->email); if (!\App\Helper\Validator::checkEmailFormat($this->email)) { throw new BadRequestException('邮箱格式错误, 必须形如 [email protected] 的格式'); } /** ============== 正式检查 ============== */ // 检查可用性(重复) if (!$domain->isEmailAvailable($this->email)) { throw new BadRequestException('邮箱已被使用'); } /** ------- captch validating ------- */ $this->captch = trim($this->captch); $correctCaptch = $domain->getLastCaptch($this->email); if ($correctCaptch == null) { throw new BadRequestException('未发送验证码'); } if ($this->captch != $correctCaptch) { throw new BadRequestException('验证码错误或过期'); } /** ------- password validating ------- */ // 密码不进行 trim() /** ------- 完成注册 ------- */ $domain->registerUserByEmail($this->username, $this->email, $this->password, 1); // 目前规定, 失败才返回消息 //\PhalApi\DI()->response->setMsg("注册成功"); return array(); }
apidoc 已经能够直接生成json, 读取json再生成相应所需php文件, 并不困难. Reacted by xun Cen Activity
MetadataMetadataAssigneesLabelsNo labels ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |