Add correct self-link

The self-link was missing the resource id, properly add the id to
the self-link now.

Change-Id: I82c59fc3a02e4182147ec8090d54cfe82b8d0c61
Partial-Bug: #1776504
This commit is contained in:
Morgan Fainberg 2018-07-13 20:34:19 -04:00
parent dbc6899c38
commit ba854a5acd
2 changed files with 3 additions and 1 deletions

View File

@ -528,7 +528,7 @@ class ResourceBase(flask_restful.Resource):
@classmethod
def _add_self_referential_link(cls, ref):
self_link = '/'.join([base_url(), 'v3', cls.collection_key])
self_link = '/'.join([base_url(), 'v3', cls.collection_key, ref['id']])
ref.setdefault('links', {})['self'] = self_link
@classmethod

View File

@ -77,6 +77,8 @@ class _TestResourceWithCollectionInfo(flask_common.ResourceBase):
raise exception.NotFound(target=argument_id)
ref = flask.request.get_json(force=True)
self._require_matching_id(ref)
# Maintain the ref id
ref['id'] = argument_id
self._storage_dict[argument_id] = ref
return '', 204