diff --git a/src/api-umbrella/web-app/app/models/api.rb b/src/api-umbrella/web-app/app/models/api.rb index 7d3db2edc..f4c09b109 100644 --- a/src/api-umbrella/web-app/app/models/api.rb +++ b/src/api-umbrella/web-app/app/models/api.rb @@ -280,4 +280,17 @@ def roles roles.uniq! roles end + + def serializable_hash(options = nil) + hash = super(options) + # Ensure all embedded relationships are at least null in the JSON output + # (rather than not being present), or else Ember-Data's serialization + # throws warnings. + hash["rewrites"] ||= nil + hash["servers"] ||= nil + hash["settings"] ||= nil + hash["sub_settings"] ||= nil + hash["url_matches"] ||= nil + hash + end end diff --git a/src/api-umbrella/web-app/app/models/api/settings.rb b/src/api-umbrella/web-app/app/models/api/settings.rb index 197f28842..3d8e11aa0 100644 --- a/src/api-umbrella/web-app/app/models/api/settings.rb +++ b/src/api-umbrella/web-app/app/models/api/settings.rb @@ -134,6 +134,18 @@ def set_transition_starts_on_publish end end + def serializable_hash(options = nil) + hash = super(options) + # Ensure all embedded relationships are at least null in the JSON output + # (rather than not being present), or else Ember-Data's serialization + # throws warnings. + hash["default_response_headers"] ||= nil + hash["headers"] ||= nil + hash["override_response_headers"] ||= nil + hash["rate_limits"] ||= nil + hash + end + private def read_headers_string(field) diff --git a/src/api-umbrella/web-app/app/models/api/sub_settings.rb b/src/api-umbrella/web-app/app/models/api/sub_settings.rb index f31374d1f..87b31ba0c 100644 --- a/src/api-umbrella/web-app/app/models/api/sub_settings.rb +++ b/src/api-umbrella/web-app/app/models/api/sub_settings.rb @@ -16,4 +16,13 @@ class Api::SubSettings # Nested attributes accepts_nested_attributes_for :settings + + def serializable_hash(options = nil) + hash = super(options) + # Ensure all embedded relationships are at least null in the JSON output + # (rather than not being present), or else Ember-Data's serialization + # throws warnings. + hash["settings"] ||= nil + hash + end end diff --git a/src/api-umbrella/web-app/app/models/api_user.rb b/src/api-umbrella/web-app/app/models/api_user.rb index ebd3f0ad0..b624acb95 100644 --- a/src/api-umbrella/web-app/app/models/api_user.rb +++ b/src/api-umbrella/web-app/app/models/api_user.rb @@ -130,6 +130,15 @@ def api_key_hides_at @api_key_hides_at ||= self.created_at + 2.weeks end + def serializable_hash(options = nil) + hash = super(options) + # Ensure all embedded relationships are at least null in the JSON output + # (rather than not being present), or else Ember-Data's serialization + # throws warnings. + hash["settings"] ||= nil + hash + end + private def normalize_terms_and_conditions