diff --git a/lib/algolia/models/abtesting/ab_test.rb b/lib/algolia/models/abtesting/ab_test.rb index 75d062cb..d836b20b 100644 --- a/lib/algolia/models/abtesting/ab_test.rb +++ b/lib/algolia/models/abtesting/ab_test.rb @@ -57,11 +57,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/ab_test_configuration.rb b/lib/algolia/models/abtesting/ab_test_configuration.rb index f45c1048..33b85b83 100644 --- a/lib/algolia/models/abtesting/ab_test_configuration.rb +++ b/lib/algolia/models/abtesting/ab_test_configuration.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/ab_test_response.rb b/lib/algolia/models/abtesting/ab_test_response.rb index 13456c19..9a4bceb2 100644 --- a/lib/algolia/models/abtesting/ab_test_response.rb +++ b/lib/algolia/models/abtesting/ab_test_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/ab_tests_variant.rb b/lib/algolia/models/abtesting/ab_tests_variant.rb index e6884ac4..e37ed1ca 100644 --- a/lib/algolia/models/abtesting/ab_tests_variant.rb +++ b/lib/algolia/models/abtesting/ab_tests_variant.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb b/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb index 60506bd5..ec13d79f 100644 --- a/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +++ b/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb @@ -27,9 +27,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :customSearchParameters + ] end # Attribute type mapping. diff --git a/lib/algolia/models/abtesting/add_ab_tests_request.rb b/lib/algolia/models/abtesting/add_ab_tests_request.rb index a45f0e80..4e1fbe5b 100644 --- a/lib/algolia/models/abtesting/add_ab_tests_request.rb +++ b/lib/algolia/models/abtesting/add_ab_tests_request.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/add_ab_tests_variant.rb b/lib/algolia/models/abtesting/add_ab_tests_variant.rb index 6d2c260c..1fccd11b 100644 --- a/lib/algolia/models/abtesting/add_ab_tests_variant.rb +++ b/lib/algolia/models/abtesting/add_ab_tests_variant.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/abtesting/currency.rb b/lib/algolia/models/abtesting/currency.rb index 4d195f95..73feaa5c 100644 --- a/lib/algolia/models/abtesting/currency.rb +++ b/lib/algolia/models/abtesting/currency.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/empty_search.rb b/lib/algolia/models/abtesting/empty_search.rb index d36b1eec..1367fb75 100644 --- a/lib/algolia/models/abtesting/empty_search.rb +++ b/lib/algolia/models/abtesting/empty_search.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/empty_search_filter.rb b/lib/algolia/models/abtesting/empty_search_filter.rb index c3bfd446..681cd195 100644 --- a/lib/algolia/models/abtesting/empty_search_filter.rb +++ b/lib/algolia/models/abtesting/empty_search_filter.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/error_base.rb b/lib/algolia/models/abtesting/error_base.rb index afe0c6b9..52b6fa87 100644 --- a/lib/algolia/models/abtesting/error_base.rb +++ b/lib/algolia/models/abtesting/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/estimate_ab_test_request.rb b/lib/algolia/models/abtesting/estimate_ab_test_request.rb index ecae9856..bdb35db2 100644 --- a/lib/algolia/models/abtesting/estimate_ab_test_request.rb +++ b/lib/algolia/models/abtesting/estimate_ab_test_request.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/estimate_ab_test_response.rb b/lib/algolia/models/abtesting/estimate_ab_test_response.rb index a079f926..60c2bece 100644 --- a/lib/algolia/models/abtesting/estimate_ab_test_response.rb +++ b/lib/algolia/models/abtesting/estimate_ab_test_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/estimate_configuration.rb b/lib/algolia/models/abtesting/estimate_configuration.rb index ec5e1e87..73c53631 100644 --- a/lib/algolia/models/abtesting/estimate_configuration.rb +++ b/lib/algolia/models/abtesting/estimate_configuration.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/filter_effects.rb b/lib/algolia/models/abtesting/filter_effects.rb index c6bba046..c2c4594f 100644 --- a/lib/algolia/models/abtesting/filter_effects.rb +++ b/lib/algolia/models/abtesting/filter_effects.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/list_ab_tests_response.rb b/lib/algolia/models/abtesting/list_ab_tests_response.rb index 8047a8d4..3642f95d 100644 --- a/lib/algolia/models/abtesting/list_ab_tests_response.rb +++ b/lib/algolia/models/abtesting/list_ab_tests_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/minimum_detectable_effect.rb b/lib/algolia/models/abtesting/minimum_detectable_effect.rb index ffb93043..0f1d5fec 100644 --- a/lib/algolia/models/abtesting/minimum_detectable_effect.rb +++ b/lib/algolia/models/abtesting/minimum_detectable_effect.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/outliers.rb b/lib/algolia/models/abtesting/outliers.rb index 7e6431e5..5bc3b993 100644 --- a/lib/algolia/models/abtesting/outliers.rb +++ b/lib/algolia/models/abtesting/outliers.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/outliers_filter.rb b/lib/algolia/models/abtesting/outliers_filter.rb index 52602b41..56a3d59b 100644 --- a/lib/algolia/models/abtesting/outliers_filter.rb +++ b/lib/algolia/models/abtesting/outliers_filter.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/schedule_ab_test_response.rb b/lib/algolia/models/abtesting/schedule_ab_test_response.rb index 97dc5658..9d9ed91b 100644 --- a/lib/algolia/models/abtesting/schedule_ab_test_response.rb +++ b/lib/algolia/models/abtesting/schedule_ab_test_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/schedule_ab_tests_request.rb b/lib/algolia/models/abtesting/schedule_ab_tests_request.rb index 47cb51d0..c9fe3ea0 100644 --- a/lib/algolia/models/abtesting/schedule_ab_tests_request.rb +++ b/lib/algolia/models/abtesting/schedule_ab_tests_request.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/abtesting/variant.rb b/lib/algolia/models/abtesting/variant.rb index a010d5bb..7929fe21 100644 --- a/lib/algolia/models/abtesting/variant.rb +++ b/lib/algolia/models/abtesting/variant.rb @@ -91,11 +91,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/click_position.rb b/lib/algolia/models/analytics/click_position.rb index 87c08235..4636d8ec 100644 --- a/lib/algolia/models/analytics/click_position.rb +++ b/lib/algolia/models/analytics/click_position.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/currency_code.rb b/lib/algolia/models/analytics/currency_code.rb index e38ee96d..033bbe34 100644 --- a/lib/algolia/models/analytics/currency_code.rb +++ b/lib/algolia/models/analytics/currency_code.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_add_to_cart_rates.rb b/lib/algolia/models/analytics/daily_add_to_cart_rates.rb index 9ee4d0a5..59f2c9da 100644 --- a/lib/algolia/models/analytics/daily_add_to_cart_rates.rb +++ b/lib/algolia/models/analytics/daily_add_to_cart_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_average_clicks.rb b/lib/algolia/models/analytics/daily_average_clicks.rb index d5710032..c1b032e0 100644 --- a/lib/algolia/models/analytics/daily_average_clicks.rb +++ b/lib/algolia/models/analytics/daily_average_clicks.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_click_through_rates.rb b/lib/algolia/models/analytics/daily_click_through_rates.rb index 8467a913..9f03871b 100644 --- a/lib/algolia/models/analytics/daily_click_through_rates.rb +++ b/lib/algolia/models/analytics/daily_click_through_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_conversion_rates.rb b/lib/algolia/models/analytics/daily_conversion_rates.rb index 5a90e9d2..25cec28d 100644 --- a/lib/algolia/models/analytics/daily_conversion_rates.rb +++ b/lib/algolia/models/analytics/daily_conversion_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_no_click_rates.rb b/lib/algolia/models/analytics/daily_no_click_rates.rb index eb7684ac..3f8efa56 100644 --- a/lib/algolia/models/analytics/daily_no_click_rates.rb +++ b/lib/algolia/models/analytics/daily_no_click_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_no_results_rates.rb b/lib/algolia/models/analytics/daily_no_results_rates.rb index dcb3f6aa..c3302593 100644 --- a/lib/algolia/models/analytics/daily_no_results_rates.rb +++ b/lib/algolia/models/analytics/daily_no_results_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_purchase_rates.rb b/lib/algolia/models/analytics/daily_purchase_rates.rb index c5fd6ee4..2602b503 100644 --- a/lib/algolia/models/analytics/daily_purchase_rates.rb +++ b/lib/algolia/models/analytics/daily_purchase_rates.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_revenue.rb b/lib/algolia/models/analytics/daily_revenue.rb index da703565..4d407726 100644 --- a/lib/algolia/models/analytics/daily_revenue.rb +++ b/lib/algolia/models/analytics/daily_revenue.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_searches.rb b/lib/algolia/models/analytics/daily_searches.rb index 28e31909..dd3bce46 100644 --- a/lib/algolia/models/analytics/daily_searches.rb +++ b/lib/algolia/models/analytics/daily_searches.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_searches_no_clicks.rb b/lib/algolia/models/analytics/daily_searches_no_clicks.rb index 8e592561..934a3c3d 100644 --- a/lib/algolia/models/analytics/daily_searches_no_clicks.rb +++ b/lib/algolia/models/analytics/daily_searches_no_clicks.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_searches_no_results.rb b/lib/algolia/models/analytics/daily_searches_no_results.rb index 4977bdcb..7abdff0e 100644 --- a/lib/algolia/models/analytics/daily_searches_no_results.rb +++ b/lib/algolia/models/analytics/daily_searches_no_results.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/daily_users.rb b/lib/algolia/models/analytics/daily_users.rb index bed9550e..fe6a4f27 100644 --- a/lib/algolia/models/analytics/daily_users.rb +++ b/lib/algolia/models/analytics/daily_users.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/error_base.rb b/lib/algolia/models/analytics/error_base.rb index 6246062f..d225d46c 100644 --- a/lib/algolia/models/analytics/error_base.rb +++ b/lib/algolia/models/analytics/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb b/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb index 95dcf95f..419a7a23 100644 --- a/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb +++ b/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_average_click_position_response.rb b/lib/algolia/models/analytics/get_average_click_position_response.rb index 1a22285c..e78beca3 100644 --- a/lib/algolia/models/analytics/get_average_click_position_response.rb +++ b/lib/algolia/models/analytics/get_average_click_position_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_click_positions_response.rb b/lib/algolia/models/analytics/get_click_positions_response.rb index 1f69e857..fdb25f7b 100644 --- a/lib/algolia/models/analytics/get_click_positions_response.rb +++ b/lib/algolia/models/analytics/get_click_positions_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_click_through_rate_response.rb b/lib/algolia/models/analytics/get_click_through_rate_response.rb index a6305ee3..e6470fd1 100644 --- a/lib/algolia/models/analytics/get_click_through_rate_response.rb +++ b/lib/algolia/models/analytics/get_click_through_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_conversion_rate_response.rb b/lib/algolia/models/analytics/get_conversion_rate_response.rb index a2f22f4e..7f3c5a80 100644 --- a/lib/algolia/models/analytics/get_conversion_rate_response.rb +++ b/lib/algolia/models/analytics/get_conversion_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_no_click_rate_response.rb b/lib/algolia/models/analytics/get_no_click_rate_response.rb index 279f9030..23459f97 100644 --- a/lib/algolia/models/analytics/get_no_click_rate_response.rb +++ b/lib/algolia/models/analytics/get_no_click_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_no_results_rate_response.rb b/lib/algolia/models/analytics/get_no_results_rate_response.rb index 570f1fed..b7b324a4 100644 --- a/lib/algolia/models/analytics/get_no_results_rate_response.rb +++ b/lib/algolia/models/analytics/get_no_results_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_purchase_rate_response.rb b/lib/algolia/models/analytics/get_purchase_rate_response.rb index e6b384b1..03aae4a2 100644 --- a/lib/algolia/models/analytics/get_purchase_rate_response.rb +++ b/lib/algolia/models/analytics/get_purchase_rate_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_revenue.rb b/lib/algolia/models/analytics/get_revenue.rb index a85f41fd..666b5052 100644 --- a/lib/algolia/models/analytics/get_revenue.rb +++ b/lib/algolia/models/analytics/get_revenue.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_searches_count_response.rb b/lib/algolia/models/analytics/get_searches_count_response.rb index 1701231d..52ac76f8 100644 --- a/lib/algolia/models/analytics/get_searches_count_response.rb +++ b/lib/algolia/models/analytics/get_searches_count_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_searches_no_clicks_response.rb b/lib/algolia/models/analytics/get_searches_no_clicks_response.rb index 30e3e47d..59c96bdb 100644 --- a/lib/algolia/models/analytics/get_searches_no_clicks_response.rb +++ b/lib/algolia/models/analytics/get_searches_no_clicks_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_searches_no_results_response.rb b/lib/algolia/models/analytics/get_searches_no_results_response.rb index 0b605675..967583ae 100644 --- a/lib/algolia/models/analytics/get_searches_no_results_response.rb +++ b/lib/algolia/models/analytics/get_searches_no_results_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_status_response.rb b/lib/algolia/models/analytics/get_status_response.rb index 17db42f1..a76efa75 100644 --- a/lib/algolia/models/analytics/get_status_response.rb +++ b/lib/algolia/models/analytics/get_status_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_countries_response.rb b/lib/algolia/models/analytics/get_top_countries_response.rb index 428f6635..c9a71ffe 100644 --- a/lib/algolia/models/analytics/get_top_countries_response.rb +++ b/lib/algolia/models/analytics/get_top_countries_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filter_attribute.rb b/lib/algolia/models/analytics/get_top_filter_attribute.rb index 5b3f551b..6704ca39 100644 --- a/lib/algolia/models/analytics/get_top_filter_attribute.rb +++ b/lib/algolia/models/analytics/get_top_filter_attribute.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filter_attributes_response.rb b/lib/algolia/models/analytics/get_top_filter_attributes_response.rb index ad02ee5e..ecf6a88d 100644 --- a/lib/algolia/models/analytics/get_top_filter_attributes_response.rb +++ b/lib/algolia/models/analytics/get_top_filter_attributes_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filter_for_attribute.rb b/lib/algolia/models/analytics/get_top_filter_for_attribute.rb index 4af1414a..f99315ed 100644 --- a/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +++ b/lib/algolia/models/analytics/get_top_filter_for_attribute.rb @@ -27,11 +27,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filter_for_attribute_response.rb b/lib/algolia/models/analytics/get_top_filter_for_attribute_response.rb index d2ff0cfa..24e7468a 100644 --- a/lib/algolia/models/analytics/get_top_filter_for_attribute_response.rb +++ b/lib/algolia/models/analytics/get_top_filter_for_attribute_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filters_no_results_response.rb b/lib/algolia/models/analytics/get_top_filters_no_results_response.rb index 5362e162..e7c2c74d 100644 --- a/lib/algolia/models/analytics/get_top_filters_no_results_response.rb +++ b/lib/algolia/models/analytics/get_top_filters_no_results_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filters_no_results_value.rb b/lib/algolia/models/analytics/get_top_filters_no_results_value.rb index 2fc55413..79d1e6d6 100644 --- a/lib/algolia/models/analytics/get_top_filters_no_results_value.rb +++ b/lib/algolia/models/analytics/get_top_filters_no_results_value.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_filters_no_results_values.rb b/lib/algolia/models/analytics/get_top_filters_no_results_values.rb index 9b875217..cf71e066 100644 --- a/lib/algolia/models/analytics/get_top_filters_no_results_values.rb +++ b/lib/algolia/models/analytics/get_top_filters_no_results_values.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/get_top_hits_response.rb b/lib/algolia/models/analytics/get_top_hits_response.rb index 85f8e98d..a86c160a 100644 --- a/lib/algolia/models/analytics/get_top_hits_response.rb +++ b/lib/algolia/models/analytics/get_top_hits_response.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/analytics/get_top_searches_response.rb b/lib/algolia/models/analytics/get_top_searches_response.rb index 9935c16b..ecfc9823 100644 --- a/lib/algolia/models/analytics/get_top_searches_response.rb +++ b/lib/algolia/models/analytics/get_top_searches_response.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/analytics/get_users_count_response.rb b/lib/algolia/models/analytics/get_users_count_response.rb index b6272988..a38bc4e7 100644 --- a/lib/algolia/models/analytics/get_users_count_response.rb +++ b/lib/algolia/models/analytics/get_users_count_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_country.rb b/lib/algolia/models/analytics/top_country.rb index d5942f67..b76245d4 100644 --- a/lib/algolia/models/analytics/top_country.rb +++ b/lib/algolia/models/analytics/top_country.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hit.rb b/lib/algolia/models/analytics/top_hit.rb index a0de5ad8..064d8bd8 100644 --- a/lib/algolia/models/analytics/top_hit.rb +++ b/lib/algolia/models/analytics/top_hit.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hit_with_analytics.rb b/lib/algolia/models/analytics/top_hit_with_analytics.rb index b91307ea..f74a088b 100644 --- a/lib/algolia/models/analytics/top_hit_with_analytics.rb +++ b/lib/algolia/models/analytics/top_hit_with_analytics.rb @@ -40,11 +40,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb b/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb index 715e64db..bdad4255 100644 --- a/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb +++ b/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb @@ -60,11 +60,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hits_response.rb b/lib/algolia/models/analytics/top_hits_response.rb index 3c34ccf6..eeec14d9 100644 --- a/lib/algolia/models/analytics/top_hits_response.rb +++ b/lib/algolia/models/analytics/top_hits_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hits_response_with_analytics.rb b/lib/algolia/models/analytics/top_hits_response_with_analytics.rb index 7a247c38..6716ebdd 100644 --- a/lib/algolia/models/analytics/top_hits_response_with_analytics.rb +++ b/lib/algolia/models/analytics/top_hits_response_with_analytics.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb b/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb index 90b5de36..a96600f3 100644 --- a/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb +++ b/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_search.rb b/lib/algolia/models/analytics/top_search.rb index 495a533b..6eb39e12 100644 --- a/lib/algolia/models/analytics/top_search.rb +++ b/lib/algolia/models/analytics/top_search.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_search_with_analytics.rb b/lib/algolia/models/analytics/top_search_with_analytics.rb index f7b2cb66..37a65a6b 100644 --- a/lib/algolia/models/analytics/top_search_with_analytics.rb +++ b/lib/algolia/models/analytics/top_search_with_analytics.rb @@ -52,11 +52,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb b/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb index 16d0d6ea..1aa9f470 100644 --- a/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +++ b/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb @@ -72,11 +72,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_searches_response.rb b/lib/algolia/models/analytics/top_searches_response.rb index c4976fef..b9ba69db 100644 --- a/lib/algolia/models/analytics/top_searches_response.rb +++ b/lib/algolia/models/analytics/top_searches_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_searches_response_with_analytics.rb b/lib/algolia/models/analytics/top_searches_response_with_analytics.rb index 51a64716..6f5e7f47 100644 --- a/lib/algolia/models/analytics/top_searches_response_with_analytics.rb +++ b/lib/algolia/models/analytics/top_searches_response_with_analytics.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb b/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb index 42f4c942..38a55b4e 100644 --- a/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb +++ b/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/auth_algolia.rb b/lib/algolia/models/ingestion/auth_algolia.rb index 437ce713..da827e9c 100644 --- a/lib/algolia/models/ingestion/auth_algolia.rb +++ b/lib/algolia/models/ingestion/auth_algolia.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/auth_algolia_insights.rb b/lib/algolia/models/ingestion/auth_algolia_insights.rb index 8f08bca6..7eb00f67 100644 --- a/lib/algolia/models/ingestion/auth_algolia_insights.rb +++ b/lib/algolia/models/ingestion/auth_algolia_insights.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/auth_algolia_insights_partial.rb b/lib/algolia/models/ingestion/auth_algolia_insights_partial.rb index 8328b543..ed01f9ea 100644 --- a/lib/algolia/models/ingestion/auth_algolia_insights_partial.rb +++ b/lib/algolia/models/ingestion/auth_algolia_insights_partial.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/auth_algolia_partial.rb b/lib/algolia/models/ingestion/auth_algolia_partial.rb index 9a6a4179..75cd96be 100644 --- a/lib/algolia/models/ingestion/auth_algolia_partial.rb +++ b/lib/algolia/models/ingestion/auth_algolia_partial.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/auth_api_key.rb b/lib/algolia/models/ingestion/auth_api_key.rb index bb4eeea6..f3f3b332 100644 --- a/lib/algolia/models/ingestion/auth_api_key.rb +++ b/lib/algolia/models/ingestion/auth_api_key.rb @@ -17,9 +17,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :key + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_api_key_partial.rb b/lib/algolia/models/ingestion/auth_api_key_partial.rb index a80e383f..a34d8d3c 100644 --- a/lib/algolia/models/ingestion/auth_api_key_partial.rb +++ b/lib/algolia/models/ingestion/auth_api_key_partial.rb @@ -17,9 +17,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :key + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_basic.rb b/lib/algolia/models/ingestion/auth_basic.rb index 0090bc3b..8d396d10 100644 --- a/lib/algolia/models/ingestion/auth_basic.rb +++ b/lib/algolia/models/ingestion/auth_basic.rb @@ -21,9 +21,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :username, + :password + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_basic_partial.rb b/lib/algolia/models/ingestion/auth_basic_partial.rb index 0aa43547..6ae5456a 100644 --- a/lib/algolia/models/ingestion/auth_basic_partial.rb +++ b/lib/algolia/models/ingestion/auth_basic_partial.rb @@ -21,9 +21,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :username + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_google_service_account.rb b/lib/algolia/models/ingestion/auth_google_service_account.rb index 62e7ebc8..d0226023 100644 --- a/lib/algolia/models/ingestion/auth_google_service_account.rb +++ b/lib/algolia/models/ingestion/auth_google_service_account.rb @@ -21,9 +21,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :clientEmail, + :privateKey + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_google_service_account_partial.rb b/lib/algolia/models/ingestion/auth_google_service_account_partial.rb index ff34aad6..14b21a91 100644 --- a/lib/algolia/models/ingestion/auth_google_service_account_partial.rb +++ b/lib/algolia/models/ingestion/auth_google_service_account_partial.rb @@ -21,9 +21,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :clientEmail + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_input.rb b/lib/algolia/models/ingestion/auth_input.rb index d018297b..6b3446cd 100644 --- a/lib/algolia/models/ingestion/auth_input.rb +++ b/lib/algolia/models/ingestion/auth_input.rb @@ -49,7 +49,6 @@ def build(data) 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? @@ -88,12 +87,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/auth_input_partial.rb b/lib/algolia/models/ingestion/auth_input_partial.rb index 0a747778..56639c39 100644 --- a/lib/algolia/models/ingestion/auth_input_partial.rb +++ b/lib/algolia/models/ingestion/auth_input_partial.rb @@ -49,7 +49,6 @@ def build(data) 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? @@ -88,12 +87,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/auth_o_auth.rb b/lib/algolia/models/ingestion/auth_o_auth.rb index 1c524ebe..12f4850a 100644 --- a/lib/algolia/models/ingestion/auth_o_auth.rb +++ b/lib/algolia/models/ingestion/auth_o_auth.rb @@ -29,9 +29,13 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :url, + :client_id, + :client_secret + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/auth_o_auth_partial.rb b/lib/algolia/models/ingestion/auth_o_auth_partial.rb index 47c2ff0b..90862d42 100644 --- a/lib/algolia/models/ingestion/auth_o_auth_partial.rb +++ b/lib/algolia/models/ingestion/auth_o_auth_partial.rb @@ -29,9 +29,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :url + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/authentication.rb b/lib/algolia/models/ingestion/authentication.rb index ae4221a4..b2708224 100644 --- a/lib/algolia/models/ingestion/authentication.rb +++ b/lib/algolia/models/ingestion/authentication.rb @@ -38,11 +38,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/authentication_create.rb b/lib/algolia/models/ingestion/authentication_create.rb index d65fa674..475cbe21 100644 --- a/lib/algolia/models/ingestion/authentication_create.rb +++ b/lib/algolia/models/ingestion/authentication_create.rb @@ -26,11 +26,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/authentication_create_response.rb b/lib/algolia/models/ingestion/authentication_create_response.rb index 4991e25a..60f17820 100644 --- a/lib/algolia/models/ingestion/authentication_create_response.rb +++ b/lib/algolia/models/ingestion/authentication_create_response.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/authentication_search.rb b/lib/algolia/models/ingestion/authentication_search.rb index 50c7458b..6ad5542d 100644 --- a/lib/algolia/models/ingestion/authentication_search.rb +++ b/lib/algolia/models/ingestion/authentication_search.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/authentication_update.rb b/lib/algolia/models/ingestion/authentication_update.rb index 3b756215..e332a37f 100644 --- a/lib/algolia/models/ingestion/authentication_update.rb +++ b/lib/algolia/models/ingestion/authentication_update.rb @@ -26,11 +26,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/authentication_update_response.rb b/lib/algolia/models/ingestion/authentication_update_response.rb index 805192fb..f3b775a7 100644 --- a/lib/algolia/models/ingestion/authentication_update_response.rb +++ b/lib/algolia/models/ingestion/authentication_update_response.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/big_commerce_channel.rb b/lib/algolia/models/ingestion/big_commerce_channel.rb index f87914ff..90bed9fd 100644 --- a/lib/algolia/models/ingestion/big_commerce_channel.rb +++ b/lib/algolia/models/ingestion/big_commerce_channel.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/big_commerce_metafield.rb b/lib/algolia/models/ingestion/big_commerce_metafield.rb index 8b604f27..cf746304 100644 --- a/lib/algolia/models/ingestion/big_commerce_metafield.rb +++ b/lib/algolia/models/ingestion/big_commerce_metafield.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/commercetools_custom_fields.rb b/lib/algolia/models/ingestion/commercetools_custom_fields.rb index 2b422b85..611d2b35 100644 --- a/lib/algolia/models/ingestion/commercetools_custom_fields.rb +++ b/lib/algolia/models/ingestion/commercetools_custom_fields.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/delete_response.rb b/lib/algolia/models/ingestion/delete_response.rb index e3dcfd34..cf163fe2 100644 --- a/lib/algolia/models/ingestion/delete_response.rb +++ b/lib/algolia/models/ingestion/delete_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination.rb b/lib/algolia/models/ingestion/destination.rb index 5d54c6f3..d985bb98 100644 --- a/lib/algolia/models/ingestion/destination.rb +++ b/lib/algolia/models/ingestion/destination.rb @@ -42,11 +42,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_create.rb b/lib/algolia/models/ingestion/destination_create.rb index 3820d0b5..5e610b41 100644 --- a/lib/algolia/models/ingestion/destination_create.rb +++ b/lib/algolia/models/ingestion/destination_create.rb @@ -30,11 +30,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_create_response.rb b/lib/algolia/models/ingestion/destination_create_response.rb index ec3acde1..bb807f1e 100644 --- a/lib/algolia/models/ingestion/destination_create_response.rb +++ b/lib/algolia/models/ingestion/destination_create_response.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_index_name.rb b/lib/algolia/models/ingestion/destination_index_name.rb index 306a5b97..08212e36 100644 --- a/lib/algolia/models/ingestion/destination_index_name.rb +++ b/lib/algolia/models/ingestion/destination_index_name.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_input.rb b/lib/algolia/models/ingestion/destination_input.rb index 15d9b9fc..87f8944e 100644 --- a/lib/algolia/models/ingestion/destination_input.rb +++ b/lib/algolia/models/ingestion/destination_input.rb @@ -43,7 +43,6 @@ def build(data) 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? @@ -82,12 +81,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/destination_search.rb b/lib/algolia/models/ingestion/destination_search.rb index 13e779f9..34990216 100644 --- a/lib/algolia/models/ingestion/destination_search.rb +++ b/lib/algolia/models/ingestion/destination_search.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_update.rb b/lib/algolia/models/ingestion/destination_update.rb index 7c4c22e0..4667c2b4 100644 --- a/lib/algolia/models/ingestion/destination_update.rb +++ b/lib/algolia/models/ingestion/destination_update.rb @@ -30,11 +30,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/destination_update_response.rb b/lib/algolia/models/ingestion/destination_update_response.rb index eb2316cc..b4b48944 100644 --- a/lib/algolia/models/ingestion/destination_update_response.rb +++ b/lib/algolia/models/ingestion/destination_update_response.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/docker_streams.rb b/lib/algolia/models/ingestion/docker_streams.rb index ab484e08..6271ea0b 100644 --- a/lib/algolia/models/ingestion/docker_streams.rb +++ b/lib/algolia/models/ingestion/docker_streams.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/docker_streams_input.rb b/lib/algolia/models/ingestion/docker_streams_input.rb index 206e0e1d..8ed6ce5d 100644 --- a/lib/algolia/models/ingestion/docker_streams_input.rb +++ b/lib/algolia/models/ingestion/docker_streams_input.rb @@ -16,9 +16,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :streams + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/email_notifications.rb b/lib/algolia/models/ingestion/email_notifications.rb index 6082827e..6c150ac8 100644 --- a/lib/algolia/models/ingestion/email_notifications.rb +++ b/lib/algolia/models/ingestion/email_notifications.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/error_base.rb b/lib/algolia/models/ingestion/error_base.rb index a14c6c8b..e037214b 100644 --- a/lib/algolia/models/ingestion/error_base.rb +++ b/lib/algolia/models/ingestion/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/event.rb b/lib/algolia/models/ingestion/event.rb index ebd5d542..f5d72881 100644 --- a/lib/algolia/models/ingestion/event.rb +++ b/lib/algolia/models/ingestion/event.rb @@ -38,11 +38,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_authentications_response.rb b/lib/algolia/models/ingestion/list_authentications_response.rb index 5299ef9d..36ff92f8 100644 --- a/lib/algolia/models/ingestion/list_authentications_response.rb +++ b/lib/algolia/models/ingestion/list_authentications_response.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_destinations_response.rb b/lib/algolia/models/ingestion/list_destinations_response.rb index e2d29151..7905737f 100644 --- a/lib/algolia/models/ingestion/list_destinations_response.rb +++ b/lib/algolia/models/ingestion/list_destinations_response.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_events_response.rb b/lib/algolia/models/ingestion/list_events_response.rb index ec89a9ac..af3424da 100644 --- a/lib/algolia/models/ingestion/list_events_response.rb +++ b/lib/algolia/models/ingestion/list_events_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_sources_response.rb b/lib/algolia/models/ingestion/list_sources_response.rb index fee4b800..5e72f184 100644 --- a/lib/algolia/models/ingestion/list_sources_response.rb +++ b/lib/algolia/models/ingestion/list_sources_response.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_tasks_response.rb b/lib/algolia/models/ingestion/list_tasks_response.rb index 379bb0cc..b01d6b7c 100644 --- a/lib/algolia/models/ingestion/list_tasks_response.rb +++ b/lib/algolia/models/ingestion/list_tasks_response.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_tasks_response_v1.rb b/lib/algolia/models/ingestion/list_tasks_response_v1.rb index 5a648098..bcc2168d 100644 --- a/lib/algolia/models/ingestion/list_tasks_response_v1.rb +++ b/lib/algolia/models/ingestion/list_tasks_response_v1.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/list_transformations_response.rb b/lib/algolia/models/ingestion/list_transformations_response.rb index fd08eaca..4a75c339 100644 --- a/lib/algolia/models/ingestion/list_transformations_response.rb +++ b/lib/algolia/models/ingestion/list_transformations_response.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/mapping_field_directive.rb b/lib/algolia/models/ingestion/mapping_field_directive.rb index 197cc920..0a38430b 100644 --- a/lib/algolia/models/ingestion/mapping_field_directive.rb +++ b/lib/algolia/models/ingestion/mapping_field_directive.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/mapping_input.rb b/lib/algolia/models/ingestion/mapping_input.rb index 47c8e698..df7153bb 100644 --- a/lib/algolia/models/ingestion/mapping_input.rb +++ b/lib/algolia/models/ingestion/mapping_input.rb @@ -19,9 +19,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :format, + :actions + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/mapping_kit_action.rb b/lib/algolia/models/ingestion/mapping_kit_action.rb index f40fb3b3..3956507c 100644 --- a/lib/algolia/models/ingestion/mapping_kit_action.rb +++ b/lib/algolia/models/ingestion/mapping_kit_action.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/notifications.rb b/lib/algolia/models/ingestion/notifications.rb index 8958f0bf..57f6c97a 100644 --- a/lib/algolia/models/ingestion/notifications.rb +++ b/lib/algolia/models/ingestion/notifications.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/on_demand_trigger.rb b/lib/algolia/models/ingestion/on_demand_trigger.rb index 3b859b32..c7b63e35 100644 --- a/lib/algolia/models/ingestion/on_demand_trigger.rb +++ b/lib/algolia/models/ingestion/on_demand_trigger.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/on_demand_trigger_input.rb b/lib/algolia/models/ingestion/on_demand_trigger_input.rb index 17c3c20c..85234937 100644 --- a/lib/algolia/models/ingestion/on_demand_trigger_input.rb +++ b/lib/algolia/models/ingestion/on_demand_trigger_input.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/pagination.rb b/lib/algolia/models/ingestion/pagination.rb index 59349f11..97d97731 100644 --- a/lib/algolia/models/ingestion/pagination.rb +++ b/lib/algolia/models/ingestion/pagination.rb @@ -29,11 +29,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/platform_with_none.rb b/lib/algolia/models/ingestion/platform_with_none.rb index 09c500a5..bba0e458 100644 --- a/lib/algolia/models/ingestion/platform_with_none.rb +++ b/lib/algolia/models/ingestion/platform_with_none.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/policies.rb b/lib/algolia/models/ingestion/policies.rb index 0f555052..29cc5e5e 100644 --- a/lib/algolia/models/ingestion/policies.rb +++ b/lib/algolia/models/ingestion/policies.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/push_task_payload.rb b/lib/algolia/models/ingestion/push_task_payload.rb index e2770428..499e775a 100644 --- a/lib/algolia/models/ingestion/push_task_payload.rb +++ b/lib/algolia/models/ingestion/push_task_payload.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/push_task_records.rb b/lib/algolia/models/ingestion/push_task_records.rb index db6ffdd8..75b927da 100644 --- a/lib/algolia/models/ingestion/push_task_records.rb +++ b/lib/algolia/models/ingestion/push_task_records.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run.rb b/lib/algolia/models/ingestion/run.rb index 700c9393..589951ec 100644 --- a/lib/algolia/models/ingestion/run.rb +++ b/lib/algolia/models/ingestion/run.rb @@ -58,11 +58,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run_list_response.rb b/lib/algolia/models/ingestion/run_list_response.rb index 30824519..b2f35818 100644 --- a/lib/algolia/models/ingestion/run_list_response.rb +++ b/lib/algolia/models/ingestion/run_list_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run_progress.rb b/lib/algolia/models/ingestion/run_progress.rb index b5f268ff..e9087ecd 100644 --- a/lib/algolia/models/ingestion/run_progress.rb +++ b/lib/algolia/models/ingestion/run_progress.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run_response.rb b/lib/algolia/models/ingestion/run_response.rb index eae3e9c4..64ae1abb 100644 --- a/lib/algolia/models/ingestion/run_response.rb +++ b/lib/algolia/models/ingestion/run_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run_source_payload.rb b/lib/algolia/models/ingestion/run_source_payload.rb index 8aaf27a6..a4649e88 100644 --- a/lib/algolia/models/ingestion/run_source_payload.rb +++ b/lib/algolia/models/ingestion/run_source_payload.rb @@ -27,11 +27,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/run_source_response.rb b/lib/algolia/models/ingestion/run_source_response.rb index 141c19cf..469cf77e 100644 --- a/lib/algolia/models/ingestion/run_source_response.rb +++ b/lib/algolia/models/ingestion/run_source_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/schedule_trigger.rb b/lib/algolia/models/ingestion/schedule_trigger.rb index 08db6e22..329dc84c 100644 --- a/lib/algolia/models/ingestion/schedule_trigger.rb +++ b/lib/algolia/models/ingestion/schedule_trigger.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/schedule_trigger_input.rb b/lib/algolia/models/ingestion/schedule_trigger_input.rb index 685009f8..0bd0f405 100644 --- a/lib/algolia/models/ingestion/schedule_trigger_input.rb +++ b/lib/algolia/models/ingestion/schedule_trigger_input.rb @@ -20,9 +20,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :cron + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/shopify_input.rb b/lib/algolia/models/ingestion/shopify_input.rb index 3e74a359..8c05240a 100644 --- a/lib/algolia/models/ingestion/shopify_input.rb +++ b/lib/algolia/models/ingestion/shopify_input.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/shopify_market.rb b/lib/algolia/models/ingestion/shopify_market.rb index 5373494f..79c465a6 100644 --- a/lib/algolia/models/ingestion/shopify_market.rb +++ b/lib/algolia/models/ingestion/shopify_market.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/shopify_metafield.rb b/lib/algolia/models/ingestion/shopify_metafield.rb index 144abcdd..8e61d288 100644 --- a/lib/algolia/models/ingestion/shopify_metafield.rb +++ b/lib/algolia/models/ingestion/shopify_metafield.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source.rb b/lib/algolia/models/ingestion/source.rb index 36927858..b29976a6 100644 --- a/lib/algolia/models/ingestion/source.rb +++ b/lib/algolia/models/ingestion/source.rb @@ -37,11 +37,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_big_commerce.rb b/lib/algolia/models/ingestion/source_big_commerce.rb index 42354272..69ed44f7 100644 --- a/lib/algolia/models/ingestion/source_big_commerce.rb +++ b/lib/algolia/models/ingestion/source_big_commerce.rb @@ -28,9 +28,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :storeHash + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_big_query.rb b/lib/algolia/models/ingestion/source_big_query.rb index 046fa7ea..2b53250b 100644 --- a/lib/algolia/models/ingestion/source_big_query.rb +++ b/lib/algolia/models/ingestion/source_big_query.rb @@ -39,9 +39,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :projectID + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_commercetools.rb b/lib/algolia/models/ingestion/source_commercetools.rb index 8d3c2463..8b1d2494 100644 --- a/lib/algolia/models/ingestion/source_commercetools.rb +++ b/lib/algolia/models/ingestion/source_commercetools.rb @@ -32,9 +32,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :projectKey + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_create.rb b/lib/algolia/models/ingestion/source_create.rb index c04786de..8ef6e5e3 100644 --- a/lib/algolia/models/ingestion/source_create.rb +++ b/lib/algolia/models/ingestion/source_create.rb @@ -26,11 +26,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_create_response.rb b/lib/algolia/models/ingestion/source_create_response.rb index f2008330..ace97dcd 100644 --- a/lib/algolia/models/ingestion/source_create_response.rb +++ b/lib/algolia/models/ingestion/source_create_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_csv.rb b/lib/algolia/models/ingestion/source_csv.rb index c8f78be7..87dec988 100644 --- a/lib/algolia/models/ingestion/source_csv.rb +++ b/lib/algolia/models/ingestion/source_csv.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_docker.rb b/lib/algolia/models/ingestion/source_docker.rb index a414d52e..4a5d23ed 100644 --- a/lib/algolia/models/ingestion/source_docker.rb +++ b/lib/algolia/models/ingestion/source_docker.rb @@ -30,9 +30,14 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :registry, + :image, + :imageType, + :configuration + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_ga4_big_query_export.rb b/lib/algolia/models/ingestion/source_ga4_big_query_export.rb index b01b291d..73ad9fd8 100644 --- a/lib/algolia/models/ingestion/source_ga4_big_query_export.rb +++ b/lib/algolia/models/ingestion/source_ga4_big_query_export.rb @@ -24,9 +24,13 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :projectID, + :datasetID, + :tablePrefix + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_input.rb b/lib/algolia/models/ingestion/source_input.rb index afeff680..be5976f1 100644 --- a/lib/algolia/models/ingestion/source_input.rb +++ b/lib/algolia/models/ingestion/source_input.rb @@ -50,7 +50,6 @@ def build(data) 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? @@ -89,12 +88,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/source_json.rb b/lib/algolia/models/ingestion/source_json.rb index 9322368c..ab462dc8 100644 --- a/lib/algolia/models/ingestion/source_json.rb +++ b/lib/algolia/models/ingestion/source_json.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_search.rb b/lib/algolia/models/ingestion/source_search.rb index f3752a6a..2aa71152 100644 --- a/lib/algolia/models/ingestion/source_search.rb +++ b/lib/algolia/models/ingestion/source_search.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_shopify.rb b/lib/algolia/models/ingestion/source_shopify.rb index 32c12950..9e5ed8a3 100644 --- a/lib/algolia/models/ingestion/source_shopify.rb +++ b/lib/algolia/models/ingestion/source_shopify.rb @@ -20,9 +20,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :shopURL + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_update.rb b/lib/algolia/models/ingestion/source_update.rb index 0ba612ea..c1f1fab4 100644 --- a/lib/algolia/models/ingestion/source_update.rb +++ b/lib/algolia/models/ingestion/source_update.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_update_commercetools.rb b/lib/algolia/models/ingestion/source_update_commercetools.rb index b0759a89..317150d6 100644 --- a/lib/algolia/models/ingestion/source_update_commercetools.rb +++ b/lib/algolia/models/ingestion/source_update_commercetools.rb @@ -29,11 +29,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_update_docker.rb b/lib/algolia/models/ingestion/source_update_docker.rb index d6fdbafe..9d20f191 100644 --- a/lib/algolia/models/ingestion/source_update_docker.rb +++ b/lib/algolia/models/ingestion/source_update_docker.rb @@ -27,9 +27,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :configuration + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/source_update_input.rb b/lib/algolia/models/ingestion/source_update_input.rb index 55de0aed..136c349e 100644 --- a/lib/algolia/models/ingestion/source_update_input.rb +++ b/lib/algolia/models/ingestion/source_update_input.rb @@ -49,7 +49,6 @@ def build(data) 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? @@ -88,12 +87,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/source_update_response.rb b/lib/algolia/models/ingestion/source_update_response.rb index 5bb609eb..a0066078 100644 --- a/lib/algolia/models/ingestion/source_update_response.rb +++ b/lib/algolia/models/ingestion/source_update_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/source_update_shopify.rb b/lib/algolia/models/ingestion/source_update_shopify.rb index 3b4f65cc..ed9e447e 100644 --- a/lib/algolia/models/ingestion/source_update_shopify.rb +++ b/lib/algolia/models/ingestion/source_update_shopify.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/streaming_input.rb b/lib/algolia/models/ingestion/streaming_input.rb index d6be6729..ad4dda20 100644 --- a/lib/algolia/models/ingestion/streaming_input.rb +++ b/lib/algolia/models/ingestion/streaming_input.rb @@ -16,9 +16,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :mapping + ] end # Attribute type mapping. diff --git a/lib/algolia/models/ingestion/streaming_trigger.rb b/lib/algolia/models/ingestion/streaming_trigger.rb index cb61e554..32e5c3e7 100644 --- a/lib/algolia/models/ingestion/streaming_trigger.rb +++ b/lib/algolia/models/ingestion/streaming_trigger.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/subscription_trigger.rb b/lib/algolia/models/ingestion/subscription_trigger.rb index 0296553d..7d789ec2 100644 --- a/lib/algolia/models/ingestion/subscription_trigger.rb +++ b/lib/algolia/models/ingestion/subscription_trigger.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task.rb b/lib/algolia/models/ingestion/task.rb index 668955e0..16715240 100644 --- a/lib/algolia/models/ingestion/task.rb +++ b/lib/algolia/models/ingestion/task.rb @@ -68,11 +68,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_create.rb b/lib/algolia/models/ingestion/task_create.rb index 8a4a75da..d364444e 100644 --- a/lib/algolia/models/ingestion/task_create.rb +++ b/lib/algolia/models/ingestion/task_create.rb @@ -49,11 +49,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_create_response.rb b/lib/algolia/models/ingestion/task_create_response.rb index f520970d..9aa4b686 100644 --- a/lib/algolia/models/ingestion/task_create_response.rb +++ b/lib/algolia/models/ingestion/task_create_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_create_trigger.rb b/lib/algolia/models/ingestion/task_create_trigger.rb index 439fdb47..eab0a811 100644 --- a/lib/algolia/models/ingestion/task_create_trigger.rb +++ b/lib/algolia/models/ingestion/task_create_trigger.rb @@ -46,7 +46,6 @@ def build(data) 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? @@ -85,12 +84,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/task_create_v1.rb b/lib/algolia/models/ingestion/task_create_v1.rb index 636d0fa9..229f7a77 100644 --- a/lib/algolia/models/ingestion/task_create_v1.rb +++ b/lib/algolia/models/ingestion/task_create_v1.rb @@ -42,11 +42,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_input.rb b/lib/algolia/models/ingestion/task_input.rb index 981b4da1..6fc9cf16 100644 --- a/lib/algolia/models/ingestion/task_input.rb +++ b/lib/algolia/models/ingestion/task_input.rb @@ -46,7 +46,6 @@ def build(data) 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? @@ -85,12 +84,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/task_search.rb b/lib/algolia/models/ingestion/task_search.rb index 5203da5b..25d88a43 100644 --- a/lib/algolia/models/ingestion/task_search.rb +++ b/lib/algolia/models/ingestion/task_search.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_update.rb b/lib/algolia/models/ingestion/task_update.rb index af696b1a..cedfdf4e 100644 --- a/lib/algolia/models/ingestion/task_update.rb +++ b/lib/algolia/models/ingestion/task_update.rb @@ -38,11 +38,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_update_response.rb b/lib/algolia/models/ingestion/task_update_response.rb index 37476ca6..214c4058 100644 --- a/lib/algolia/models/ingestion/task_update_response.rb +++ b/lib/algolia/models/ingestion/task_update_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_update_v1.rb b/lib/algolia/models/ingestion/task_update_v1.rb index c33f932a..9dc57e5a 100644 --- a/lib/algolia/models/ingestion/task_update_v1.rb +++ b/lib/algolia/models/ingestion/task_update_v1.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/task_v1.rb b/lib/algolia/models/ingestion/task_v1.rb index 88ef8343..0143180a 100644 --- a/lib/algolia/models/ingestion/task_v1.rb +++ b/lib/algolia/models/ingestion/task_v1.rb @@ -60,11 +60,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation.rb b/lib/algolia/models/ingestion/transformation.rb index 9c3fca9b..41319275 100644 --- a/lib/algolia/models/ingestion/transformation.rb +++ b/lib/algolia/models/ingestion/transformation.rb @@ -40,11 +40,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_create.rb b/lib/algolia/models/ingestion/transformation_create.rb index 3c475c22..198b8542 100644 --- a/lib/algolia/models/ingestion/transformation_create.rb +++ b/lib/algolia/models/ingestion/transformation_create.rb @@ -29,11 +29,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_create_response.rb b/lib/algolia/models/ingestion/transformation_create_response.rb index d657090a..075baa62 100644 --- a/lib/algolia/models/ingestion/transformation_create_response.rb +++ b/lib/algolia/models/ingestion/transformation_create_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_error.rb b/lib/algolia/models/ingestion/transformation_error.rb index 77aeec7a..7df8ce64 100644 --- a/lib/algolia/models/ingestion/transformation_error.rb +++ b/lib/algolia/models/ingestion/transformation_error.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_search.rb b/lib/algolia/models/ingestion/transformation_search.rb index 9ee22a05..53af09e3 100644 --- a/lib/algolia/models/ingestion/transformation_search.rb +++ b/lib/algolia/models/ingestion/transformation_search.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_try.rb b/lib/algolia/models/ingestion/transformation_try.rb index d8f60591..7c9fab7e 100644 --- a/lib/algolia/models/ingestion/transformation_try.rb +++ b/lib/algolia/models/ingestion/transformation_try.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_try_response.rb b/lib/algolia/models/ingestion/transformation_try_response.rb index 6ee25cb3..4f217d00 100644 --- a/lib/algolia/models/ingestion/transformation_try_response.rb +++ b/lib/algolia/models/ingestion/transformation_try_response.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/transformation_update_response.rb b/lib/algolia/models/ingestion/transformation_update_response.rb index a90bb07c..a343c599 100644 --- a/lib/algolia/models/ingestion/transformation_update_response.rb +++ b/lib/algolia/models/ingestion/transformation_update_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/trigger.rb b/lib/algolia/models/ingestion/trigger.rb index fe7df5b3..8f051db5 100644 --- a/lib/algolia/models/ingestion/trigger.rb +++ b/lib/algolia/models/ingestion/trigger.rb @@ -47,7 +47,6 @@ def build(data) 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? @@ -86,12 +85,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/ingestion/trigger_update_input.rb b/lib/algolia/models/ingestion/trigger_update_input.rb index 962d69bf..0577c6ad 100644 --- a/lib/algolia/models/ingestion/trigger_update_input.rb +++ b/lib/algolia/models/ingestion/trigger_update_input.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/watch_response.rb b/lib/algolia/models/ingestion/watch_response.rb index add0a261..3a07b09a 100644 --- a/lib/algolia/models/ingestion/watch_response.rb +++ b/lib/algolia/models/ingestion/watch_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/ingestion/window.rb b/lib/algolia/models/ingestion/window.rb index feff0e1e..7c23a558 100644 --- a/lib/algolia/models/ingestion/window.rb +++ b/lib/algolia/models/ingestion/window.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/added_to_cart_object_ids.rb b/lib/algolia/models/insights/added_to_cart_object_ids.rb index 7c15eb56..4e23a33d 100644 --- a/lib/algolia/models/insights/added_to_cart_object_ids.rb +++ b/lib/algolia/models/insights/added_to_cart_object_ids.rb @@ -54,9 +54,13 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :eventSubtype, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb b/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb index aff54c6e..25eb9569 100644 --- a/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +++ b/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb @@ -58,9 +58,14 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :eventSubtype, + :queryID, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/clicked_filters.rb b/lib/algolia/models/insights/clicked_filters.rb index 29f09872..72698dd9 100644 --- a/lib/algolia/models/insights/clicked_filters.rb +++ b/lib/algolia/models/insights/clicked_filters.rb @@ -40,9 +40,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :filters + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/clicked_object_ids.rb b/lib/algolia/models/insights/clicked_object_ids.rb index 46dfa5fb..422af46c 100644 --- a/lib/algolia/models/insights/clicked_object_ids.rb +++ b/lib/algolia/models/insights/clicked_object_ids.rb @@ -40,9 +40,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/clicked_object_ids_after_search.rb b/lib/algolia/models/insights/clicked_object_ids_after_search.rb index 276b3294..02056647 100644 --- a/lib/algolia/models/insights/clicked_object_ids_after_search.rb +++ b/lib/algolia/models/insights/clicked_object_ids_after_search.rb @@ -48,9 +48,13 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :positions, + :queryID, + :eventType + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/converted_filters.rb b/lib/algolia/models/insights/converted_filters.rb index 21cf9358..27f3f7a4 100644 --- a/lib/algolia/models/insights/converted_filters.rb +++ b/lib/algolia/models/insights/converted_filters.rb @@ -39,9 +39,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :filters + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/converted_object_ids.rb b/lib/algolia/models/insights/converted_object_ids.rb index 37a36596..7ec1654e 100644 --- a/lib/algolia/models/insights/converted_object_ids.rb +++ b/lib/algolia/models/insights/converted_object_ids.rb @@ -40,9 +40,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/converted_object_ids_after_search.rb b/lib/algolia/models/insights/converted_object_ids_after_search.rb index c69c9f56..f1559849 100644 --- a/lib/algolia/models/insights/converted_object_ids_after_search.rb +++ b/lib/algolia/models/insights/converted_object_ids_after_search.rb @@ -44,9 +44,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :queryID, + :eventType + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/discount.rb b/lib/algolia/models/insights/discount.rb index 6a32d48f..a36d951e 100644 --- a/lib/algolia/models/insights/discount.rb +++ b/lib/algolia/models/insights/discount.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/insights/error_base.rb b/lib/algolia/models/insights/error_base.rb index 4c5832a9..e03e2564 100644 --- a/lib/algolia/models/insights/error_base.rb +++ b/lib/algolia/models/insights/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/events_items.rb b/lib/algolia/models/insights/events_items.rb index c171e5ae..4f8095ad 100644 --- a/lib/algolia/models/insights/events_items.rb +++ b/lib/algolia/models/insights/events_items.rb @@ -54,7 +54,6 @@ def build(data) 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? @@ -93,12 +92,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/insights/events_response.rb b/lib/algolia/models/insights/events_response.rb index 608a1456..0ea1639d 100644 --- a/lib/algolia/models/insights/events_response.rb +++ b/lib/algolia/models/insights/events_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/insights_events.rb b/lib/algolia/models/insights/insights_events.rb index 16832c77..295ef611 100644 --- a/lib/algolia/models/insights/insights_events.rb +++ b/lib/algolia/models/insights/insights_events.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/object_data.rb b/lib/algolia/models/insights/object_data.rb index 634da24a..ee86b23a 100644 --- a/lib/algolia/models/insights/object_data.rb +++ b/lib/algolia/models/insights/object_data.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/object_data_after_search.rb b/lib/algolia/models/insights/object_data_after_search.rb index 49352496..435129b8 100644 --- a/lib/algolia/models/insights/object_data_after_search.rb +++ b/lib/algolia/models/insights/object_data_after_search.rb @@ -26,11 +26,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/insights/price.rb b/lib/algolia/models/insights/price.rb index f4774d90..fb4418a7 100644 --- a/lib/algolia/models/insights/price.rb +++ b/lib/algolia/models/insights/price.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/insights/purchased_object_ids.rb b/lib/algolia/models/insights/purchased_object_ids.rb index 5985e2d4..163ee7a2 100644 --- a/lib/algolia/models/insights/purchased_object_ids.rb +++ b/lib/algolia/models/insights/purchased_object_ids.rb @@ -54,9 +54,13 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :eventSubtype, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/purchased_object_ids_after_search.rb b/lib/algolia/models/insights/purchased_object_ids_after_search.rb index 5d31e667..a6a92458 100644 --- a/lib/algolia/models/insights/purchased_object_ids_after_search.rb +++ b/lib/algolia/models/insights/purchased_object_ids_after_search.rb @@ -54,9 +54,14 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :eventSubtype, + :objectIDs, + :objectData + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/value.rb b/lib/algolia/models/insights/value.rb index 9af6cfa3..778861aa 100644 --- a/lib/algolia/models/insights/value.rb +++ b/lib/algolia/models/insights/value.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/insights/viewed_filters.rb b/lib/algolia/models/insights/viewed_filters.rb index 905acf52..b6cd17a8 100644 --- a/lib/algolia/models/insights/viewed_filters.rb +++ b/lib/algolia/models/insights/viewed_filters.rb @@ -40,9 +40,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :filters + ] end # Attribute type mapping. diff --git a/lib/algolia/models/insights/viewed_object_ids.rb b/lib/algolia/models/insights/viewed_object_ids.rb index be1f15aa..7b95c4ff 100644 --- a/lib/algolia/models/insights/viewed_object_ids.rb +++ b/lib/algolia/models/insights/viewed_object_ids.rb @@ -40,9 +40,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :eventType, + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/monitoring/error_base.rb b/lib/algolia/models/monitoring/error_base.rb index b50e0f86..6b71f9f1 100644 --- a/lib/algolia/models/monitoring/error_base.rb +++ b/lib/algolia/models/monitoring/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/incident.rb b/lib/algolia/models/monitoring/incident.rb index da44d52e..3fc3042d 100644 --- a/lib/algolia/models/monitoring/incident.rb +++ b/lib/algolia/models/monitoring/incident.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/incident_entry.rb b/lib/algolia/models/monitoring/incident_entry.rb index e23cc4ff..0f3d46e7 100644 --- a/lib/algolia/models/monitoring/incident_entry.rb +++ b/lib/algolia/models/monitoring/incident_entry.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/incidents_response.rb b/lib/algolia/models/monitoring/incidents_response.rb index d13c015e..abc12767 100644 --- a/lib/algolia/models/monitoring/incidents_response.rb +++ b/lib/algolia/models/monitoring/incidents_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/indexing_metric.rb b/lib/algolia/models/monitoring/indexing_metric.rb index 45362f6a..9538d0df 100644 --- a/lib/algolia/models/monitoring/indexing_metric.rb +++ b/lib/algolia/models/monitoring/indexing_metric.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/indexing_time_response.rb b/lib/algolia/models/monitoring/indexing_time_response.rb index 053f7531..6d12cf27 100644 --- a/lib/algolia/models/monitoring/indexing_time_response.rb +++ b/lib/algolia/models/monitoring/indexing_time_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/infrastructure_response.rb b/lib/algolia/models/monitoring/infrastructure_response.rb index 89b2f972..e0124264 100644 --- a/lib/algolia/models/monitoring/infrastructure_response.rb +++ b/lib/algolia/models/monitoring/infrastructure_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/inventory_response.rb b/lib/algolia/models/monitoring/inventory_response.rb index 4ae8a80f..5465b1a1 100644 --- a/lib/algolia/models/monitoring/inventory_response.rb +++ b/lib/algolia/models/monitoring/inventory_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/latency_metric.rb b/lib/algolia/models/monitoring/latency_metric.rb index c9d6d52a..310aa2e5 100644 --- a/lib/algolia/models/monitoring/latency_metric.rb +++ b/lib/algolia/models/monitoring/latency_metric.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/latency_response.rb b/lib/algolia/models/monitoring/latency_response.rb index 0c404c7f..f6d316ad 100644 --- a/lib/algolia/models/monitoring/latency_response.rb +++ b/lib/algolia/models/monitoring/latency_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/metrics.rb b/lib/algolia/models/monitoring/metrics.rb index ca29313c..67a40d00 100644 --- a/lib/algolia/models/monitoring/metrics.rb +++ b/lib/algolia/models/monitoring/metrics.rb @@ -32,11 +32,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/probes_metric.rb b/lib/algolia/models/monitoring/probes_metric.rb index 1e22fd87..104a7d2e 100644 --- a/lib/algolia/models/monitoring/probes_metric.rb +++ b/lib/algolia/models/monitoring/probes_metric.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/server.rb b/lib/algolia/models/monitoring/server.rb index 90ba270b..754666f4 100644 --- a/lib/algolia/models/monitoring/server.rb +++ b/lib/algolia/models/monitoring/server.rb @@ -37,11 +37,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/status_response.rb b/lib/algolia/models/monitoring/status_response.rb index e1bb0884..535dd6dc 100644 --- a/lib/algolia/models/monitoring/status_response.rb +++ b/lib/algolia/models/monitoring/status_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/monitoring/time_entry.rb b/lib/algolia/models/monitoring/time_entry.rb index ef2cb1d2..527ee453 100644 --- a/lib/algolia/models/monitoring/time_entry.rb +++ b/lib/algolia/models/monitoring/time_entry.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/delete_user_profile_response.rb b/lib/algolia/models/personalization/delete_user_profile_response.rb index 8e23e19d..7e94448e 100644 --- a/lib/algolia/models/personalization/delete_user_profile_response.rb +++ b/lib/algolia/models/personalization/delete_user_profile_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/error_base.rb b/lib/algolia/models/personalization/error_base.rb index 372d23ad..4dc3febc 100644 --- a/lib/algolia/models/personalization/error_base.rb +++ b/lib/algolia/models/personalization/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/events_scoring.rb b/lib/algolia/models/personalization/events_scoring.rb index 2f84b79e..52512e3d 100644 --- a/lib/algolia/models/personalization/events_scoring.rb +++ b/lib/algolia/models/personalization/events_scoring.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/facets_scoring.rb b/lib/algolia/models/personalization/facets_scoring.rb index f6f8a9d7..10582ab4 100644 --- a/lib/algolia/models/personalization/facets_scoring.rb +++ b/lib/algolia/models/personalization/facets_scoring.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/get_user_token_response.rb b/lib/algolia/models/personalization/get_user_token_response.rb index 7fbcd07e..eab7fd79 100644 --- a/lib/algolia/models/personalization/get_user_token_response.rb +++ b/lib/algolia/models/personalization/get_user_token_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/personalization_strategy_params.rb b/lib/algolia/models/personalization/personalization_strategy_params.rb index a41c02bd..75c66899 100644 --- a/lib/algolia/models/personalization/personalization_strategy_params.rb +++ b/lib/algolia/models/personalization/personalization_strategy_params.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/personalization/set_personalization_strategy_response.rb b/lib/algolia/models/personalization/set_personalization_strategy_response.rb index d118de34..dc51b2f0 100644 --- a/lib/algolia/models/personalization/set_personalization_strategy_response.rb +++ b/lib/algolia/models/personalization/set_personalization_strategy_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/base_response.rb b/lib/algolia/models/query-suggestions/base_response.rb index 698edac7..24f1c7ee 100644 --- a/lib/algolia/models/query-suggestions/base_response.rb +++ b/lib/algolia/models/query-suggestions/base_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/config_status.rb b/lib/algolia/models/query-suggestions/config_status.rb index 0911d42d..0ad41a71 100644 --- a/lib/algolia/models/query-suggestions/config_status.rb +++ b/lib/algolia/models/query-suggestions/config_status.rb @@ -32,11 +32,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/configuration.rb b/lib/algolia/models/query-suggestions/configuration.rb index 45824720..8ea476b3 100644 --- a/lib/algolia/models/query-suggestions/configuration.rb +++ b/lib/algolia/models/query-suggestions/configuration.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/configuration_response.rb b/lib/algolia/models/query-suggestions/configuration_response.rb index 1235fe59..6abc903d 100644 --- a/lib/algolia/models/query-suggestions/configuration_response.rb +++ b/lib/algolia/models/query-suggestions/configuration_response.rb @@ -39,11 +39,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/configuration_with_index.rb b/lib/algolia/models/query-suggestions/configuration_with_index.rb index 6b6b34c9..c5cf164e 100644 --- a/lib/algolia/models/query-suggestions/configuration_with_index.rb +++ b/lib/algolia/models/query-suggestions/configuration_with_index.rb @@ -35,11 +35,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/error_base.rb b/lib/algolia/models/query-suggestions/error_base.rb index b757ec40..c5bb286e 100644 --- a/lib/algolia/models/query-suggestions/error_base.rb +++ b/lib/algolia/models/query-suggestions/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/facet.rb b/lib/algolia/models/query-suggestions/facet.rb index b19636cb..a2f1afa6 100644 --- a/lib/algolia/models/query-suggestions/facet.rb +++ b/lib/algolia/models/query-suggestions/facet.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/languages.rb b/lib/algolia/models/query-suggestions/languages.rb index d5c478f2..ad28131c 100644 --- a/lib/algolia/models/query-suggestions/languages.rb +++ b/lib/algolia/models/query-suggestions/languages.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/query-suggestions/log_file.rb b/lib/algolia/models/query-suggestions/log_file.rb index 588c11f9..82255557 100644 --- a/lib/algolia/models/query-suggestions/log_file.rb +++ b/lib/algolia/models/query-suggestions/log_file.rb @@ -27,11 +27,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/query-suggestions/source_index.rb b/lib/algolia/models/query-suggestions/source_index.rb index 0098aa6e..4d6ddac7 100644 --- a/lib/algolia/models/query-suggestions/source_index.rb +++ b/lib/algolia/models/query-suggestions/source_index.rb @@ -41,11 +41,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/around_precision.rb b/lib/algolia/models/recommend/around_precision.rb index 18ebfcb6..ba4108f2 100644 --- a/lib/algolia/models/recommend/around_precision.rb +++ b/lib/algolia/models/recommend/around_precision.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/around_radius.rb b/lib/algolia/models/recommend/around_radius.rb index b426e374..daac8226 100644 --- a/lib/algolia/models/recommend/around_radius.rb +++ b/lib/algolia/models/recommend/around_radius.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/auto_facet_filter.rb b/lib/algolia/models/recommend/auto_facet_filter.rb index 1e61ee3d..cbf53ad4 100644 --- a/lib/algolia/models/recommend/auto_facet_filter.rb +++ b/lib/algolia/models/recommend/auto_facet_filter.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/banner.rb b/lib/algolia/models/recommend/banner.rb index 9590524e..913cacdb 100644 --- a/lib/algolia/models/recommend/banner.rb +++ b/lib/algolia/models/recommend/banner.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/banner_image.rb b/lib/algolia/models/recommend/banner_image.rb index d33289e2..d027a904 100644 --- a/lib/algolia/models/recommend/banner_image.rb +++ b/lib/algolia/models/recommend/banner_image.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/banner_image_url.rb b/lib/algolia/models/recommend/banner_image_url.rb index 463d563e..06cb6f0c 100644 --- a/lib/algolia/models/recommend/banner_image_url.rb +++ b/lib/algolia/models/recommend/banner_image_url.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/banner_link.rb b/lib/algolia/models/recommend/banner_link.rb index 9c6c7593..3d109cc4 100644 --- a/lib/algolia/models/recommend/banner_link.rb +++ b/lib/algolia/models/recommend/banner_link.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/bought_together_query.rb b/lib/algolia/models/recommend/bought_together_query.rb index 3bdeddb5..c256ab0c 100644 --- a/lib/algolia/models/recommend/bought_together_query.rb +++ b/lib/algolia/models/recommend/bought_together_query.rb @@ -34,11 +34,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/condition.rb b/lib/algolia/models/recommend/condition.rb index a9a93754..1941dc69 100644 --- a/lib/algolia/models/recommend/condition.rb +++ b/lib/algolia/models/recommend/condition.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/consequence.rb b/lib/algolia/models/recommend/consequence.rb index 0d800bc3..188b0af4 100644 --- a/lib/algolia/models/recommend/consequence.rb +++ b/lib/algolia/models/recommend/consequence.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/deleted_at_response.rb b/lib/algolia/models/recommend/deleted_at_response.rb index 7094217c..3c5e87cf 100644 --- a/lib/algolia/models/recommend/deleted_at_response.rb +++ b/lib/algolia/models/recommend/deleted_at_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/distinct.rb b/lib/algolia/models/recommend/distinct.rb index 9f8ccf69..85ebd20d 100644 --- a/lib/algolia/models/recommend/distinct.rb +++ b/lib/algolia/models/recommend/distinct.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/error_base.rb b/lib/algolia/models/recommend/error_base.rb index 66c33e23..7671d9b2 100644 --- a/lib/algolia/models/recommend/error_base.rb +++ b/lib/algolia/models/recommend/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/exhaustive.rb b/lib/algolia/models/recommend/exhaustive.rb index c5e186dd..b03504f9 100644 --- a/lib/algolia/models/recommend/exhaustive.rb +++ b/lib/algolia/models/recommend/exhaustive.rb @@ -33,11 +33,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/facet_filters.rb b/lib/algolia/models/recommend/facet_filters.rb index 6261f008..84fd2a3a 100644 --- a/lib/algolia/models/recommend/facet_filters.rb +++ b/lib/algolia/models/recommend/facet_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/facet_ordering.rb b/lib/algolia/models/recommend/facet_ordering.rb index 09d3248c..cf55ff5e 100644 --- a/lib/algolia/models/recommend/facet_ordering.rb +++ b/lib/algolia/models/recommend/facet_ordering.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/facet_stats.rb b/lib/algolia/models/recommend/facet_stats.rb index 338bbf58..0afec7c8 100644 --- a/lib/algolia/models/recommend/facet_stats.rb +++ b/lib/algolia/models/recommend/facet_stats.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/fallback_params.rb b/lib/algolia/models/recommend/fallback_params.rb index 9aa83006..a7fe0973 100644 --- a/lib/algolia/models/recommend/fallback_params.rb +++ b/lib/algolia/models/recommend/fallback_params.rb @@ -335,11 +335,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/get_recommend_task_response.rb b/lib/algolia/models/recommend/get_recommend_task_response.rb index 93504b85..810f9968 100644 --- a/lib/algolia/models/recommend/get_recommend_task_response.rb +++ b/lib/algolia/models/recommend/get_recommend_task_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/get_recommendations_params.rb b/lib/algolia/models/recommend/get_recommendations_params.rb index cd37acc4..d31f541a 100644 --- a/lib/algolia/models/recommend/get_recommendations_params.rb +++ b/lib/algolia/models/recommend/get_recommendations_params.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/get_recommendations_response.rb b/lib/algolia/models/recommend/get_recommendations_response.rb index 0f5397f4..1cb4a86f 100644 --- a/lib/algolia/models/recommend/get_recommendations_response.rb +++ b/lib/algolia/models/recommend/get_recommendations_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/hide_consequence_object.rb b/lib/algolia/models/recommend/hide_consequence_object.rb index d0ff6dbf..388faf40 100644 --- a/lib/algolia/models/recommend/hide_consequence_object.rb +++ b/lib/algolia/models/recommend/hide_consequence_object.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/highlight_result.rb b/lib/algolia/models/recommend/highlight_result.rb index 0cc496e5..5cfa4c41 100644 --- a/lib/algolia/models/recommend/highlight_result.rb +++ b/lib/algolia/models/recommend/highlight_result.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/highlight_result_option.rb b/lib/algolia/models/recommend/highlight_result_option.rb index 23038d67..4ef196de 100644 --- a/lib/algolia/models/recommend/highlight_result_option.rb +++ b/lib/algolia/models/recommend/highlight_result_option.rb @@ -28,9 +28,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :matchLevel, + :matchedWords + ] end # Attribute type mapping. diff --git a/lib/algolia/models/recommend/ignore_plurals.rb b/lib/algolia/models/recommend/ignore_plurals.rb index 3606ca1d..fea089c9 100644 --- a/lib/algolia/models/recommend/ignore_plurals.rb +++ b/lib/algolia/models/recommend/ignore_plurals.rb @@ -46,7 +46,6 @@ def build(data) 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? @@ -85,12 +84,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/index_settings_facets.rb b/lib/algolia/models/recommend/index_settings_facets.rb index ef78f044..01f14a2c 100644 --- a/lib/algolia/models/recommend/index_settings_facets.rb +++ b/lib/algolia/models/recommend/index_settings_facets.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/inside_bounding_box.rb b/lib/algolia/models/recommend/inside_bounding_box.rb index 4f292426..ba242cab 100644 --- a/lib/algolia/models/recommend/inside_bounding_box.rb +++ b/lib/algolia/models/recommend/inside_bounding_box.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/looking_similar_query.rb b/lib/algolia/models/recommend/looking_similar_query.rb index c5923a48..c1a1ce68 100644 --- a/lib/algolia/models/recommend/looking_similar_query.rb +++ b/lib/algolia/models/recommend/looking_similar_query.rb @@ -37,11 +37,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/matched_geo_location.rb b/lib/algolia/models/recommend/matched_geo_location.rb index 4596c8af..3b8b895b 100644 --- a/lib/algolia/models/recommend/matched_geo_location.rb +++ b/lib/algolia/models/recommend/matched_geo_location.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/numeric_filters.rb b/lib/algolia/models/recommend/numeric_filters.rb index c8420639..45bb53a2 100644 --- a/lib/algolia/models/recommend/numeric_filters.rb +++ b/lib/algolia/models/recommend/numeric_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/optional_filters.rb b/lib/algolia/models/recommend/optional_filters.rb index cd4236bd..88ceb1d4 100644 --- a/lib/algolia/models/recommend/optional_filters.rb +++ b/lib/algolia/models/recommend/optional_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/optional_words.rb b/lib/algolia/models/recommend/optional_words.rb index f1af98c6..617ea8c4 100644 --- a/lib/algolia/models/recommend/optional_words.rb +++ b/lib/algolia/models/recommend/optional_words.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/params_consequence.rb b/lib/algolia/models/recommend/params_consequence.rb index 10432c59..1bddbac3 100644 --- a/lib/algolia/models/recommend/params_consequence.rb +++ b/lib/algolia/models/recommend/params_consequence.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/personalization.rb b/lib/algolia/models/recommend/personalization.rb index 233c8bc5..7e53379d 100644 --- a/lib/algolia/models/recommend/personalization.rb +++ b/lib/algolia/models/recommend/personalization.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/promote_consequence_object.rb b/lib/algolia/models/recommend/promote_consequence_object.rb index 36362ee2..a292083a 100644 --- a/lib/algolia/models/recommend/promote_consequence_object.rb +++ b/lib/algolia/models/recommend/promote_consequence_object.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/range.rb b/lib/algolia/models/recommend/range.rb index f4571fef..514258e1 100644 --- a/lib/algolia/models/recommend/range.rb +++ b/lib/algolia/models/recommend/range.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/ranking_info.rb b/lib/algolia/models/recommend/ranking_info.rb index ff7ceb5d..dbbc2bc3 100644 --- a/lib/algolia/models/recommend/ranking_info.rb +++ b/lib/algolia/models/recommend/ranking_info.rb @@ -63,11 +63,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/re_ranking_apply_filter.rb b/lib/algolia/models/recommend/re_ranking_apply_filter.rb index 2dd96834..aaf182ef 100644 --- a/lib/algolia/models/recommend/re_ranking_apply_filter.rb +++ b/lib/algolia/models/recommend/re_ranking_apply_filter.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/recommend_hit.rb b/lib/algolia/models/recommend/recommend_hit.rb index 3cb1ee07..9d65129f 100644 --- a/lib/algolia/models/recommend/recommend_hit.rb +++ b/lib/algolia/models/recommend/recommend_hit.rb @@ -37,9 +37,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :objectID + ] end # Attribute type mapping. diff --git a/lib/algolia/models/recommend/recommend_rule.rb b/lib/algolia/models/recommend/recommend_rule.rb index 753702af..356e9374 100644 --- a/lib/algolia/models/recommend/recommend_rule.rb +++ b/lib/algolia/models/recommend/recommend_rule.rb @@ -38,11 +38,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/recommend_search_params.rb b/lib/algolia/models/recommend/recommend_search_params.rb index d7e6a023..26008c1b 100644 --- a/lib/algolia/models/recommend/recommend_search_params.rb +++ b/lib/algolia/models/recommend/recommend_search_params.rb @@ -336,11 +336,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/recommend_updated_at_response.rb b/lib/algolia/models/recommend/recommend_updated_at_response.rb index 312febd7..ed607277 100644 --- a/lib/algolia/models/recommend/recommend_updated_at_response.rb +++ b/lib/algolia/models/recommend/recommend_updated_at_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/recommendations_hit.rb b/lib/algolia/models/recommend/recommendations_hit.rb index ba20dcb6..369ca9e3 100644 --- a/lib/algolia/models/recommend/recommendations_hit.rb +++ b/lib/algolia/models/recommend/recommendations_hit.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/recommendations_request.rb b/lib/algolia/models/recommend/recommendations_request.rb index c594b6d4..67f7c824 100644 --- a/lib/algolia/models/recommend/recommendations_request.rb +++ b/lib/algolia/models/recommend/recommendations_request.rb @@ -47,7 +47,6 @@ def build(data) 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? @@ -86,12 +85,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/recommendations_results.rb b/lib/algolia/models/recommend/recommendations_results.rb index 6af55b22..a29ee580 100644 --- a/lib/algolia/models/recommend/recommendations_results.rb +++ b/lib/algolia/models/recommend/recommendations_results.rb @@ -132,11 +132,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/redirect.rb b/lib/algolia/models/recommend/redirect.rb index 2ecb468a..0d95157a 100644 --- a/lib/algolia/models/recommend/redirect.rb +++ b/lib/algolia/models/recommend/redirect.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/redirect_rule_index_data.rb b/lib/algolia/models/recommend/redirect_rule_index_data.rb index 39b991a7..ab19191d 100644 --- a/lib/algolia/models/recommend/redirect_rule_index_data.rb +++ b/lib/algolia/models/recommend/redirect_rule_index_data.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/redirect_rule_index_metadata.rb b/lib/algolia/models/recommend/redirect_rule_index_metadata.rb index 8cb54144..a6c84190 100644 --- a/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +++ b/lib/algolia/models/recommend/redirect_rule_index_metadata.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/redirect_url.rb b/lib/algolia/models/recommend/redirect_url.rb index 69e750c3..80543a3c 100644 --- a/lib/algolia/models/recommend/redirect_url.rb +++ b/lib/algolia/models/recommend/redirect_url.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/related_query.rb b/lib/algolia/models/recommend/related_query.rb index 5d7d14f6..de02ddf6 100644 --- a/lib/algolia/models/recommend/related_query.rb +++ b/lib/algolia/models/recommend/related_query.rb @@ -37,11 +37,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/remove_stop_words.rb b/lib/algolia/models/recommend/remove_stop_words.rb index a2de371f..2d71d4c0 100644 --- a/lib/algolia/models/recommend/remove_stop_words.rb +++ b/lib/algolia/models/recommend/remove_stop_words.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/rendering_content.rb b/lib/algolia/models/recommend/rendering_content.rb index 41e1fe54..8d4001e3 100644 --- a/lib/algolia/models/recommend/rendering_content.rb +++ b/lib/algolia/models/recommend/rendering_content.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/rule_metadata.rb b/lib/algolia/models/recommend/rule_metadata.rb index 6b4da8ce..31d264fc 100644 --- a/lib/algolia/models/recommend/rule_metadata.rb +++ b/lib/algolia/models/recommend/rule_metadata.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/search_recommend_rules_params.rb b/lib/algolia/models/recommend/search_recommend_rules_params.rb index efc9ca6f..70c7e9d4 100644 --- a/lib/algolia/models/recommend/search_recommend_rules_params.rb +++ b/lib/algolia/models/recommend/search_recommend_rules_params.rb @@ -45,11 +45,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/search_recommend_rules_response.rb b/lib/algolia/models/recommend/search_recommend_rules_response.rb index 626d4581..144af37e 100644 --- a/lib/algolia/models/recommend/search_recommend_rules_response.rb +++ b/lib/algolia/models/recommend/search_recommend_rules_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/snippet_result.rb b/lib/algolia/models/recommend/snippet_result.rb index c919a930..7c52d6ff 100644 --- a/lib/algolia/models/recommend/snippet_result.rb +++ b/lib/algolia/models/recommend/snippet_result.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/snippet_result_option.rb b/lib/algolia/models/recommend/snippet_result_option.rb index a61b4f4b..da35433e 100644 --- a/lib/algolia/models/recommend/snippet_result_option.rb +++ b/lib/algolia/models/recommend/snippet_result_option.rb @@ -20,9 +20,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :matchLevel + ] end # Attribute type mapping. diff --git a/lib/algolia/models/recommend/tag_filters.rb b/lib/algolia/models/recommend/tag_filters.rb index f6cedf62..26115bfd 100644 --- a/lib/algolia/models/recommend/tag_filters.rb +++ b/lib/algolia/models/recommend/tag_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/time_range.rb b/lib/algolia/models/recommend/time_range.rb index 459bd89f..417b31ee 100644 --- a/lib/algolia/models/recommend/time_range.rb +++ b/lib/algolia/models/recommend/time_range.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/trending_facet_hit.rb b/lib/algolia/models/recommend/trending_facet_hit.rb index a00f3577..7c6e2fab 100644 --- a/lib/algolia/models/recommend/trending_facet_hit.rb +++ b/lib/algolia/models/recommend/trending_facet_hit.rb @@ -25,9 +25,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :facetName, + :facetValue + ] end # Attribute type mapping. diff --git a/lib/algolia/models/recommend/trending_facets_query.rb b/lib/algolia/models/recommend/trending_facets_query.rb index 5fea3b33..6e1e136f 100644 --- a/lib/algolia/models/recommend/trending_facets_query.rb +++ b/lib/algolia/models/recommend/trending_facets_query.rb @@ -37,11 +37,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/trending_items_query.rb b/lib/algolia/models/recommend/trending_items_query.rb index 4095017f..85ef872f 100644 --- a/lib/algolia/models/recommend/trending_items_query.rb +++ b/lib/algolia/models/recommend/trending_items_query.rb @@ -41,11 +41,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/typo_tolerance.rb b/lib/algolia/models/recommend/typo_tolerance.rb index 3ba6c4b0..4c31cba2 100644 --- a/lib/algolia/models/recommend/typo_tolerance.rb +++ b/lib/algolia/models/recommend/typo_tolerance.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/recommend/value.rb b/lib/algolia/models/recommend/value.rb index 330ba490..998250c0 100644 --- a/lib/algolia/models/recommend/value.rb +++ b/lib/algolia/models/recommend/value.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/recommend/widgets.rb b/lib/algolia/models/recommend/widgets.rb index 196aa074..61ee6324 100644 --- a/lib/algolia/models/recommend/widgets.rb +++ b/lib/algolia/models/recommend/widgets.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/add_api_key_response.rb b/lib/algolia/models/search/add_api_key_response.rb index 98b69695..065dd5a0 100644 --- a/lib/algolia/models/search/add_api_key_response.rb +++ b/lib/algolia/models/search/add_api_key_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/api_key.rb b/lib/algolia/models/search/api_key.rb index 94c25b06..0ed43132 100644 --- a/lib/algolia/models/search/api_key.rb +++ b/lib/algolia/models/search/api_key.rb @@ -45,11 +45,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/around_precision.rb b/lib/algolia/models/search/around_precision.rb index a4c1b466..170a900b 100644 --- a/lib/algolia/models/search/around_precision.rb +++ b/lib/algolia/models/search/around_precision.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/around_radius.rb b/lib/algolia/models/search/around_radius.rb index 28ff2000..2230ef47 100644 --- a/lib/algolia/models/search/around_radius.rb +++ b/lib/algolia/models/search/around_radius.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/assign_user_id_params.rb b/lib/algolia/models/search/assign_user_id_params.rb index 65863dd3..118e6d4d 100644 --- a/lib/algolia/models/search/assign_user_id_params.rb +++ b/lib/algolia/models/search/assign_user_id_params.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/attribute_to_update.rb b/lib/algolia/models/search/attribute_to_update.rb index 9906909c..a5a88666 100644 --- a/lib/algolia/models/search/attribute_to_update.rb +++ b/lib/algolia/models/search/attribute_to_update.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/automatic_facet_filter.rb b/lib/algolia/models/search/automatic_facet_filter.rb index 45085658..71044fb2 100644 --- a/lib/algolia/models/search/automatic_facet_filter.rb +++ b/lib/algolia/models/search/automatic_facet_filter.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/automatic_facet_filters.rb b/lib/algolia/models/search/automatic_facet_filters.rb index d22f41be..2692c5d9 100644 --- a/lib/algolia/models/search/automatic_facet_filters.rb +++ b/lib/algolia/models/search/automatic_facet_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/banner.rb b/lib/algolia/models/search/banner.rb index 530ecccd..7b517b3b 100644 --- a/lib/algolia/models/search/banner.rb +++ b/lib/algolia/models/search/banner.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/banner_image.rb b/lib/algolia/models/search/banner_image.rb index e27ea947..d1c5f4fa 100644 --- a/lib/algolia/models/search/banner_image.rb +++ b/lib/algolia/models/search/banner_image.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/banner_image_url.rb b/lib/algolia/models/search/banner_image_url.rb index 61ade9af..64474ce2 100644 --- a/lib/algolia/models/search/banner_image_url.rb +++ b/lib/algolia/models/search/banner_image_url.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/banner_link.rb b/lib/algolia/models/search/banner_link.rb index ae17a095..38c93a51 100644 --- a/lib/algolia/models/search/banner_link.rb +++ b/lib/algolia/models/search/banner_link.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_assign_user_ids_params.rb b/lib/algolia/models/search/batch_assign_user_ids_params.rb index 47fd19f8..9eee0089 100644 --- a/lib/algolia/models/search/batch_assign_user_ids_params.rb +++ b/lib/algolia/models/search/batch_assign_user_ids_params.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_dictionary_entries_params.rb b/lib/algolia/models/search/batch_dictionary_entries_params.rb index 02a6df82..ae28a7e2 100644 --- a/lib/algolia/models/search/batch_dictionary_entries_params.rb +++ b/lib/algolia/models/search/batch_dictionary_entries_params.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_dictionary_entries_request.rb b/lib/algolia/models/search/batch_dictionary_entries_request.rb index 15a2d178..f8f3afce 100644 --- a/lib/algolia/models/search/batch_dictionary_entries_request.rb +++ b/lib/algolia/models/search/batch_dictionary_entries_request.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_params.rb b/lib/algolia/models/search/batch_params.rb index 774def4d..76846828 100644 --- a/lib/algolia/models/search/batch_params.rb +++ b/lib/algolia/models/search/batch_params.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_request.rb b/lib/algolia/models/search/batch_request.rb index 48871b3f..ac2c791b 100644 --- a/lib/algolia/models/search/batch_request.rb +++ b/lib/algolia/models/search/batch_request.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_response.rb b/lib/algolia/models/search/batch_response.rb index ca6e9519..c8247d9f 100644 --- a/lib/algolia/models/search/batch_response.rb +++ b/lib/algolia/models/search/batch_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/batch_write_params.rb b/lib/algolia/models/search/batch_write_params.rb index ea144260..8eb8e8a1 100644 --- a/lib/algolia/models/search/batch_write_params.rb +++ b/lib/algolia/models/search/batch_write_params.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/browse_params.rb b/lib/algolia/models/search/browse_params.rb index e7bdb6de..bedc140a 100644 --- a/lib/algolia/models/search/browse_params.rb +++ b/lib/algolia/models/search/browse_params.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/browse_params_object.rb b/lib/algolia/models/search/browse_params_object.rb index 67dab56a..62bee75d 100644 --- a/lib/algolia/models/search/browse_params_object.rb +++ b/lib/algolia/models/search/browse_params_object.rb @@ -297,11 +297,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/browse_response.rb b/lib/algolia/models/search/browse_response.rb index d430e1f9..8ebf8553 100644 --- a/lib/algolia/models/search/browse_response.rb +++ b/lib/algolia/models/search/browse_response.rb @@ -145,11 +145,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/built_in_operation.rb b/lib/algolia/models/search/built_in_operation.rb index 2be90ee0..82b00d07 100644 --- a/lib/algolia/models/search/built_in_operation.rb +++ b/lib/algolia/models/search/built_in_operation.rb @@ -19,11 +19,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/built_in_operation_value.rb b/lib/algolia/models/search/built_in_operation_value.rb index 5d258c9d..49fe8e0d 100644 --- a/lib/algolia/models/search/built_in_operation_value.rb +++ b/lib/algolia/models/search/built_in_operation_value.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/condition.rb b/lib/algolia/models/search/condition.rb index 301786e6..1996f360 100644 --- a/lib/algolia/models/search/condition.rb +++ b/lib/algolia/models/search/condition.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/consequence.rb b/lib/algolia/models/search/consequence.rb index 394723ba..ecc671c7 100644 --- a/lib/algolia/models/search/consequence.rb +++ b/lib/algolia/models/search/consequence.rb @@ -32,11 +32,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/consequence_hide.rb b/lib/algolia/models/search/consequence_hide.rb index ba7c43d3..0a056236 100644 --- a/lib/algolia/models/search/consequence_hide.rb +++ b/lib/algolia/models/search/consequence_hide.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/consequence_params.rb b/lib/algolia/models/search/consequence_params.rb index e73916aa..e7428906 100644 --- a/lib/algolia/models/search/consequence_params.rb +++ b/lib/algolia/models/search/consequence_params.rb @@ -298,11 +298,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/consequence_query.rb b/lib/algolia/models/search/consequence_query.rb index e8c0a39f..fa1ea05b 100644 --- a/lib/algolia/models/search/consequence_query.rb +++ b/lib/algolia/models/search/consequence_query.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/consequence_query_object.rb b/lib/algolia/models/search/consequence_query_object.rb index 1d9dd641..492a254e 100644 --- a/lib/algolia/models/search/consequence_query_object.rb +++ b/lib/algolia/models/search/consequence_query_object.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/created_at_response.rb b/lib/algolia/models/search/created_at_response.rb index cd0036af..287d4745 100644 --- a/lib/algolia/models/search/created_at_response.rb +++ b/lib/algolia/models/search/created_at_response.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/delete_api_key_response.rb b/lib/algolia/models/search/delete_api_key_response.rb index 2540bb8e..10428cc3 100644 --- a/lib/algolia/models/search/delete_api_key_response.rb +++ b/lib/algolia/models/search/delete_api_key_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/delete_by_params.rb b/lib/algolia/models/search/delete_by_params.rb index 9aa30cde..336f2e87 100644 --- a/lib/algolia/models/search/delete_by_params.rb +++ b/lib/algolia/models/search/delete_by_params.rb @@ -39,11 +39,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/delete_source_response.rb b/lib/algolia/models/search/delete_source_response.rb index 103f7320..94927ac8 100644 --- a/lib/algolia/models/search/delete_source_response.rb +++ b/lib/algolia/models/search/delete_source_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/deleted_at_response.rb b/lib/algolia/models/search/deleted_at_response.rb index 5bafc93a..1a221e2d 100644 --- a/lib/algolia/models/search/deleted_at_response.rb +++ b/lib/algolia/models/search/deleted_at_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/dictionary_entry.rb b/lib/algolia/models/search/dictionary_entry.rb index 930db843..ec9d72e2 100644 --- a/lib/algolia/models/search/dictionary_entry.rb +++ b/lib/algolia/models/search/dictionary_entry.rb @@ -40,11 +40,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/dictionary_language.rb b/lib/algolia/models/search/dictionary_language.rb index aeabe568..ffb15080 100644 --- a/lib/algolia/models/search/dictionary_language.rb +++ b/lib/algolia/models/search/dictionary_language.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/dictionary_settings_params.rb b/lib/algolia/models/search/dictionary_settings_params.rb index 8d918cb9..bf5e5a30 100644 --- a/lib/algolia/models/search/dictionary_settings_params.rb +++ b/lib/algolia/models/search/dictionary_settings_params.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/distinct.rb b/lib/algolia/models/search/distinct.rb index 34ac43b0..49119a3a 100644 --- a/lib/algolia/models/search/distinct.rb +++ b/lib/algolia/models/search/distinct.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/edit.rb b/lib/algolia/models/search/edit.rb index 3be42842..7b9ff377 100644 --- a/lib/algolia/models/search/edit.rb +++ b/lib/algolia/models/search/edit.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/error_base.rb b/lib/algolia/models/search/error_base.rb index 12eedd34..053e464c 100644 --- a/lib/algolia/models/search/error_base.rb +++ b/lib/algolia/models/search/error_base.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/exhaustive.rb b/lib/algolia/models/search/exhaustive.rb index ddaa318d..ef2d8e3b 100644 --- a/lib/algolia/models/search/exhaustive.rb +++ b/lib/algolia/models/search/exhaustive.rb @@ -33,11 +33,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/facet_filters.rb b/lib/algolia/models/search/facet_filters.rb index 8421fe3e..52356d00 100644 --- a/lib/algolia/models/search/facet_filters.rb +++ b/lib/algolia/models/search/facet_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/facet_hits.rb b/lib/algolia/models/search/facet_hits.rb index 4a0cc830..527bafe4 100644 --- a/lib/algolia/models/search/facet_hits.rb +++ b/lib/algolia/models/search/facet_hits.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/facet_ordering.rb b/lib/algolia/models/search/facet_ordering.rb index 22b29bac..9222b5a4 100644 --- a/lib/algolia/models/search/facet_ordering.rb +++ b/lib/algolia/models/search/facet_ordering.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/facet_stats.rb b/lib/algolia/models/search/facet_stats.rb index 492bed9f..1c584736 100644 --- a/lib/algolia/models/search/facet_stats.rb +++ b/lib/algolia/models/search/facet_stats.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/facets.rb b/lib/algolia/models/search/facets.rb index 0ac21a68..b367e296 100644 --- a/lib/algolia/models/search/facets.rb +++ b/lib/algolia/models/search/facets.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/fetched_index.rb b/lib/algolia/models/search/fetched_index.rb index 1a3c474b..68ef0410 100644 --- a/lib/algolia/models/search/fetched_index.rb +++ b/lib/algolia/models/search/fetched_index.rb @@ -60,11 +60,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_api_key_response.rb b/lib/algolia/models/search/get_api_key_response.rb index 9c9e9151..d23b74f6 100644 --- a/lib/algolia/models/search/get_api_key_response.rb +++ b/lib/algolia/models/search/get_api_key_response.rb @@ -52,11 +52,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_dictionary_settings_response.rb b/lib/algolia/models/search/get_dictionary_settings_response.rb index 3b6f67c8..0df44604 100644 --- a/lib/algolia/models/search/get_dictionary_settings_response.rb +++ b/lib/algolia/models/search/get_dictionary_settings_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_logs_response.rb b/lib/algolia/models/search/get_logs_response.rb index 6929b689..0cde19ba 100644 --- a/lib/algolia/models/search/get_logs_response.rb +++ b/lib/algolia/models/search/get_logs_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_objects_params.rb b/lib/algolia/models/search/get_objects_params.rb index a1aebcf1..debb8efc 100644 --- a/lib/algolia/models/search/get_objects_params.rb +++ b/lib/algolia/models/search/get_objects_params.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_objects_request.rb b/lib/algolia/models/search/get_objects_request.rb index 3c2c3cc6..3f59ff2e 100644 --- a/lib/algolia/models/search/get_objects_request.rb +++ b/lib/algolia/models/search/get_objects_request.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_objects_response.rb b/lib/algolia/models/search/get_objects_response.rb index c0582fb3..d2eb308f 100644 --- a/lib/algolia/models/search/get_objects_response.rb +++ b/lib/algolia/models/search/get_objects_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_task_response.rb b/lib/algolia/models/search/get_task_response.rb index e52acd7e..f8b84382 100644 --- a/lib/algolia/models/search/get_task_response.rb +++ b/lib/algolia/models/search/get_task_response.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/get_top_user_ids_response.rb b/lib/algolia/models/search/get_top_user_ids_response.rb index e612e220..7607b472 100644 --- a/lib/algolia/models/search/get_top_user_ids_response.rb +++ b/lib/algolia/models/search/get_top_user_ids_response.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/has_pending_mappings_response.rb b/lib/algolia/models/search/has_pending_mappings_response.rb index 33009cb1..3338c7f8 100644 --- a/lib/algolia/models/search/has_pending_mappings_response.rb +++ b/lib/algolia/models/search/has_pending_mappings_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/highlight_result.rb b/lib/algolia/models/search/highlight_result.rb index 5586c73b..72d661a1 100644 --- a/lib/algolia/models/search/highlight_result.rb +++ b/lib/algolia/models/search/highlight_result.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/highlight_result_option.rb b/lib/algolia/models/search/highlight_result_option.rb index c72ce281..936993bf 100644 --- a/lib/algolia/models/search/highlight_result_option.rb +++ b/lib/algolia/models/search/highlight_result_option.rb @@ -28,9 +28,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :matchLevel, + :matchedWords + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/hit.rb b/lib/algolia/models/search/hit.rb index 3b587d70..34d4be12 100644 --- a/lib/algolia/models/search/hit.rb +++ b/lib/algolia/models/search/hit.rb @@ -33,11 +33,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/ignore_plurals.rb b/lib/algolia/models/search/ignore_plurals.rb index 2c3afc31..42b13104 100644 --- a/lib/algolia/models/search/ignore_plurals.rb +++ b/lib/algolia/models/search/ignore_plurals.rb @@ -46,7 +46,6 @@ def build(data) 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? @@ -85,12 +84,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/index_settings.rb b/lib/algolia/models/search/index_settings.rb index 58e91629..7ee89a03 100644 --- a/lib/algolia/models/search/index_settings.rb +++ b/lib/algolia/models/search/index_settings.rb @@ -245,11 +245,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/inside_bounding_box.rb b/lib/algolia/models/search/inside_bounding_box.rb index 87b7b52c..5aee4d89 100644 --- a/lib/algolia/models/search/inside_bounding_box.rb +++ b/lib/algolia/models/search/inside_bounding_box.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/languages.rb b/lib/algolia/models/search/languages.rb index 8191b19c..56759c38 100644 --- a/lib/algolia/models/search/languages.rb +++ b/lib/algolia/models/search/languages.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/list_api_keys_response.rb b/lib/algolia/models/search/list_api_keys_response.rb index e7a8e3bd..454ab23a 100644 --- a/lib/algolia/models/search/list_api_keys_response.rb +++ b/lib/algolia/models/search/list_api_keys_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/list_clusters_response.rb b/lib/algolia/models/search/list_clusters_response.rb index e08ffc8a..49c98465 100644 --- a/lib/algolia/models/search/list_clusters_response.rb +++ b/lib/algolia/models/search/list_clusters_response.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/list_indices_response.rb b/lib/algolia/models/search/list_indices_response.rb index f2aaaa28..e823c32b 100644 --- a/lib/algolia/models/search/list_indices_response.rb +++ b/lib/algolia/models/search/list_indices_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/list_user_ids_response.rb b/lib/algolia/models/search/list_user_ids_response.rb index fce13ba0..47295c24 100644 --- a/lib/algolia/models/search/list_user_ids_response.rb +++ b/lib/algolia/models/search/list_user_ids_response.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/log.rb b/lib/algolia/models/search/log.rb index e07b1f69..e1107518 100644 --- a/lib/algolia/models/search/log.rb +++ b/lib/algolia/models/search/log.rb @@ -72,11 +72,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/log_query.rb b/lib/algolia/models/search/log_query.rb index 8f90da92..076d3701 100644 --- a/lib/algolia/models/search/log_query.rb +++ b/lib/algolia/models/search/log_query.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/matched_geo_location.rb b/lib/algolia/models/search/matched_geo_location.rb index c5c48cb0..7520b993 100644 --- a/lib/algolia/models/search/matched_geo_location.rb +++ b/lib/algolia/models/search/matched_geo_location.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/multiple_batch_request.rb b/lib/algolia/models/search/multiple_batch_request.rb index 1b613f27..b5be1e54 100644 --- a/lib/algolia/models/search/multiple_batch_request.rb +++ b/lib/algolia/models/search/multiple_batch_request.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/multiple_batch_response.rb b/lib/algolia/models/search/multiple_batch_response.rb index b0c1e4f6..3806f8c8 100644 --- a/lib/algolia/models/search/multiple_batch_response.rb +++ b/lib/algolia/models/search/multiple_batch_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/numeric_filters.rb b/lib/algolia/models/search/numeric_filters.rb index a8f00c93..03209ad4 100644 --- a/lib/algolia/models/search/numeric_filters.rb +++ b/lib/algolia/models/search/numeric_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/operation_index_params.rb b/lib/algolia/models/search/operation_index_params.rb index a10d37df..b696fe31 100644 --- a/lib/algolia/models/search/operation_index_params.rb +++ b/lib/algolia/models/search/operation_index_params.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/optional_filters.rb b/lib/algolia/models/search/optional_filters.rb index be58522f..9865c5b8 100644 --- a/lib/algolia/models/search/optional_filters.rb +++ b/lib/algolia/models/search/optional_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/optional_words.rb b/lib/algolia/models/search/optional_words.rb index 900b19a9..36fa5b91 100644 --- a/lib/algolia/models/search/optional_words.rb +++ b/lib/algolia/models/search/optional_words.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/personalization.rb b/lib/algolia/models/search/personalization.rb index f65d2fd9..d8458ab4 100644 --- a/lib/algolia/models/search/personalization.rb +++ b/lib/algolia/models/search/personalization.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/promote.rb b/lib/algolia/models/search/promote.rb index 4f5ac734..fa431f58 100644 --- a/lib/algolia/models/search/promote.rb +++ b/lib/algolia/models/search/promote.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/promote_object_id.rb b/lib/algolia/models/search/promote_object_id.rb index 120b4701..41768aca 100644 --- a/lib/algolia/models/search/promote_object_id.rb +++ b/lib/algolia/models/search/promote_object_id.rb @@ -21,9 +21,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :objectID + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/promote_object_ids.rb b/lib/algolia/models/search/promote_object_ids.rb index cf72ca5c..3c7cba78 100644 --- a/lib/algolia/models/search/promote_object_ids.rb +++ b/lib/algolia/models/search/promote_object_ids.rb @@ -21,9 +21,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :objectIDs + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/range.rb b/lib/algolia/models/search/range.rb index 69f1e126..ff8b7eda 100644 --- a/lib/algolia/models/search/range.rb +++ b/lib/algolia/models/search/range.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/ranking_info.rb b/lib/algolia/models/search/ranking_info.rb index 1c057a8f..6d97c621 100644 --- a/lib/algolia/models/search/ranking_info.rb +++ b/lib/algolia/models/search/ranking_info.rb @@ -63,11 +63,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/re_ranking_apply_filter.rb b/lib/algolia/models/search/re_ranking_apply_filter.rb index dbe1700d..c0e4a28c 100644 --- a/lib/algolia/models/search/re_ranking_apply_filter.rb +++ b/lib/algolia/models/search/re_ranking_apply_filter.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/redirect.rb b/lib/algolia/models/search/redirect.rb index d485a63a..f219168a 100644 --- a/lib/algolia/models/search/redirect.rb +++ b/lib/algolia/models/search/redirect.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/redirect_rule_index_data.rb b/lib/algolia/models/search/redirect_rule_index_data.rb index c71dfe14..2b9884b4 100644 --- a/lib/algolia/models/search/redirect_rule_index_data.rb +++ b/lib/algolia/models/search/redirect_rule_index_data.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/redirect_rule_index_metadata.rb b/lib/algolia/models/search/redirect_rule_index_metadata.rb index 4131504f..3ab501f8 100644 --- a/lib/algolia/models/search/redirect_rule_index_metadata.rb +++ b/lib/algolia/models/search/redirect_rule_index_metadata.rb @@ -31,11 +31,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/redirect_url.rb b/lib/algolia/models/search/redirect_url.rb index 64fddc29..7e03166d 100644 --- a/lib/algolia/models/search/redirect_url.rb +++ b/lib/algolia/models/search/redirect_url.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/remove_stop_words.rb b/lib/algolia/models/search/remove_stop_words.rb index e28a9f6f..5846c40a 100644 --- a/lib/algolia/models/search/remove_stop_words.rb +++ b/lib/algolia/models/search/remove_stop_words.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/remove_user_id_response.rb b/lib/algolia/models/search/remove_user_id_response.rb index 9db4d9ef..9db9e03d 100644 --- a/lib/algolia/models/search/remove_user_id_response.rb +++ b/lib/algolia/models/search/remove_user_id_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/rendering_content.rb b/lib/algolia/models/search/rendering_content.rb index 52a3a871..7a67d49f 100644 --- a/lib/algolia/models/search/rendering_content.rb +++ b/lib/algolia/models/search/rendering_content.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/replace_all_objects_response.rb b/lib/algolia/models/search/replace_all_objects_response.rb index 466e24ca..2be94a93 100644 --- a/lib/algolia/models/search/replace_all_objects_response.rb +++ b/lib/algolia/models/search/replace_all_objects_response.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/replace_source_response.rb b/lib/algolia/models/search/replace_source_response.rb index 79684539..ec9bc4fa 100644 --- a/lib/algolia/models/search/replace_source_response.rb +++ b/lib/algolia/models/search/replace_source_response.rb @@ -16,11 +16,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/rule.rb b/lib/algolia/models/search/rule.rb index eddf6eb6..a5ac0580 100644 --- a/lib/algolia/models/search/rule.rb +++ b/lib/algolia/models/search/rule.rb @@ -36,11 +36,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/save_object_response.rb b/lib/algolia/models/search/save_object_response.rb index 85b266b9..23587b0c 100644 --- a/lib/algolia/models/search/save_object_response.rb +++ b/lib/algolia/models/search/save_object_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/save_synonym_response.rb b/lib/algolia/models/search/save_synonym_response.rb index 5eceaf85..c1537cda 100644 --- a/lib/algolia/models/search/save_synonym_response.rb +++ b/lib/algolia/models/search/save_synonym_response.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_dictionary_entries_params.rb b/lib/algolia/models/search/search_dictionary_entries_params.rb index 98e3405a..0469ddc0 100644 --- a/lib/algolia/models/search/search_dictionary_entries_params.rb +++ b/lib/algolia/models/search/search_dictionary_entries_params.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_dictionary_entries_response.rb b/lib/algolia/models/search/search_dictionary_entries_response.rb index 1ec56151..fa42e7d0 100644 --- a/lib/algolia/models/search/search_dictionary_entries_response.rb +++ b/lib/algolia/models/search/search_dictionary_entries_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_for_facet_values_request.rb b/lib/algolia/models/search/search_for_facet_values_request.rb index e3b126a6..5215e5ad 100644 --- a/lib/algolia/models/search/search_for_facet_values_request.rb +++ b/lib/algolia/models/search/search_for_facet_values_request.rb @@ -24,11 +24,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_for_facet_values_response.rb b/lib/algolia/models/search/search_for_facet_values_response.rb index b51f7a31..7be2b3b4 100644 --- a/lib/algolia/models/search/search_for_facet_values_response.rb +++ b/lib/algolia/models/search/search_for_facet_values_response.rb @@ -24,9 +24,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :facetHits + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/search_for_facets.rb b/lib/algolia/models/search/search_for_facets.rb index 800c015c..645f5410 100644 --- a/lib/algolia/models/search/search_for_facets.rb +++ b/lib/algolia/models/search/search_for_facets.rb @@ -316,9 +316,12 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :facet, + :type + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/search_for_hits.rb b/lib/algolia/models/search/search_for_hits.rb index 2a4b5081..06b5a50f 100644 --- a/lib/algolia/models/search/search_for_hits.rb +++ b/lib/algolia/models/search/search_for_hits.rb @@ -304,11 +304,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_method_params.rb b/lib/algolia/models/search/search_method_params.rb index 760786d8..46cbbb45 100644 --- a/lib/algolia/models/search/search_method_params.rb +++ b/lib/algolia/models/search/search_method_params.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_params.rb b/lib/algolia/models/search/search_params.rb index f5460d88..d05956d9 100644 --- a/lib/algolia/models/search/search_params.rb +++ b/lib/algolia/models/search/search_params.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/search_params_object.rb b/lib/algolia/models/search/search_params_object.rb index 6dcce24d..90651df9 100644 --- a/lib/algolia/models/search/search_params_object.rb +++ b/lib/algolia/models/search/search_params_object.rb @@ -294,11 +294,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_params_string.rb b/lib/algolia/models/search/search_params_string.rb index 84054331..37eed5c9 100644 --- a/lib/algolia/models/search/search_params_string.rb +++ b/lib/algolia/models/search/search_params_string.rb @@ -17,9 +17,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :params + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/search_query.rb b/lib/algolia/models/search/search_query.rb index 2fa530f7..0a0ff277 100644 --- a/lib/algolia/models/search/search_query.rb +++ b/lib/algolia/models/search/search_query.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/search_response.rb b/lib/algolia/models/search/search_response.rb index 818e1c30..49df428c 100644 --- a/lib/algolia/models/search/search_response.rb +++ b/lib/algolia/models/search/search_response.rb @@ -143,11 +143,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_responses.rb b/lib/algolia/models/search/search_responses.rb index b67f322d..fc1cde74 100644 --- a/lib/algolia/models/search/search_responses.rb +++ b/lib/algolia/models/search/search_responses.rb @@ -15,11 +15,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_result.rb b/lib/algolia/models/search/search_result.rb index 58a7734c..2e039555 100644 --- a/lib/algolia/models/search/search_result.rb +++ b/lib/algolia/models/search/search_result.rb @@ -44,7 +44,6 @@ def build(data) 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? @@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/search_rules_params.rb b/lib/algolia/models/search/search_rules_params.rb index 251d67c9..ee16795c 100644 --- a/lib/algolia/models/search/search_rules_params.rb +++ b/lib/algolia/models/search/search_rules_params.rb @@ -36,11 +36,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_rules_response.rb b/lib/algolia/models/search/search_rules_response.rb index 13fd7227..10df852e 100644 --- a/lib/algolia/models/search/search_rules_response.rb +++ b/lib/algolia/models/search/search_rules_response.rb @@ -28,11 +28,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_synonyms_params.rb b/lib/algolia/models/search/search_synonyms_params.rb index e5e1f65e..24334ca5 100644 --- a/lib/algolia/models/search/search_synonyms_params.rb +++ b/lib/algolia/models/search/search_synonyms_params.rb @@ -27,11 +27,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_synonyms_response.rb b/lib/algolia/models/search/search_synonyms_response.rb index dbe0de76..08eb92e0 100644 --- a/lib/algolia/models/search/search_synonyms_response.rb +++ b/lib/algolia/models/search/search_synonyms_response.rb @@ -22,11 +22,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_user_ids_params.rb b/lib/algolia/models/search/search_user_ids_params.rb index eaa0aec8..d62ace13 100644 --- a/lib/algolia/models/search/search_user_ids_params.rb +++ b/lib/algolia/models/search/search_user_ids_params.rb @@ -29,11 +29,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/search_user_ids_response.rb b/lib/algolia/models/search/search_user_ids_response.rb index 1f7fc8f9..c7d0f8b9 100644 --- a/lib/algolia/models/search/search_user_ids_response.rb +++ b/lib/algolia/models/search/search_user_ids_response.rb @@ -33,11 +33,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/secured_api_key_restrictions.rb b/lib/algolia/models/search/secured_api_key_restrictions.rb index 433fc34e..89cdcf44 100644 --- a/lib/algolia/models/search/secured_api_key_restrictions.rb +++ b/lib/algolia/models/search/secured_api_key_restrictions.rb @@ -35,11 +35,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/semantic_search.rb b/lib/algolia/models/search/semantic_search.rb index 9dd3d355..e2790c3a 100644 --- a/lib/algolia/models/search/semantic_search.rb +++ b/lib/algolia/models/search/semantic_search.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/settings_response.rb b/lib/algolia/models/search/settings_response.rb index de735c5c..f0514e5a 100644 --- a/lib/algolia/models/search/settings_response.rb +++ b/lib/algolia/models/search/settings_response.rb @@ -248,11 +248,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/snippet_result.rb b/lib/algolia/models/search/snippet_result.rb index b47f5138..39c83ebb 100644 --- a/lib/algolia/models/search/snippet_result.rb +++ b/lib/algolia/models/search/snippet_result.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/snippet_result_option.rb b/lib/algolia/models/search/snippet_result_option.rb index e47327a7..32daf84a 100644 --- a/lib/algolia/models/search/snippet_result_option.rb +++ b/lib/algolia/models/search/snippet_result_option.rb @@ -20,9 +20,11 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values + # Returns the keys that uniquely identify this oneOf variant when present + def self.discriminator_attributes + [ + :matchLevel + ] end # Attribute type mapping. diff --git a/lib/algolia/models/search/source.rb b/lib/algolia/models/search/source.rb index 22e8822c..3ce64d14 100644 --- a/lib/algolia/models/search/source.rb +++ b/lib/algolia/models/search/source.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/standard_entries.rb b/lib/algolia/models/search/standard_entries.rb index fdd71aec..c91d49ad 100644 --- a/lib/algolia/models/search/standard_entries.rb +++ b/lib/algolia/models/search/standard_entries.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/synonym_hit.rb b/lib/algolia/models/search/synonym_hit.rb index d035335f..3c95ec98 100644 --- a/lib/algolia/models/search/synonym_hit.rb +++ b/lib/algolia/models/search/synonym_hit.rb @@ -44,11 +44,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/tag_filters.rb b/lib/algolia/models/search/tag_filters.rb index a97f8b79..5e58855d 100644 --- a/lib/algolia/models/search/tag_filters.rb +++ b/lib/algolia/models/search/tag_filters.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/time_range.rb b/lib/algolia/models/search/time_range.rb index 3f935a56..60a02f15 100644 --- a/lib/algolia/models/search/time_range.rb +++ b/lib/algolia/models/search/time_range.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/typo_tolerance.rb b/lib/algolia/models/search/typo_tolerance.rb index 7d80f400..11ab8d3e 100644 --- a/lib/algolia/models/search/typo_tolerance.rb +++ b/lib/algolia/models/search/typo_tolerance.rb @@ -45,7 +45,6 @@ def build(data) 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? @@ -84,12 +83,12 @@ def find_and_cast_into_type(klass, data) 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 diff --git a/lib/algolia/models/search/update_api_key_response.rb b/lib/algolia/models/search/update_api_key_response.rb index 70db8115..f1a823bb 100644 --- a/lib/algolia/models/search/update_api_key_response.rb +++ b/lib/algolia/models/search/update_api_key_response.rb @@ -20,11 +20,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/updated_at_response.rb b/lib/algolia/models/search/updated_at_response.rb index f9be8d72..ee20ed72 100644 --- a/lib/algolia/models/search/updated_at_response.rb +++ b/lib/algolia/models/search/updated_at_response.rb @@ -21,11 +21,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/updated_at_with_object_id_response.rb b/lib/algolia/models/search/updated_at_with_object_id_response.rb index 3dd6e029..819f092e 100644 --- a/lib/algolia/models/search/updated_at_with_object_id_response.rb +++ b/lib/algolia/models/search/updated_at_with_object_id_response.rb @@ -25,11 +25,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/user_highlight_result.rb b/lib/algolia/models/search/user_highlight_result.rb index c48981d8..e3a6e221 100644 --- a/lib/algolia/models/search/user_highlight_result.rb +++ b/lib/algolia/models/search/user_highlight_result.rb @@ -18,11 +18,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/user_hit.rb b/lib/algolia/models/search/user_hit.rb index 5cefa8ae..f035f4d8 100644 --- a/lib/algolia/models/search/user_hit.rb +++ b/lib/algolia/models/search/user_hit.rb @@ -35,11 +35,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/user_id.rb b/lib/algolia/models/search/user_id.rb index 5e433701..46fb89a6 100644 --- a/lib/algolia/models/search/user_id.rb +++ b/lib/algolia/models/search/user_id.rb @@ -29,11 +29,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/value.rb b/lib/algolia/models/search/value.rb index 6a686506..1f808601 100644 --- a/lib/algolia/models/search/value.rb +++ b/lib/algolia/models/search/value.rb @@ -23,11 +23,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping { diff --git a/lib/algolia/models/search/widgets.rb b/lib/algolia/models/search/widgets.rb index 3ea4e104..37124bc5 100644 --- a/lib/algolia/models/search/widgets.rb +++ b/lib/algolia/models/search/widgets.rb @@ -17,11 +17,6 @@ def self.attribute_map } end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. def self.types_mapping {