Validate all API request as the API is now open for third parties (references #5)

This commit is contained in:
Bernd Bestel
2018-04-22 14:25:08 +02:00
parent 538d789366
commit 4853174d03
12 changed files with 389 additions and 36 deletions

View File

@@ -4,8 +4,25 @@ namespace Grocy\Controllers;
class BaseApiController extends BaseController
{
protected function ApiResponse($response)
public function __construct(\Slim\Container $container)
{
return json_encode($response);
parent::__construct($container);
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
}
protected $OpenApiSpec;
protected function ApiResponse($data)
{
return json_encode($data);
}
protected function VoidApiActionResponse($response, $success = true, $status = 200, $errorMessage = '')
{
return $response->withStatus($status)->withJson(array(
'success' => $success,
'error_message' => $errorMessage
));
}
}