fix: unfuck list API

This commit is contained in:
b1ek 2024-08-21 11:48:54 +10:00
parent b85dd5ff13
commit 917abfc03c
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 42 additions and 24 deletions

View File

@ -12,7 +12,10 @@ class ApiController extends \yii\rest\Controller
{
public function actionIndex()
{
return Parameter::find()->with(['icon', 'iconGray'])->all();
return [
'images' => Image::find()->join('INNER JOIN', 'parameters', 'parameters.icon_id = image.id OR parameters.icon_gray_id = image.id')->all(),
'params' => Parameter::find()->all(),
];
}
public function actionImage(Request $request, Response $response)

View File

@ -47,33 +47,48 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Parameter'
example: [
{
"id": 1,
"title": "A thing happening somewhere",
"type": 1,
"icon": null,
"icon_gray": null
},
{
"id": 2,
"title": "The fox jumping over a cat",
"type": 1,
"icon": {
type: object
properties:
images:
type: array
items:
$ref: '#/components/schemas/Image'
params:
type: array
items:
$ref: '#/components/schemas/Parameter'
example: {
"images": [
{
"id": 1,
"original_name": "fox_jump.jpeg",
"sha256": "SHA256"
"sha256": "0000000000000000000000000000000000000000000000000000000000000000",
"original_name": "filename.svg",
"mime": "image/svg+xml"
},
"icon_gray": {
{
"id": 1,
"sha256": "0000000000000000000000000000000000000000000000000000000000000001",
"original_name": "filename.svg",
"mime": "image/svg+xml"
},
],
"params": [
{
"id": 1,
"title": "A thing happening somewhere",
"type": 1,
"icon": null,
"icon_gray": null
},
{
"id": 2,
"original_name": "fox_jump.gray.jpeg",
"sha256": "SHA256"
"title": "The fox jumping over a cat",
"type": 1,
"icon_id": 1,
"icon_gray_id": 2,
}
}
]
],
}
components:
schemas:
Image: