demos-europe / edt

Enables your PHP application to expose its entities as REST resources using the feature rich JSON:API specification as API. How and to whom your entities are exposed is highly customizable while minimizing boilerplate code.
MIT License
2 stars 1 forks source link

Prefer 204 responses after creation/update #116

Open dresslerdemos opened 10 months ago

dresslerdemos commented 10 months ago

After successfully creating or updating a resource it needs to be returned with the response, if the state in the client needs to be informed about the new state of the resource. For example a resource may be created/updated with a text attribute, which is not directly filled with the value provided in the client request, but with a trimmed version (leading and trailing white spaces removed).

The current implementation already considers such cases and will always return the resource with its default fields or requested fieldset if any property was set differently than requested.

However, this does not always seem necessary, because the client probably only needs the resource in the response body if the changes affected any properties that are present in the response body. For example if the text field mentioned above is no default field or was excluded via a provided fieldset, then a 204 response without body may suffice. The specification for creations and updates does not directly support this interpretation, so additional research is needed to not accidentally implement a non-standard-complient feature.