Closed clh021 closed 8 years ago
我是从实际使用角度出发,不适合暴露出来 比如办公时候显示器会一直显示出来也不清除,路过人可随意观察到,另外一个就是演示api实际使用时候的投影显示。
另外一个,我刚刚实际使用过程中的问题: 我发现没有option提交方法,还有, Parameter in (query) 似乎只能是query,不能修改为body 官方是有支持body的。不明白。
/**
* @SWG\Options(
* path = "/users",
* tags = {"user"},
* operationId = "userOptions",
* summary = "options",
* produces = {"application/json"},
* consumes = {"application/json"},
* @SWG\Response(
* response = 200,
* description = "success",
* @SWG\Header(header="Allow", type="GET, POST, HEAD, OPTIONS"),
* @SWG\Header(header="Content-Type", type="application/json; charset=UTF-8")
* )
*)
*/
Options提交方法
后面那个没明白
/**
* @SWG\Post(path="/users",
* tags={"user"},
* summary="获取用户登录字段",
* description="用户登录操作的准备,一般不会变更",
* produces={"application/json"},
* @SWG\Parameter(
* in = "query",
* name = "access_token",
* description = "access token",
* required = true,
* type = "string"
* ),
*
* @SWG\Response(
* response = 200,
* description = " success"
* )
* )
*
*/
其中的 in query
是包含在地址栏中的参数请求,不希望放在地址栏中,官方文档有放在body的示例,但是我试图改为 body
,却提示没有这种写法。
options请求不应该有请求数据的吧。
是支持的body的,可以看下我那个demo,有个body请求的示例
呵呵,抱歉,我急于尝试你给出的 options 一时改的,
看到你的demo中body示例了,但是,我看到了一个错误信息,提示我 Schema 是必须的
/**
* @SWG\Post(path="/users/login",
* tags={"user"},
* summary="用户登录",
* description="进行其它所有操作的凭据",
* produces = {"application/json"},
* consumes = {"application/json"},
* @SWG\Parameter(
* in = "body",
* name = "username",
* description = "用户姓名",
* required = true,
* type = "string",
* @SWG\Schema(ref = "#/user/post_users_login")
* ),
* @SWG\Parameter(
* in = "body",
* name = "password",
* description = "密码",
* required = true,
* type = "string",
* @SWG\Schema(ref = "#/user/post_users_login")
* ),
* @SWG\Parameter(
* in = "body",
* name = "app_system",
* description = "app手机的系统名和版本号",
* required = true,
* type = "string",
* @SWG\Schema(ref = "#/user/post_users_login")
* ),
* @SWG\Parameter(
* in = "body",
* name = "app_version",
* description = "app自身的名称和版本号",
* required = true,
* type = "string",
* @SWG\Schema(ref = "#/user/post_users_login")
* ),
* @SWG\Parameter(
* in = "body",
* name = "app_key",
* description = "app与服务器接口约定的key值",
* required = true,
* type = "string",
* @SWG\Schema(ref = "#/user/post_users_login")
* ),
*
* @SWG\Response(
* response = 200,
* description = " success"
* )
* )
*/
我不太理解 schema是做什么用的
请问哪里有相关的字段配置说明文档,我翻查 http://swagger.io/ 和 https://openapis.org/ 似乎仍然没有有关字段说明的文档。
我的 options请求 和 post请求 都在一个函数中,可以写在一起吗? 另外当我使用 Yii2 内置 restful 功能的时候,只需要配置 model即可,没有对应函数,该如何编写相应接口文档呢?
直接写在文件里面就好,可以写在文件的开头,controller注释的代码块中。
当然也可以写在其他文件,只要是能扫描的到的。但是最好在那个controller文件里写就好
谢谢!我在controller写好,并正常生成,能正常测试了。
请问哪里有相关的字段配置说明文档,我翻查 http://swagger.io/ 和 https://openapis.org/ 似乎仍然没有有关字段说明的文档。
另外我希望 接口能够有一个排序,请教,请教,,也许这个可以在说明文档中找到吧,可是我找了很久,不知到在哪里。
为啥要改成password的?官方的就是明文的input,http://petstore.swagger.io/