Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion modules/dkan_metastore/docs/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@
"required": true,
"allowEmptyValue": false,
"examples": []
},
"limit": {
"name": "limit",
"in": "query",
"description": "Limit the output of items, mainly for testing purposes.",
"schema": {
"type": "integer",
"default": 10
},
"style": "form",
"allowEmptyValue": true
}
},
"responses": {
Expand Down Expand Up @@ -203,7 +214,8 @@
"tags": [ "Metastore" ],
"parameters": [
{ "$ref": "#/components/parameters/schemaId" },
{ "$ref": "#/components/parameters/showReferenceIds" }
{ "$ref": "#/components/parameters/showReferenceIds" },
{ "$ref": "#/components/parameters/limit" }

],
"responses": {
Expand Down
19 changes: 18 additions & 1 deletion modules/dkan_metastore/src/Controller/MetastoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getAll(string $schema_id, Request $request) {
? $this->service->swapReferences($object)
: $this->service->removeReferences($object);
return (object) $modified_object->get('$');
}, $this->service->getAll($schema_id));
}, $this->service->getAll($schema_id, $this->wantLimitedAmountOfItems($request) ? 0 : NULL, $this->wantLimitedAmountOfItems($request) ?? NULL));

$output = array_values($output);
return $this->apiResponse->cachedJsonResponse($output, 200, [$schema_id], $request->query);
Expand Down Expand Up @@ -159,6 +159,23 @@ private function wantObjectWithReferences(Request $request) {
return TRUE;
}

/**
* Determine if we want to limit the number of items in the response.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
*
* @return ?integer
* number of items or NULL if we want no limit.
*/
private function wantLimitedAmountOfItems(Request $request) {
$param = $request->get('limit', FALSE);
if ($param === FALSE) {
return NULL;
}
return (int) $param;
}

/**
* Implements POST method.
*
Expand Down