apiato - 教程示例:无效输入(电子邮件字段是必需的;密码字段是必需的;名称字段是必需的)

时间:2017-03-24 14:38:40

标签: php testing web-api-testing

尝试开始使用apioto http://apiato.io/A.getting-started/installation/

如果我尝试在示例中测试http://api.apiato.dev/register,我会收到错误:

curl -X POST -H "Accept: application/json" -H "Cache-Control: no-cache" -F "email=mahmoud@zalt.me" -F "password=so-secret" -F "name=Mahmoud Zalt" "http://api.apiato.dev/register"

错误:

{
  "message": "Invalid Input.",
  "errors": {
    "email": [
      "The email field is required."
    ],
    "password": [
      "The password field is required."
    ],
    "name": [
      "The name field is required."
    ]
  },
  "status_code": 422,
  "debug": {
    "line": 45,
    "file": "C:\\laragon\\www\\apiato\\app\\Ship\\Parents\\Requests\\RequestTrait.php",
    "class": "App\\Ship\\Features\\Exceptions\\ValidationFailedException",
    "trace": [
      "#0 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Validation\\ValidatesWhenResolvedTrait.php(24): App\\Ship\\Parents\\Requests\\Request->failedValidation(Object(Illuminate\\Validation\\Validator))",
      "#1 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Providers\\FormRequestServiceProvider.php(31): Illuminate\\Foundation\\Http\\FormRequest->validate()",
      "#2 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(997): Illuminate\\Foundation\\Providers\\FormRequestServiceProvider->Illuminate\\Foundation\\Providers\\{closure}(Object(App\\Containers\\User\\UI\\API\\Requests\\RegisterUserRequest), Object(Illuminate\\Foundation\\Application))",
      "#3 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(961): Illuminate\\Container\\Container->fireCallbackArray(Object(App\\Containers\\User\\UI\\API\\Requests\\RegisterUserRequest), Array)",
      "#4 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(946): Illuminate\\Container\\Container->fireAfterResolvingCallbacks('App\\\\Containers\\\\...', Object(App\\Containers\\User\\UI\\API\\Requests\\RegisterUserRequest))",
      "#5 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(617): Illuminate\\Container\\Container->fireResolvingCallbacks('App\\\\Containers\\\\...', Object(App\\Containers\\User\\UI\\API\\Requests\\RegisterUserRequest))",
      "#6 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(567): Illuminate\\Container\\Container->resolve('App\\\\Containers\\\\...')",
      "#7 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(702): Illuminate\\Container\\Container->make('App\\\\Containers\\\\...')",
      "#8 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteDependencyResolverTrait.php(79): Illuminate\\Foundation\\Application->make('App\\\\Containers\\\\...')",
      "#9 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteDependencyResolverTrait.php(47): Illuminate\\Routing\\ControllerDispatcher->transformDependency(Object(ReflectionParameter), Array)",
      "#10 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\RouteDependencyResolverTrait.php(27): Illuminate\\Routing\\ControllerDispatcher->resolveMethodDependencies(Array, Object(ReflectionMethod))",
      "#11 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(40): Illuminate\\Routing\\ControllerDispatcher->resolveClassMethodDependencies(Array, Object(App\\Containers\\User\\UI\\API\\Controllers\\Controller), 'registerUser')",
      "#12 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(203): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Containers\\User\\UI\\API\\Controllers\\Controller), 'registerUser')",
      "#13 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(160): Illuminate\\Routing\\Route->runController()",
      "#14 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(559): Illuminate\\Routing\\Route->run()",
      "#15 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#16 C:\\laragon\\www\\apiato\\app\\Containers\\Localization\\Middlewares\\LocalizationMiddleware.php(34): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#17 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): App\\Containers\\Localization\\Middlewares\\LocalizationMiddleware->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#18 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#19 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Http\\Middleware\\RateLimit.php(70): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#20 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\RateLimit->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#21 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#22 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#23 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#24 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#25 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Http\\Middleware\\PrepareController.php(45): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#26 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\PrepareController->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#27 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#28 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#29 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(561): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "#30 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(520): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Dingo\\Api\\Http\\Request))",
      "#31 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(498): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))",
      "#32 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Routing\\Adapter\\Laravel.php(81): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
      "#33 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Routing\\Router.php(513): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')",
      "#34 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))",
      "#35 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(114): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#36 C:\\laragon\\www\\apiato\\vendor\\barryvdh\\laravel-cors\\src\\HandleCors.php(42): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#37 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Barryvdh\\Cors\\HandleCors->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#38 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#39 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#40 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#41 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#42 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#43 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#44 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#45 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#46 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))",
      "#47 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "#48 C:\\laragon\\www\\apiato\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))",
      "#49 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))",
      "#50 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "#51 C:\\laragon\\www\\apiato\\app\\Containers\\Debugger\\Middlewares\\RequestsMonitorMiddleware.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "#52 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(148): App\\Containers\\Debugger\\Middlewares\\RequestsMonitorMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "#53 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "#54 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "#55 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(149): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "#56 C:\\laragon\\www\\apiato\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
      "#57 C:\\laragon\\www\\apiato\\public\\index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
      "#58 {main}"
    ]
  }
}

我该如何解决?根据apiato-tutorial,这个例子应该可行。

1 个答案:

答案 0 :(得分:2)

问题解决了:https://github.com/apiato/apiato/issues/124

非常感谢@objectorientedninja。