yii2 - 描述如何在swagger yii2中获取特定用户?
问题描述
我有一个方法(显示),我可以通过它获取有关特定用户的信息。如何在一个招摇的链接(localhost/users/12)中描述它?
/**
* @SWG\Get(path="/api/users/id",
* tags={"User"},
* summary="",
* @SWG\Parameter(
* name="Authorization",
* in="header",
* description="",
* required=true,
* type="string"
* ),
* @SWG\Response(
* response = 200,
* description = "Ok",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 400,
* description = "Bad Request",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 404,
* description = "Not Found",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 500,
* description = "Internal Server Error"
* )
* )
*/
解决方案
/**
* @SWG\Get(path="/api/users/{id}",
* tags={"User"},
* summary="",
* @SWG\Parameter(
* name="Authorization",
* in="header",
* description="",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="id",
* in="path",
* description="Укажите ID",
* required=true,
* type="string"
* ),
* @SWG\Response(
* response = 200,
* description = "Ok",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 400,
* description = "Bad Request",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 404,
* description = "Not Found",
* @SWG\Schema(ref = "#/")
* ),
* @SWG\Response(
* response = 500,
* description = "Internal Server Error"
* )
* )
*/
推荐阅读
- linux - 使用 bash 脚本启用核心转储日志记录
- python - 如何有效地将稀疏矩阵列添加到另一个稀疏矩阵中的每一列?
- windows-subsystem-for-linux - 如何检查 WSL-2 上不断增长的文件的尾部
- google-chrome - 升级到 chrome 94 后,无法从 http 网站请求 https 资源。我应该怎么办?
- javascript - AWS Datastore 未将用户保存在 Android 上的数据库中
- ionic-framework - 电容器 - 未捕获的类型错误:cap.[some_function] 不是函数
- html - 如何在 AWS EC2 上使用 Flask 和 Ubuntu 和 apache 服务器显示图像
- python - 无法在终端 Visual Studio 代码中运行 Python 代码(EntryNotFound 无法读取文件)
- flutter - 错误:无法找到或加载主类 org.gradle.wrapper.GradleWrapperMain Flutter
- c++ - 初始化空数组时出现“预期表达式”错误