lib/algolia/models/search/search_query.rb in algolia-3.10.2 vs lib/algolia/models/search/search_query.rb in algolia-3.11.0

- old
+ new

@@ -42,11 +42,10 @@ private SchemaMismatchError = Class.new(StandardError) - # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse. def find_and_cast_into_type(klass, data) return if data.nil? case klass.to_s when "Boolean" @@ -81,15 +80,15 @@ const = Algolia::Search.const_get(klass) if const if const.respond_to?(:openapi_one_of) # nested oneOf model model = const.build(data) - elsif const.respond_to?(:acceptable_attributes) - # raise if data contains keys that are not known to the model - raise unless (data.keys - const.acceptable_attributes).empty? - model = const.build_from_hash(data) + elsif const.respond_to?(:discriminator_attributes) + if const.discriminator_attributes.all? { |attr| data.key?(attr) } + model = const.build_from_hash(data) + end else - # maybe it's an enum + # maybe it's an enum, or doens't have discriminators model = const.build_from_hash(data) end return model if model end