CakeDC / cakephp-api

API Plugin for CakePHP
Other
61 stars 33 forks source link

JSend output don't look like JSend #11

Closed mtancoigne closed 7 years ago

mtancoigne commented 7 years ago

As per this example, the model for each dataset is sent in the response:

{
    status : "success",
    data : {
        "post" : { 
            "id" : 1, "title" : "A blog post", "body" : "Some useful content"
        }
     }
}

For now the JSend renderer outputs:

{
    status : "success",
    data : {
        "id" : 1, "title" : "A blog post", "body" : "Some useful content"
     }
}

I managed to loop through the dataset in the JsendRenderer, but I don't think that's where the code belongs to. Where is the best place to change the output formatting when it needs data from the Table classes ?

skie commented 7 years ago

JSend mainly defines the message and data presense in response and the status code for responses. Content of data response is flexible, and its semantic depends of backend that uses it. For this plugin most sense is reflect structures that cakephp3 ORM represents.

mtancoigne commented 7 years ago

@skie Ok, so let's close this, as its not a real JSend format issue.