Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
penghcheng opened this issue May 18, 2020 · 5 comments

Comments

@penghcheng
Copy link

/**
* @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 里面的值进行描述的么?谢谢

@daodao97
Copy link
Owner

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

@jhansin-zhang
Copy link

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

@daodao97
Copy link
Owner

daodao97 commented Jan 7, 2021

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

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

@wjycoder
Copy link

hyperf 3版本

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

@daodao97
Copy link
Owner

hyperf 3版本

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

后续我得空升级一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants