Skip to content
Snippets Groups Projects
Commit 80b6ba96 authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Minor API fixes (#877)

- Added error handling to Swagger spec fragment parsing
- Fixed a phpdoc mistake
- Tweaked code style
parent 2db1dd97
No related merge requests found
...@@ -108,6 +108,12 @@ class ApiController extends \VuFind\Controller\AbstractBase ...@@ -108,6 +108,12 @@ class ApiController extends \VuFind\Controller\AbstractBase
foreach ($this->apiControllers as $controller) { foreach ($this->apiControllers as $controller) {
$api = $controller->getSwaggerSpecFragment(); $api = $controller->getSwaggerSpecFragment();
$specs = json_decode($api, true); $specs = json_decode($api, true);
if (null === $specs) {
throw new \Exception(
'Could not parse Swagger spec fragment of '
. get_class($controller)
);
}
foreach ($specs as $key => $spec) { foreach ($specs as $key => $spec) {
if (isset($results[$key])) { if (isset($results[$key])) {
$results[$key] = array_merge($results[$key], $spec); $results[$key] = array_merge($results[$key], $spec);
......
...@@ -46,7 +46,7 @@ interface ApiInterface ...@@ -46,7 +46,7 @@ interface ApiInterface
* Get Swagger specification JSON fragment for services provided by the * Get Swagger specification JSON fragment for services provided by the
* controller * controller
* *
* @return \Zend\Http\Response * @return string
*/ */
public function getSwaggerSpecFragment(); public function getSwaggerSpecFragment();
} }
...@@ -222,8 +222,7 @@ class SearchApiController extends \VuFind\Controller\AbstractSearch ...@@ -222,8 +222,7 @@ class SearchApiController extends \VuFind\Controller\AbstractSearch
$this->determineOutputMode(); $this->determineOutputMode();
if ($result = $this->isAccessDenied($this->searchAccessPermission) if ($result = $this->isAccessDenied($this->searchAccessPermission)) {
) {
return $result; return $result;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment