所以我在我的 php 代码中有如下评论,所以基本上我正在尝试生成我的 api 接受的以下类型的请求。
我有如下评论:
/**
* Login API
*
*
*@SWG\Definition(
* definition="login",
* description="Enter your username",
*)
*@SWG\Definition(
* definition="password",
* type="string",
* description="Enter your Password",
*)
* @SWG\Post(
* path="/user/login",
* description="Login API.",
* operationId="Login",
* produces={"application/json"},
* tags={"login"},
* consumes={"application/json"},
*@SWG\Parameter(
* name="params",
* in="body",
* type="string",
* default="params={""username"":""abc@abc.com"",""password"":""12345678""}",
* description="Login Detail",
* required=true,
* @SWG\Schema(ref="#/definitions/login")
*),
*@SWG\Response(
* response=200,
* description="Token overview."
*),
*@SWG\Response(
* response=401,
* description="Unauthorized action.",
*),
* )
*/
预期产出
curl -X POST \
http://localhost/project/api/web/user/login \
-H 'cache-control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-H 'postman-token: 78219bf9-85a4-420f-7637-55e2f0e51b11' \
-F 'params={"username":"abc@abc.com","password":"12345678"}'
实际输出
curl -X POST "http://localhost/project/api/web/user/login" -H "accept: application/json" -H "Content-Type: application/json" -d "params={\"username\":\"abc@abc.com\",\"password\":\"12345678\"}"
在 Swagger-ui 中,当我尝试执行它时,它给了我错误:
类型错误:获取失败
我试过的
- 更改消耗为“multipart/form-data”(同样的错误)
- 如果我将 in="body" 更改为 in="query" 那么它可以工作,但我不能使用它。因为它需要在 POST 方法中传递参数。
- 可能不相关,但在控制台中我收到以下错误:
root-injects.js:95 TypeError: e.get(...).entrySeq is not a function at t.default (curlify.js:23) at t.value (curl.jsx:17) at t.render ( root-injects.js:93) 在 u._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:796) 在 u._renderValidatedComponent (ReactCompositeComponent.js:819) 在 u._updateRenderedComponent (ReactCompositeComponent.js:743) 在 u._performComponentUpdate (ReactCompositeComponent.js: 721) 在 updateComponent (ReactCompositeComponent.js:642) 在 u.receiveComponent (ReactCompositeComponent.js:544) 在 Object.receiveComponent (ReactReconciler.js:122)
那么我应该怎么做才能解决这个问题呢?