Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fieldList parameter to story index response #138

Merged
merged 5 commits into from
Mar 6, 2025
Merged
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
2 changes: 1 addition & 1 deletion src/app/Http/Controllers/ResponseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected function filterDataByFieldlist(
$fieldlist[] = $queries['orderBy'] ?? $initialSortColumn;
$fieldlist = array_merge($defaults, $fieldlist);
$fieldlist = array_unique($fieldlist);
$dataArray = $data->toArray()[0] ?: $data->toArray();
$dataArray = $data->toArray()[0] ?? $data->toArray();
$fieldsToRemove = array_filter(array_keys($dataArray), function($field) use ($fieldlist) {
return !in_array($field, $fieldlist);
});
Expand Down
2 changes: 2 additions & 0 deletions src/app/Http/Controllers/StoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function index(Request $request): JsonResponse

$data = $this->getDataByRequest($request, $model, $queryColumns, $initialSortColumn);

$data = $this->filterDataByFieldlist($data, $request, ['StoryId'], $initialSortColumn);

if (!$data) {
return $this->sendError('Invalid data', $request . ' not valid', 400);
}
Expand Down
39 changes: 19 additions & 20 deletions src/public/v2/documentation/swagger-initializer.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
window.onload = function() {
//<editor-fold desc="Changeable Configuration Block">

// the following lines will be replaced by docker/configurator, when it runs in a docker-container
window.ui = SwaggerUIBundle({
url: window.location.origin + "/v2/documentation/api-docs.yaml",
dom_id: '#swagger-ui',
// deepLinking: true,
persistAuthorization: true,
filter: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});

//</editor-fold>
window.ui = SwaggerUIBundle({
url: window.location.origin + "/v2/documentation/api-docs.yaml",
dom_id: '#swagger-ui',
docExpansion: 'none',
deepLinking: true,
persistAuthorization: true,
filter: true,
defaultModelsExpandDepth: 0,
docExpansion: 'none',
tagsSorter: 'alpha',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset,
],
plugins: [
// SwaggerUIBundle.plugins.DownloadUrl
],
layout: 'StandaloneLayout',
});
};
2 changes: 1 addition & 1 deletion src/storage/api-docs/api-docs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.1.1

info:
version: 1.56.0
version: 1.57.0
title: Transcribathon Platform API v2
description: This is the documentation of the Transcribathon API v2 used by [https:transcribathon.eu](https://transcribathon.eu/).<br />
For authorization you can use the the bearer token you are provided with.
Expand Down
4 changes: 4 additions & 0 deletions src/storage/api-docs/stories-path.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ get:
description: Determine the type of query for the parameter (DcTitle, RecordId). If set, a broad search ( LIKE %term%) is processed otherwise the exact term is searched for
schema:
type: boolean
- in: query
name: fieldlist
description: Comma-separated list of fields that will be shown in the response
type: string
responses:
200:
description: Ok
Expand Down