dotarj / PartialResponse

PartialResponse provides JSON partial response (partial resource) support for ASP.NET Web API.
Other
57 stars 26 forks source link

Handle "data" wrappers #24

Open Nikkelmann opened 5 years ago

Nikkelmann commented 5 years ago

According to https://developers.google.com/drive/api/v3/performance#partial requests to API responses that use "data" wrappers, where the response is nested within a data object that looks like data: { ... }, one should not include "data" in the fields specification.

So instead of "fields=data(a,b)" it should be specified like "fields=a,b".

In this case the filtering is only applied to the data property; any other properties of the wrapper object should not be filtered. Eg. { "success": true, "data": { ... } }

To not break the old versions this could be implemented as a property like with IgnoreCase on PartialJsonMediaTypeFormatter.

dotarj commented 5 years ago

Sorry for the delay, this project hasn’t had the focus it should have had. The documentation isn’t very explicit on the data field, but if I understand correctly, the data field is always in the first level of the JSON response, eg.:

{ “success”: true, “data”: { ... } }

And filtering fields only affects fields in the data field, so other fields (success in this example) can’t be filtered (of course, only if the option is enabled).

Please let me know if you agree on this. I will think of a solution for this and get back to you. Suggestions are welcome!

Nikkelmann commented 5 years ago

Agreed.

zihotki commented 5 years ago

From my experience the data is always either on root level (without wrapper) or on 1st level (data field or alternative). I never saw any other options so I also agree that it's safe to assume it.