【发布时间】:2020-07-17 01:34:17
【问题描述】:
我安装了 "darkaonline/l5-swagger": "~3.0" 以在我的 Laravel 5.3 项目中获取 Swagger,我想为通过 swagger get accesses 或不比较测试我的 api 的用户设置一个 api_key 值他用一个地雷输入的 api_key 值。
我的 security.php 上有这个:
/**
* @SWG\SecurityScheme(
* securityDefinition="api_key",
* type="apiKey",
* in="header",
* name="api_key"
* )
*/
在我的用户控制器上:
/**
* @SWG\Post(
* path="/add_user",
* tags={"user"},
* operationId="adduser",
* summary="Add a new user to the store",
* description="",
* produces={"application/xml", "application/json"},
* @SWG\Parameter(
* name="name",
* in="formData",
* type="string",
* description="Name of the user",
* required=true,
* ),
* @SWG\Parameter(
* name="lastname",
* in="formData",
* type="string",
* description="Lastname of the user",
* required=true,
* ),
* @SWG\Parameter(
* name="email",
* in="formData",
* type="string",
* description="Email of the user",
* required=true,
* ),
* @SWG\Parameter(
* name="password",
* in="formData",
* type="string",
* description="password of the user",
* required=true,
* ),
* @SWG\Parameter(
* name="website",
* in="formData",
* type="string",
* description="website of the user",
* required=true,
* ),
* @SWG\Parameter(
* name="platform",
* in="formData",
* type="string",
* description="website of the user",
* required=true,
* ),
* @SWG\Response(
* response=405,
* description="Invalid input",
* ),
* security={
* {
* "api_key": {},
* }
* },
* )
*/
但即使我没有在我的 url 或授权对话框中添加 api_key 值,我也可以存储新用户。我错过了什么?
【问题讨论】:
-
@KhorneHoly 谢谢我错过了那部分
-
嗨杰拉德,你能就这个问题给我建议吗? stackoverflow.com/questions/45839934/…
标签: php laravel swagger swagger-ui