diff --git a/addon/serializers/rest.js b/addon/serializers/rest.js index 6b3c90623bf..edc8bb67122 100644 --- a/addon/serializers/rest.js +++ b/addon/serializers/rest.js @@ -156,6 +156,10 @@ var RESTSerializer = JSONSerializer.extend({ */ normalize(modelClass, resourceHash, prop) { if (this.normalizeHash && this.normalizeHash[prop]) { + deprecate('`RESTSerializer.normalizeHash` has been deprecated. Please use `serializer.normalize` to modify the payload of single resources.', false, { + id: 'ds.serializer.normalize-hash-deprecated', + until: '3.0.0' + }); this.normalizeHash[prop](resourceHash); } return this._super(modelClass, resourceHash); diff --git a/tests/integration/serializers/rest-serializer-test.js b/tests/integration/serializers/rest-serializer-test.js index b7e850e0f5f..e36ee5c3db1 100644 --- a/tests/integration/serializers/rest-serializer-test.js +++ b/tests/integration/serializers/rest-serializer-test.js @@ -392,6 +392,29 @@ test('normalizeHash normalizes specific parts of the payload', function(assert) }); +testInDebug('normalizeHash has been deprecated', function(assert) { + env.registry.register('serializer:application', DS.RESTSerializer.extend({ + normalizeHash: { + homePlanets(hash) { + hash.id = hash._id; + delete hash._id; + return hash; + } + } + })); + + var jsonHash = { + homePlanets: [{ _id: "1", name: "Umber", superVillains: [1] }] + }; + + run(function() { + assert.expectDeprecation(function() { + env.restSerializer.normalizeResponse(env.store, HomePlanet, jsonHash, null, 'findAll'); + }, /`RESTSerializer.normalizeHash` has been deprecated/); + }); +}); + + test('normalizeHash works with transforms', function(assert) { env.registry.register('serializer:application', DS.RESTSerializer.extend({ normalizeHash: {