Add original URL and mimetype information for expanded resources.
Review Request #10452 — Created March 18, 2019 and submitted — Latest diff uploaded
When expanding objects in an API response, the caller loses out on some
useful information, such as the original URL to the expanded resource
and the mimetypes. This causes the caller some extra work if they need
this information, either making assumptions about URLs/mimetypes or
performing a second request to get these details.
This change updates the payment to provide some useful information on
the expanded information. Payloads that expand resources now have an
_expandedfield that has each expanded field name as a key and
information as the value.
If expanding a model (such as from a
ForeignKey), this will contain
item_mimetypekey mapping to the mimetype of the expanded resource.
If expanding a
QuerySet, this will also just contain
(as there's not necessarily a corresponding list resource that the user
could otherwise get access to).
If expanding a child resource, this will contain
list_url, all of which can be useful for mapping
the results back to native objects on the client.
Unit tests pass in both Djblets and Review Board.
Manually tested this with some resources, making sure I always got the
results I expected.