for one news by id:
{
current:{
…
},
nex:{
…
},
previous:{
…
}
}
for list of news:
[
{…},
{…},
…
]
Two ways I can think of are:
I would go for the first option between those two.
But maybe someone have an even better method.
I would suggest you query data with DAO and format the resultant array to your own format and keys
Hm,
best way to return custom-formatted model from REST API is use fields()
method: https://www.yiiframework.com/doc/api/2.0/yii-base-model#fields()-detail
Just extend main/common model in api/models and configure fields()
method.
Dependency Injection also may be helpful.