apidog icon indicating copy to clipboard operation
apidog copied to clipboard

请问可以对 ApiResponse 下schema 里面的值进行描述的么?

Open penghcheng opened this issue 4 years ago • 5 comments

/** * @PostApi(path="login", description="添加一个用户") * @Header(key="token|接口访问凭证", rule="required") * @FormData(key="username|用户名或者手机号", rule="required") * @FormData(key="password|密码", rule="required") * @ApiResponse(code="-1", description="参数错误") * @ApiResponse(code="0", description="成功", schema={"id":1}) */

请问可以对 ApiResponse 下schema 里面的值进行描述的么?谢谢

penghcheng avatar May 18 '20 10:05 penghcheng

目前不可以, 采用Modle方式应该可以达到你想要的效果, 有空了研究下

daodao97 avatar May 21 '20 11:05 daodao97

目前可能只能在class层多定义点@ApiDefinition,然后schema $ref引用,能否在method层支持@ApiDefinition这样就可以了

jhansin-zhang avatar Jan 07 '21 09:01 jhansin-zhang

ApiDefinition 定义在 class 层是考虑到定义内容在整个class 方法中的复用, 抽离的初衷也是复用, 感觉不适合在 method层使用, 如果仅单个接口的响应需要对字段做描述可以如下写法

 @ApiResponse(code="0", description="创建成功", schema={"id|ID": 1})

daodao97 avatar Jan 07 '21 11:01 daodao97

hyperf 3版本

hyperf 3移除了 @Annotation 的支持,全部使用 PHP8 原生注解 Attribute。 到时可能此组件不再兼容。

wjycoder avatar Jun 22 '22 10:06 wjycoder

hyperf 3版本

hyperf 3移除了 @Annotation 的支持,全部使用 PHP8 原生注解 Attribute。 到时可能此组件不再兼容。

后续我得空升级一下

daodao97 avatar Jun 24 '22 03:06 daodao97