From 98be1f6a38c39c894ed61f89d1247d4eb77636fc Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Fri, 30 Aug 2024 13:55:05 +0000 Subject: [PATCH] fix(specs): ignorePlurals can be a boolean string (generated) https://github.com/algolia/api-clients-automation/pull/3620 Co-authored-by: algolia-bot Co-authored-by: Pierre Millot --- lib/algolia/api_client.rb | 2 +- lib/algolia/models/abtesting/ab_test.rb | 22 ------------- .../models/abtesting/add_ab_tests_variant.rb | 7 ++-- .../abtesting/minimum_detectable_effect.rb | 22 ------------- .../analytics/get_top_filter_for_attribute.rb | 22 ------------- .../get_top_filters_no_results_value.rb | 22 ------------- .../models/analytics/get_top_hits_response.rb | 7 ++-- .../analytics/get_top_searches_response.rb | 7 ++-- lib/algolia/models/ingestion/auth_input.rb | 7 ++-- .../models/ingestion/auth_input_partial.rb | 7 ++-- .../models/ingestion/authentication.rb | 22 ------------- .../models/ingestion/authentication_create.rb | 22 ------------- .../models/ingestion/authentication_update.rb | 22 ------------- lib/algolia/models/ingestion/destination.rb | 22 ------------- .../models/ingestion/destination_create.rb | 22 ------------- .../ingestion/destination_index_name.rb | 22 ------------- .../models/ingestion/destination_input.rb | 7 ++-- .../models/ingestion/destination_update.rb | 22 ------------- .../models/ingestion/docker_streams.rb | 22 ------------- lib/algolia/models/ingestion/event.rb | 22 ------------- lib/algolia/models/ingestion/mapping_input.rb | 22 ------------- .../models/ingestion/on_demand_trigger.rb | 22 ------------- .../ingestion/on_demand_trigger_input.rb | 22 ------------- .../models/ingestion/platform_with_none.rb | 7 ++-- .../models/ingestion/push_task_payload.rb | 22 ------------- lib/algolia/models/ingestion/run.rb | 22 ------------- .../models/ingestion/run_source_payload.rb | 22 ------------- .../models/ingestion/schedule_trigger.rb | 22 ------------- .../ingestion/schedule_trigger_input.rb | 22 ------------- lib/algolia/models/ingestion/source.rb | 22 ------------- .../models/ingestion/source_big_query.rb | 22 ------------- lib/algolia/models/ingestion/source_create.rb | 22 ------------- lib/algolia/models/ingestion/source_csv.rb | 22 ------------- lib/algolia/models/ingestion/source_docker.rb | 22 ------------- lib/algolia/models/ingestion/source_input.rb | 7 ++-- lib/algolia/models/ingestion/source_json.rb | 22 ------------- .../models/ingestion/source_update_docker.rb | 22 ------------- .../models/ingestion/source_update_input.rb | 7 ++-- .../models/ingestion/streaming_trigger.rb | 22 ------------- .../models/ingestion/subscription_trigger.rb | 22 ------------- lib/algolia/models/ingestion/task.rb | 22 ------------- lib/algolia/models/ingestion/task_create.rb | 22 ------------- .../models/ingestion/task_create_trigger.rb | 7 ++-- .../models/ingestion/task_create_v1.rb | 22 ------------- lib/algolia/models/ingestion/task_input.rb | 7 ++-- lib/algolia/models/ingestion/task_v1.rb | 22 ------------- lib/algolia/models/ingestion/trigger.rb | 7 ++-- .../insights/added_to_cart_object_ids.rb | 22 ------------- .../added_to_cart_object_ids_after_search.rb | 22 ------------- .../models/insights/clicked_filters.rb | 22 ------------- .../models/insights/clicked_object_ids.rb | 22 ------------- .../clicked_object_ids_after_search.rb | 22 ------------- .../models/insights/converted_filters.rb | 22 ------------- .../models/insights/converted_object_ids.rb | 22 ------------- .../converted_object_ids_after_search.rb | 22 ------------- lib/algolia/models/insights/discount.rb | 7 ++-- lib/algolia/models/insights/events_items.rb | 7 ++-- lib/algolia/models/insights/price.rb | 7 ++-- .../models/insights/purchased_object_ids.rb | 22 ------------- .../purchased_object_ids_after_search.rb | 22 ------------- lib/algolia/models/insights/value.rb | 7 ++-- lib/algolia/models/insights/viewed_filters.rb | 22 ------------- .../models/insights/viewed_object_ids.rb | 22 ------------- lib/algolia/models/monitoring/incident.rb | 22 ------------- lib/algolia/models/monitoring/server.rb | 22 ------------- .../models/personalization/event_scoring.rb | 22 ------------- .../models/query-suggestions/languages.rb | 7 ++-- .../models/query-suggestions/log_file.rb | 22 ------------- .../models/recommend/around_precision.rb | 7 ++-- lib/algolia/models/recommend/around_radius.rb | 7 ++-- .../models/recommend/boolean_string.rb | 32 +++++++++++++++++++ .../models/recommend/bought_together_query.rb | 22 ------------- lib/algolia/models/recommend/distinct.rb | 7 ++-- lib/algolia/models/recommend/facet_filters.rb | 7 ++-- .../models/recommend/fallback_params.rb | 22 ------------- .../recommend/get_recommend_task_response.rb | 22 ------------- .../models/recommend/highlight_result.rb | 7 ++-- .../recommend/highlight_result_option.rb | 22 ------------- .../models/recommend/ignore_plurals.rb | 10 ++++-- .../models/recommend/looking_similar_query.rb | 22 ------------- .../models/recommend/numeric_filters.rb | 7 ++-- .../models/recommend/optional_filters.rb | 7 ++-- .../recommend/re_ranking_apply_filter.rb | 7 ++-- .../models/recommend/recommendations_hit.rb | 7 ++-- .../recommend/recommendations_request.rb | 7 ++-- .../recommend/recommended_for_you_query.rb | 22 ------------- lib/algolia/models/recommend/related_query.rb | 22 ------------- .../models/recommend/remove_stop_words.rb | 7 ++-- lib/algolia/models/recommend/search_params.rb | 22 ------------- .../models/recommend/search_params_object.rb | 22 ------------- .../models/recommend/snippet_result.rb | 7 ++-- .../models/recommend/snippet_result_option.rb | 22 ------------- lib/algolia/models/recommend/tag_filters.rb | 7 ++-- .../models/recommend/trending_facets_query.rb | 22 ------------- .../models/recommend/trending_items_query.rb | 22 ------------- .../models/recommend/typo_tolerance.rb | 7 ++-- lib/algolia/models/recommend/value.rb | 22 ------------- lib/algolia/models/search/around_precision.rb | 7 ++-- lib/algolia/models/search/around_radius.rb | 7 ++-- .../models/search/attribute_to_update.rb | 7 ++-- .../models/search/automatic_facet_filters.rb | 7 ++-- .../batch_dictionary_entries_request.rb | 22 ------------- lib/algolia/models/search/batch_request.rb | 22 ------------- lib/algolia/models/search/boolean_string.rb | 32 +++++++++++++++++++ lib/algolia/models/search/browse_params.rb | 7 ++-- .../models/search/browse_params_object.rb | 22 ------------- .../models/search/built_in_operation.rb | 22 ------------- .../models/search/built_in_operation_value.rb | 7 ++-- lib/algolia/models/search/condition.rb | 22 ------------- .../models/search/consequence_params.rb | 22 ------------- .../models/search/consequence_query.rb | 7 ++-- lib/algolia/models/search/dictionary_entry.rb | 22 ------------- lib/algolia/models/search/distinct.rb | 7 ++-- lib/algolia/models/search/edit.rb | 22 ------------- lib/algolia/models/search/facet_filters.rb | 7 ++-- .../models/search/get_task_response.rb | 22 ------------- lib/algolia/models/search/highlight_result.rb | 7 ++-- .../models/search/highlight_result_option.rb | 22 ------------- lib/algolia/models/search/ignore_plurals.rb | 10 ++++-- lib/algolia/models/search/index_settings.rb | 22 ------------- .../models/search/multiple_batch_request.rb | 22 ------------- lib/algolia/models/search/numeric_filters.rb | 7 ++-- .../models/search/operation_index_params.rb | 22 ------------- lib/algolia/models/search/optional_filters.rb | 7 ++-- lib/algolia/models/search/promote.rb | 7 ++-- .../models/search/re_ranking_apply_filter.rb | 7 ++-- .../models/search/remove_stop_words.rb | 7 ++-- .../search_dictionary_entries_params.rb | 22 ------------- .../models/search/search_for_facets.rb | 22 ------------- lib/algolia/models/search/search_for_hits.rb | 22 ------------- .../models/search/search_method_params.rb | 22 ------------- lib/algolia/models/search/search_params.rb | 7 ++-- .../models/search/search_params_object.rb | 22 ------------- lib/algolia/models/search/search_query.rb | 7 ++-- lib/algolia/models/search/search_result.rb | 7 ++-- .../models/search/search_rules_params.rb | 22 ------------- .../models/search/search_synonyms_params.rb | 22 ------------- .../models/search/settings_response.rb | 22 ------------- lib/algolia/models/search/snippet_result.rb | 7 ++-- .../models/search/snippet_result_option.rb | 22 ------------- lib/algolia/models/search/synonym_hit.rb | 22 ------------- lib/algolia/models/search/tag_filters.rb | 7 ++-- lib/algolia/models/search/typo_tolerance.rb | 7 ++-- lib/algolia/models/search/value.rb | 22 ------------- lib/algolia/models/usage/statistic_value.rb | 7 ++-- 145 files changed, 344 insertions(+), 2027 deletions(-) create mode 100644 lib/algolia/models/recommend/boolean_string.rb create mode 100644 lib/algolia/models/search/boolean_string.rb diff --git a/lib/algolia/api_client.rb b/lib/algolia/api_client.rb index 8fd2e0c8..44387622 100644 --- a/lib/algolia/api_client.rb +++ b/lib/algolia/api_client.rb @@ -93,7 +93,7 @@ def convert_to_type(data, return_type) data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } end else - # models (e.g. Pet) or oneOf + # models (e.g. Pet), enum, or oneOf klass = Algolia.const_get(return_type) klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) end diff --git a/lib/algolia/models/abtesting/ab_test.rb b/lib/algolia/models/abtesting/ab_test.rb index 23325350..75d062cb 100644 --- a/lib/algolia/models/abtesting/ab_test.rb +++ b/lib/algolia/models/abtesting/ab_test.rb @@ -38,28 +38,6 @@ class ABTest attr_accessor :configuration - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/abtesting/add_ab_tests_variant.rb b/lib/algolia/models/abtesting/add_ab_tests_variant.rb index 4d669eb1..6d2c260c 100644 --- a/lib/algolia/models/abtesting/add_ab_tests_variant.rb +++ b/lib/algolia/models/abtesting/add_ab_tests_variant.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Abtesting.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/abtesting/minimum_detectable_effect.rb b/lib/algolia/models/abtesting/minimum_detectable_effect.rb index ab74e098..f09ab723 100644 --- a/lib/algolia/models/abtesting/minimum_detectable_effect.rb +++ b/lib/algolia/models/abtesting/minimum_detectable_effect.rb @@ -12,28 +12,6 @@ class MinimumDetectableEffect attr_accessor :effect - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 df0e58ad..4af1414a 100644 --- a/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +++ b/lib/algolia/models/analytics/get_top_filter_for_attribute.rb @@ -17,28 +17,6 @@ class GetTopFilterForAttribute # Number of occurrences. attr_accessor :count - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 038d3b4b..2fc55413 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 @@ -14,28 +14,6 @@ class GetTopFiltersNoResultsValue # Attribute value. attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/analytics/get_top_hits_response.rb b/lib/algolia/models/analytics/get_top_hits_response.rb index 77931961..85f8e98d 100644 --- a/lib/algolia/models/analytics/get_top_hits_response.rb +++ b/lib/algolia/models/analytics/get_top_hits_response.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Analytics.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/analytics/get_top_searches_response.rb b/lib/algolia/models/analytics/get_top_searches_response.rb index 0c79ce02..9935c16b 100644 --- a/lib/algolia/models/analytics/get_top_searches_response.rb +++ b/lib/algolia/models/analytics/get_top_searches_response.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Analytics.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/auth_input.rb b/lib/algolia/models/ingestion/auth_input.rb index 0469c3f8..0da4dbdd 100644 --- a/lib/algolia/models/ingestion/auth_input.rb +++ b/lib/algolia/models/ingestion/auth_input.rb @@ -84,13 +84,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/auth_input_partial.rb b/lib/algolia/models/ingestion/auth_input_partial.rb index d0a1abcb..2d112d58 100644 --- a/lib/algolia/models/ingestion/auth_input_partial.rb +++ b/lib/algolia/models/ingestion/auth_input_partial.rb @@ -84,13 +84,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/authentication.rb b/lib/algolia/models/ingestion/authentication.rb index c20c53b6..ae4221a4 100644 --- a/lib/algolia/models/ingestion/authentication.rb +++ b/lib/algolia/models/ingestion/authentication.rb @@ -25,28 +25,6 @@ class Authentication # Date of last update in RFC 3339 format. attr_accessor :updated_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/authentication_create.rb b/lib/algolia/models/ingestion/authentication_create.rb index 18ff62f5..d65fa674 100644 --- a/lib/algolia/models/ingestion/authentication_create.rb +++ b/lib/algolia/models/ingestion/authentication_create.rb @@ -16,28 +16,6 @@ class AuthenticationCreate attr_accessor :input - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/authentication_update.rb b/lib/algolia/models/ingestion/authentication_update.rb index 13421f05..3b756215 100644 --- a/lib/algolia/models/ingestion/authentication_update.rb +++ b/lib/algolia/models/ingestion/authentication_update.rb @@ -16,28 +16,6 @@ class AuthenticationUpdate attr_accessor :input - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/destination.rb b/lib/algolia/models/ingestion/destination.rb index 5dd95b71..5d54c6f3 100644 --- a/lib/algolia/models/ingestion/destination.rb +++ b/lib/algolia/models/ingestion/destination.rb @@ -28,28 +28,6 @@ class Destination attr_accessor :transformation_ids - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/destination_create.rb b/lib/algolia/models/ingestion/destination_create.rb index 62b463aa..3820d0b5 100644 --- a/lib/algolia/models/ingestion/destination_create.rb +++ b/lib/algolia/models/ingestion/destination_create.rb @@ -19,28 +19,6 @@ class DestinationCreate attr_accessor :transformation_ids - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/destination_index_name.rb b/lib/algolia/models/ingestion/destination_index_name.rb index e1c081e7..306a5b97 100644 --- a/lib/algolia/models/ingestion/destination_index_name.rb +++ b/lib/algolia/models/ingestion/destination_index_name.rb @@ -14,28 +14,6 @@ class DestinationIndexName # Attributes from your source to exclude from Algolia records. Not all your data attributes will be useful for searching. Keeping your Algolia records small increases indexing and search performance. - Exclude nested attributes with `.` notation. For example, `foo.bar` indexes the `foo` attribute and all its children **except** the `bar` attribute. - Exclude attributes from arrays with `[i]`, where `i` is the index of the array element. For example, `foo.[0].bar` only excludes the `bar` attribute from the first element of the `foo` array, but indexes the complete `foo` attribute for all other elements. Use `*` as wildcard: `foo.[*].bar` excludes `bar` from all elements of the `foo` array. attr_accessor :attributes_to_exclude - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/destination_input.rb b/lib/algolia/models/ingestion/destination_input.rb index 294db8f7..15d9b9fc 100644 --- a/lib/algolia/models/ingestion/destination_input.rb +++ b/lib/algolia/models/ingestion/destination_input.rb @@ -79,13 +79,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/destination_update.rb b/lib/algolia/models/ingestion/destination_update.rb index 1c97f55a..7c4c22e0 100644 --- a/lib/algolia/models/ingestion/destination_update.rb +++ b/lib/algolia/models/ingestion/destination_update.rb @@ -19,28 +19,6 @@ class DestinationUpdate attr_accessor :transformation_ids - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/docker_streams.rb b/lib/algolia/models/ingestion/docker_streams.rb index bb7fe04c..ab484e08 100644 --- a/lib/algolia/models/ingestion/docker_streams.rb +++ b/lib/algolia/models/ingestion/docker_streams.rb @@ -14,28 +14,6 @@ class DockerStreams attr_accessor :sync_mode - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/event.rb b/lib/algolia/models/ingestion/event.rb index 97da27d1..d1683f1e 100644 --- a/lib/algolia/models/ingestion/event.rb +++ b/lib/algolia/models/ingestion/event.rb @@ -28,28 +28,6 @@ class Event # Date of publish RFC 3339 format. attr_accessor :published_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/mapping_input.rb b/lib/algolia/models/ingestion/mapping_input.rb index 9c44bc7d..47c8e698 100644 --- a/lib/algolia/models/ingestion/mapping_input.rb +++ b/lib/algolia/models/ingestion/mapping_input.rb @@ -11,28 +11,6 @@ class MappingInput attr_accessor :actions - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/on_demand_trigger.rb b/lib/algolia/models/ingestion/on_demand_trigger.rb index 84cfda05..3b859b32 100644 --- a/lib/algolia/models/ingestion/on_demand_trigger.rb +++ b/lib/algolia/models/ingestion/on_demand_trigger.rb @@ -12,28 +12,6 @@ class OnDemandTrigger # The last time the scheduled task ran in RFC 3339 format. attr_accessor :last_run - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/on_demand_trigger_input.rb b/lib/algolia/models/ingestion/on_demand_trigger_input.rb index dccf2a62..17c3c20c 100644 --- a/lib/algolia/models/ingestion/on_demand_trigger_input.rb +++ b/lib/algolia/models/ingestion/on_demand_trigger_input.rb @@ -9,28 +9,6 @@ module Ingestion class OnDemandTriggerInput attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/platform_with_none.rb b/lib/algolia/models/ingestion/platform_with_none.rb index 1ee2277c..09c500a5 100644 --- a/lib/algolia/models/ingestion/platform_with_none.rb +++ b/lib/algolia/models/ingestion/platform_with_none.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/push_task_payload.rb b/lib/algolia/models/ingestion/push_task_payload.rb index e90dfe72..e2770428 100644 --- a/lib/algolia/models/ingestion/push_task_payload.rb +++ b/lib/algolia/models/ingestion/push_task_payload.rb @@ -10,28 +10,6 @@ class PushTaskPayload attr_accessor :records - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/run.rb b/lib/algolia/models/ingestion/run.rb index 62c31446..4c916b0b 100644 --- a/lib/algolia/models/ingestion/run.rb +++ b/lib/algolia/models/ingestion/run.rb @@ -39,28 +39,6 @@ class Run # Date of finish in RFC 3339 format. attr_accessor :finished_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/run_source_payload.rb b/lib/algolia/models/ingestion/run_source_payload.rb index 798e0c5c..8aaf27a6 100644 --- a/lib/algolia/models/ingestion/run_source_payload.rb +++ b/lib/algolia/models/ingestion/run_source_payload.rb @@ -17,28 +17,6 @@ class RunSourcePayload attr_accessor :entity_type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/schedule_trigger.rb b/lib/algolia/models/ingestion/schedule_trigger.rb index adedc974..08db6e22 100644 --- a/lib/algolia/models/ingestion/schedule_trigger.rb +++ b/lib/algolia/models/ingestion/schedule_trigger.rb @@ -18,28 +18,6 @@ class ScheduleTrigger # The next scheduled run of the task in RFC 3339 format. attr_accessor :next_run - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/schedule_trigger_input.rb b/lib/algolia/models/ingestion/schedule_trigger_input.rb index 6cdbeb57..685009f8 100644 --- a/lib/algolia/models/ingestion/schedule_trigger_input.rb +++ b/lib/algolia/models/ingestion/schedule_trigger_input.rb @@ -12,28 +12,6 @@ class ScheduleTriggerInput # Cron expression for the task's schedule. attr_accessor :cron - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source.rb b/lib/algolia/models/ingestion/source.rb index 6b332849..36927858 100644 --- a/lib/algolia/models/ingestion/source.rb +++ b/lib/algolia/models/ingestion/source.rb @@ -24,28 +24,6 @@ class Source # Date of last update in RFC 3339 format. attr_accessor :updated_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_big_query.rb b/lib/algolia/models/ingestion/source_big_query.rb index d9803e8b..046fa7ea 100644 --- a/lib/algolia/models/ingestion/source_big_query.rb +++ b/lib/algolia/models/ingestion/source_big_query.rb @@ -26,28 +26,6 @@ class SourceBigQuery # Name of a column that contains a unique ID which will be used as `objectID` in Algolia. attr_accessor :unique_id_column - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_create.rb b/lib/algolia/models/ingestion/source_create.rb index e2b6ccf9..c04786de 100644 --- a/lib/algolia/models/ingestion/source_create.rb +++ b/lib/algolia/models/ingestion/source_create.rb @@ -16,28 +16,6 @@ class SourceCreate # Universally unique identifier (UUID) of an authentication resource. attr_accessor :authentication_id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_csv.rb b/lib/algolia/models/ingestion/source_csv.rb index 36976bf3..77274841 100644 --- a/lib/algolia/models/ingestion/source_csv.rb +++ b/lib/algolia/models/ingestion/source_csv.rb @@ -20,28 +20,6 @@ class SourceCSV # The character used to split the value on each line, default to a comma (\\r, \\n, 0xFFFD, and space are forbidden). attr_accessor :delimiter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_docker.rb b/lib/algolia/models/ingestion/source_docker.rb index 7d7c8a66..a414d52e 100644 --- a/lib/algolia/models/ingestion/source_docker.rb +++ b/lib/algolia/models/ingestion/source_docker.rb @@ -19,28 +19,6 @@ class SourceDocker # Configuration of the spec. attr_accessor :configuration - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_input.rb b/lib/algolia/models/ingestion/source_input.rb index 43988a91..afeff680 100644 --- a/lib/algolia/models/ingestion/source_input.rb +++ b/lib/algolia/models/ingestion/source_input.rb @@ -86,13 +86,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/source_json.rb b/lib/algolia/models/ingestion/source_json.rb index 76b0774e..9322368c 100644 --- a/lib/algolia/models/ingestion/source_json.rb +++ b/lib/algolia/models/ingestion/source_json.rb @@ -14,28 +14,6 @@ class SourceJSON attr_accessor :method - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_update_docker.rb b/lib/algolia/models/ingestion/source_update_docker.rb index e2e7bc13..d6fdbafe 100644 --- a/lib/algolia/models/ingestion/source_update_docker.rb +++ b/lib/algolia/models/ingestion/source_update_docker.rb @@ -17,28 +17,6 @@ class SourceUpdateDocker # Configuration of the spec. attr_accessor :configuration - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/source_update_input.rb b/lib/algolia/models/ingestion/source_update_input.rb index d2110b46..55de0aed 100644 --- a/lib/algolia/models/ingestion/source_update_input.rb +++ b/lib/algolia/models/ingestion/source_update_input.rb @@ -85,13 +85,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/streaming_trigger.rb b/lib/algolia/models/ingestion/streaming_trigger.rb index 10ac777c..cb61e554 100644 --- a/lib/algolia/models/ingestion/streaming_trigger.rb +++ b/lib/algolia/models/ingestion/streaming_trigger.rb @@ -9,28 +9,6 @@ module Ingestion class StreamingTrigger attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/subscription_trigger.rb b/lib/algolia/models/ingestion/subscription_trigger.rb index 1440daba..0296553d 100644 --- a/lib/algolia/models/ingestion/subscription_trigger.rb +++ b/lib/algolia/models/ingestion/subscription_trigger.rb @@ -9,28 +9,6 @@ module Ingestion class SubscriptionTrigger attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/task.rb b/lib/algolia/models/ingestion/task.rb index 8ae865b0..6a7e3f7b 100644 --- a/lib/algolia/models/ingestion/task.rb +++ b/lib/algolia/models/ingestion/task.rb @@ -43,28 +43,6 @@ class Task # Date of last update in RFC 3339 format. attr_accessor :updated_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/task_create.rb b/lib/algolia/models/ingestion/task_create.rb index 8bdf3486..0ea1e71b 100644 --- a/lib/algolia/models/ingestion/task_create.rb +++ b/lib/algolia/models/ingestion/task_create.rb @@ -29,28 +29,6 @@ class TaskCreate # Date of the last cursor in RFC 3339 format. attr_accessor :cursor - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/task_create_trigger.rb b/lib/algolia/models/ingestion/task_create_trigger.rb index b7383238..439fdb47 100644 --- a/lib/algolia/models/ingestion/task_create_trigger.rb +++ b/lib/algolia/models/ingestion/task_create_trigger.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/task_create_v1.rb b/lib/algolia/models/ingestion/task_create_v1.rb index 32738a64..f9d9fbc5 100644 --- a/lib/algolia/models/ingestion/task_create_v1.rb +++ b/lib/algolia/models/ingestion/task_create_v1.rb @@ -28,28 +28,6 @@ class TaskCreateV1 # Date of the last cursor in RFC 3339 format. attr_accessor :cursor - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/task_input.rb b/lib/algolia/models/ingestion/task_input.rb index a10a8e9a..981b4da1 100644 --- a/lib/algolia/models/ingestion/task_input.rb +++ b/lib/algolia/models/ingestion/task_input.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/ingestion/task_v1.rb b/lib/algolia/models/ingestion/task_v1.rb index 29c535e9..e0d610f3 100644 --- a/lib/algolia/models/ingestion/task_v1.rb +++ b/lib/algolia/models/ingestion/task_v1.rb @@ -37,28 +37,6 @@ class TaskV1 # Date of last update in RFC 3339 format. attr_accessor :updated_at - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/ingestion/trigger.rb b/lib/algolia/models/ingestion/trigger.rb index a68aed40..fe7df5b3 100644 --- a/lib/algolia/models/ingestion/trigger.rb +++ b/lib/algolia/models/ingestion/trigger.rb @@ -83,13 +83,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Ingestion.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model 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 e255f0ab..bc99932c 100644 --- a/lib/algolia/models/insights/added_to_cart_object_ids.rb +++ b/lib/algolia/models/insights/added_to_cart_object_ids.rb @@ -37,28 +37,6 @@ class AddedToCartObjectIDs attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 78d3d1c1..cf8660b2 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 @@ -40,28 +40,6 @@ class AddedToCartObjectIDsAfterSearch attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/clicked_filters.rb b/lib/algolia/models/insights/clicked_filters.rb index 5cfdec06..da345f47 100644 --- a/lib/algolia/models/insights/clicked_filters.rb +++ b/lib/algolia/models/insights/clicked_filters.rb @@ -27,28 +27,6 @@ class ClickedFilters # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/clicked_object_ids.rb b/lib/algolia/models/insights/clicked_object_ids.rb index cd1651b9..37fc34f8 100644 --- a/lib/algolia/models/insights/clicked_object_ids.rb +++ b/lib/algolia/models/insights/clicked_object_ids.rb @@ -27,28 +27,6 @@ class ClickedObjectIDs # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 500504d0..a429cad7 100644 --- a/lib/algolia/models/insights/clicked_object_ids_after_search.rb +++ b/lib/algolia/models/insights/clicked_object_ids_after_search.rb @@ -33,28 +33,6 @@ class ClickedObjectIDsAfterSearch # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/converted_filters.rb b/lib/algolia/models/insights/converted_filters.rb index 0d8e46fe..d9bfd2d9 100644 --- a/lib/algolia/models/insights/converted_filters.rb +++ b/lib/algolia/models/insights/converted_filters.rb @@ -26,28 +26,6 @@ class ConvertedFilters # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/converted_object_ids.rb b/lib/algolia/models/insights/converted_object_ids.rb index 3c125141..be780532 100644 --- a/lib/algolia/models/insights/converted_object_ids.rb +++ b/lib/algolia/models/insights/converted_object_ids.rb @@ -27,28 +27,6 @@ class ConvertedObjectIDs # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 daf74b6f..191710ec 100644 --- a/lib/algolia/models/insights/converted_object_ids_after_search.rb +++ b/lib/algolia/models/insights/converted_object_ids_after_search.rb @@ -30,28 +30,6 @@ class ConvertedObjectIDsAfterSearch # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/discount.rb b/lib/algolia/models/insights/discount.rb index 1c5b52a0..6a32d48f 100644 --- a/lib/algolia/models/insights/discount.rb +++ b/lib/algolia/models/insights/discount.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Insights.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/insights/events_items.rb b/lib/algolia/models/insights/events_items.rb index 3b7a77cf..c171e5ae 100644 --- a/lib/algolia/models/insights/events_items.rb +++ b/lib/algolia/models/insights/events_items.rb @@ -90,13 +90,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Insights.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/insights/price.rb b/lib/algolia/models/insights/price.rb index 1d5c06db..f4774d90 100644 --- a/lib/algolia/models/insights/price.rb +++ b/lib/algolia/models/insights/price.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Insights.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/insights/purchased_object_ids.rb b/lib/algolia/models/insights/purchased_object_ids.rb index 061a096f..6252829b 100644 --- a/lib/algolia/models/insights/purchased_object_ids.rb +++ b/lib/algolia/models/insights/purchased_object_ids.rb @@ -37,28 +37,6 @@ class PurchasedObjectIDs attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { 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 b49435cd..51ca25ac 100644 --- a/lib/algolia/models/insights/purchased_object_ids_after_search.rb +++ b/lib/algolia/models/insights/purchased_object_ids_after_search.rb @@ -37,28 +37,6 @@ class PurchasedObjectIDsAfterSearch attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/value.rb b/lib/algolia/models/insights/value.rb index 7614d3f6..9af6cfa3 100644 --- a/lib/algolia/models/insights/value.rb +++ b/lib/algolia/models/insights/value.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Insights.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/insights/viewed_filters.rb b/lib/algolia/models/insights/viewed_filters.rb index c7de21ba..ee5dfd2f 100644 --- a/lib/algolia/models/insights/viewed_filters.rb +++ b/lib/algolia/models/insights/viewed_filters.rb @@ -27,28 +27,6 @@ class ViewedFilters # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/insights/viewed_object_ids.rb b/lib/algolia/models/insights/viewed_object_ids.rb index f7a432e8..73622b37 100644 --- a/lib/algolia/models/insights/viewed_object_ids.rb +++ b/lib/algolia/models/insights/viewed_object_ids.rb @@ -27,28 +27,6 @@ class ViewedObjectIDs # Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp. attr_accessor :timestamp - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/monitoring/incident.rb b/lib/algolia/models/monitoring/incident.rb index bd4459fe..da44d52e 100644 --- a/lib/algolia/models/monitoring/incident.rb +++ b/lib/algolia/models/monitoring/incident.rb @@ -12,28 +12,6 @@ class Incident attr_accessor :status - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/monitoring/server.rb b/lib/algolia/models/monitoring/server.rb index 8b6777ee..90ba270b 100644 --- a/lib/algolia/models/monitoring/server.rb +++ b/lib/algolia/models/monitoring/server.rb @@ -24,28 +24,6 @@ class Server attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/personalization/event_scoring.rb b/lib/algolia/models/personalization/event_scoring.rb index a242b6bb..d16d4a01 100644 --- a/lib/algolia/models/personalization/event_scoring.rb +++ b/lib/algolia/models/personalization/event_scoring.rb @@ -14,28 +14,6 @@ class EventScoring attr_accessor :event_type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/query-suggestions/languages.rb b/lib/algolia/models/query-suggestions/languages.rb index 6a5bf272..d5c478f2 100644 --- a/lib/algolia/models/query-suggestions/languages.rb +++ b/lib/algolia/models/query-suggestions/languages.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::QuerySuggestions.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/query-suggestions/log_file.rb b/lib/algolia/models/query-suggestions/log_file.rb index dcf1f80b..588c11f9 100644 --- a/lib/algolia/models/query-suggestions/log_file.rb +++ b/lib/algolia/models/query-suggestions/log_file.rb @@ -17,28 +17,6 @@ class LogFile # Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0. attr_accessor :context_level - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/around_precision.rb b/lib/algolia/models/recommend/around_precision.rb index b45009f5..18ebfcb6 100644 --- a/lib/algolia/models/recommend/around_precision.rb +++ b/lib/algolia/models/recommend/around_precision.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/around_radius.rb b/lib/algolia/models/recommend/around_radius.rb index 5c56ebd7..b426e374 100644 --- a/lib/algolia/models/recommend/around_radius.rb +++ b/lib/algolia/models/recommend/around_radius.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/boolean_string.rb b/lib/algolia/models/recommend/boolean_string.rb new file mode 100644 index 00000000..91875c3d --- /dev/null +++ b/lib/algolia/models/recommend/boolean_string.rb @@ -0,0 +1,32 @@ +# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +require "date" +require "time" + +module Algolia + module Recommend + class BooleanString + TRUE = "true".freeze + FALSE = "false".freeze + + def self.all_vars + @all_vars ||= [TRUE, FALSE].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if BooleanString.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #BooleanString" + end + end + end +end diff --git a/lib/algolia/models/recommend/bought_together_query.rb b/lib/algolia/models/recommend/bought_together_query.rb index 0b5dc594..71295004 100644 --- a/lib/algolia/models/recommend/bought_together_query.rb +++ b/lib/algolia/models/recommend/bought_together_query.rb @@ -22,28 +22,6 @@ class BoughtTogetherQuery # Unique record identifier. attr_accessor :object_id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/distinct.rb b/lib/algolia/models/recommend/distinct.rb index 3fd6e623..9f8ccf69 100644 --- a/lib/algolia/models/recommend/distinct.rb +++ b/lib/algolia/models/recommend/distinct.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/facet_filters.rb b/lib/algolia/models/recommend/facet_filters.rb index bdfe909f..6261f008 100644 --- a/lib/algolia/models/recommend/facet_filters.rb +++ b/lib/algolia/models/recommend/facet_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/fallback_params.rb b/lib/algolia/models/recommend/fallback_params.rb index 6e6a7c19..d4e89612 100644 --- a/lib/algolia/models/recommend/fallback_params.rb +++ b/lib/algolia/models/recommend/fallback_params.rb @@ -217,28 +217,6 @@ class FallbackParams attr_accessor :re_ranking_apply_filter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/get_recommend_task_response.rb b/lib/algolia/models/recommend/get_recommend_task_response.rb index 7e801737..93504b85 100644 --- a/lib/algolia/models/recommend/get_recommend_task_response.rb +++ b/lib/algolia/models/recommend/get_recommend_task_response.rb @@ -8,28 +8,6 @@ module Recommend class GetRecommendTaskResponse attr_accessor :status - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/highlight_result.rb b/lib/algolia/models/recommend/highlight_result.rb index 6e73b87d..a95eb62a 100644 --- a/lib/algolia/models/recommend/highlight_result.rb +++ b/lib/algolia/models/recommend/highlight_result.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/highlight_result_option.rb b/lib/algolia/models/recommend/highlight_result_option.rb index 3896a091..23038d67 100644 --- a/lib/algolia/models/recommend/highlight_result_option.rb +++ b/lib/algolia/models/recommend/highlight_result_option.rb @@ -18,28 +18,6 @@ class HighlightResultOption # Whether the entire attribute value is highlighted. attr_accessor :fully_highlighted - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/ignore_plurals.rb b/lib/algolia/models/recommend/ignore_plurals.rb index a696cd2b..3606ca1d 100644 --- a/lib/algolia/models/recommend/ignore_plurals.rb +++ b/lib/algolia/models/recommend/ignore_plurals.rb @@ -12,7 +12,8 @@ class << self def openapi_one_of [ :"Array", - :"Boolean" + :"Boolean", + :"BooleanString" ] end @@ -81,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/looking_similar_query.rb b/lib/algolia/models/recommend/looking_similar_query.rb index 0eac223d..2dc1a5c9 100644 --- a/lib/algolia/models/recommend/looking_similar_query.rb +++ b/lib/algolia/models/recommend/looking_similar_query.rb @@ -24,28 +24,6 @@ class LookingSimilarQuery attr_accessor :fallback_parameters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/numeric_filters.rb b/lib/algolia/models/recommend/numeric_filters.rb index f538687d..92e95da4 100644 --- a/lib/algolia/models/recommend/numeric_filters.rb +++ b/lib/algolia/models/recommend/numeric_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/optional_filters.rb b/lib/algolia/models/recommend/optional_filters.rb index ca60c9b8..cd4236bd 100644 --- a/lib/algolia/models/recommend/optional_filters.rb +++ b/lib/algolia/models/recommend/optional_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/re_ranking_apply_filter.rb b/lib/algolia/models/recommend/re_ranking_apply_filter.rb index 15a0a57a..2dd96834 100644 --- a/lib/algolia/models/recommend/re_ranking_apply_filter.rb +++ b/lib/algolia/models/recommend/re_ranking_apply_filter.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/recommendations_hit.rb b/lib/algolia/models/recommend/recommendations_hit.rb index d4aedc17..ba20dcb6 100644 --- a/lib/algolia/models/recommend/recommendations_hit.rb +++ b/lib/algolia/models/recommend/recommendations_hit.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/recommendations_request.rb b/lib/algolia/models/recommend/recommendations_request.rb index 2fe0a500..b8b34ef2 100644 --- a/lib/algolia/models/recommend/recommendations_request.rb +++ b/lib/algolia/models/recommend/recommendations_request.rb @@ -84,13 +84,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/recommended_for_you_query.rb b/lib/algolia/models/recommend/recommended_for_you_query.rb index 0b3e8015..44aa11a4 100644 --- a/lib/algolia/models/recommend/recommended_for_you_query.rb +++ b/lib/algolia/models/recommend/recommended_for_you_query.rb @@ -21,28 +21,6 @@ class RecommendedForYouQuery attr_accessor :fallback_parameters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/related_query.rb b/lib/algolia/models/recommend/related_query.rb index 286663bd..4871ab65 100644 --- a/lib/algolia/models/recommend/related_query.rb +++ b/lib/algolia/models/recommend/related_query.rb @@ -24,28 +24,6 @@ class RelatedQuery attr_accessor :fallback_parameters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/remove_stop_words.rb b/lib/algolia/models/recommend/remove_stop_words.rb index d90858e4..a2de371f 100644 --- a/lib/algolia/models/recommend/remove_stop_words.rb +++ b/lib/algolia/models/recommend/remove_stop_words.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/search_params.rb b/lib/algolia/models/recommend/search_params.rb index 49af3191..208dd847 100644 --- a/lib/algolia/models/recommend/search_params.rb +++ b/lib/algolia/models/recommend/search_params.rb @@ -217,28 +217,6 @@ class SearchParams attr_accessor :re_ranking_apply_filter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/search_params_object.rb b/lib/algolia/models/recommend/search_params_object.rb index 4c7aa115..94ddbb21 100644 --- a/lib/algolia/models/recommend/search_params_object.rb +++ b/lib/algolia/models/recommend/search_params_object.rb @@ -218,28 +218,6 @@ class SearchParamsObject attr_accessor :re_ranking_apply_filter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/snippet_result.rb b/lib/algolia/models/recommend/snippet_result.rb index 36e8340d..4ec49fa9 100644 --- a/lib/algolia/models/recommend/snippet_result.rb +++ b/lib/algolia/models/recommend/snippet_result.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/snippet_result_option.rb b/lib/algolia/models/recommend/snippet_result_option.rb index 1f1a7a68..a61b4f4b 100644 --- a/lib/algolia/models/recommend/snippet_result_option.rb +++ b/lib/algolia/models/recommend/snippet_result_option.rb @@ -12,28 +12,6 @@ class SnippetResultOption attr_accessor :match_level - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/tag_filters.rb b/lib/algolia/models/recommend/tag_filters.rb index 0e8dc90b..f6cedf62 100644 --- a/lib/algolia/models/recommend/tag_filters.rb +++ b/lib/algolia/models/recommend/tag_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/trending_facets_query.rb b/lib/algolia/models/recommend/trending_facets_query.rb index 50c1f613..37c53216 100644 --- a/lib/algolia/models/recommend/trending_facets_query.rb +++ b/lib/algolia/models/recommend/trending_facets_query.rb @@ -24,28 +24,6 @@ class TrendingFacetsQuery attr_accessor :fallback_parameters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/trending_items_query.rb b/lib/algolia/models/recommend/trending_items_query.rb index 842b32ae..63a43482 100644 --- a/lib/algolia/models/recommend/trending_items_query.rb +++ b/lib/algolia/models/recommend/trending_items_query.rb @@ -27,28 +27,6 @@ class TrendingItemsQuery attr_accessor :fallback_parameters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/recommend/typo_tolerance.rb b/lib/algolia/models/recommend/typo_tolerance.rb index b926cd15..a2b4d62f 100644 --- a/lib/algolia/models/recommend/typo_tolerance.rb +++ b/lib/algolia/models/recommend/typo_tolerance.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Recommend.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/recommend/value.rb b/lib/algolia/models/recommend/value.rb index 7affe306..330ba490 100644 --- a/lib/algolia/models/recommend/value.rb +++ b/lib/algolia/models/recommend/value.rb @@ -14,28 +14,6 @@ class Value # Hide facet values. attr_accessor :hide - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/around_precision.rb b/lib/algolia/models/search/around_precision.rb index 915eff27..a4c1b466 100644 --- a/lib/algolia/models/search/around_precision.rb +++ b/lib/algolia/models/search/around_precision.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/around_radius.rb b/lib/algolia/models/search/around_radius.rb index f118c1ea..28ff2000 100644 --- a/lib/algolia/models/search/around_radius.rb +++ b/lib/algolia/models/search/around_radius.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/attribute_to_update.rb b/lib/algolia/models/search/attribute_to_update.rb index cfd6a218..9906909c 100644 --- a/lib/algolia/models/search/attribute_to_update.rb +++ b/lib/algolia/models/search/attribute_to_update.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/automatic_facet_filters.rb b/lib/algolia/models/search/automatic_facet_filters.rb index 2f7d342d..d22f41be 100644 --- a/lib/algolia/models/search/automatic_facet_filters.rb +++ b/lib/algolia/models/search/automatic_facet_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/batch_dictionary_entries_request.rb b/lib/algolia/models/search/batch_dictionary_entries_request.rb index 9fc9ee2b..15a2d178 100644 --- a/lib/algolia/models/search/batch_dictionary_entries_request.rb +++ b/lib/algolia/models/search/batch_dictionary_entries_request.rb @@ -10,28 +10,6 @@ class BatchDictionaryEntriesRequest attr_accessor :body - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/batch_request.rb b/lib/algolia/models/search/batch_request.rb index 9e9ab1a8..48871b3f 100644 --- a/lib/algolia/models/search/batch_request.rb +++ b/lib/algolia/models/search/batch_request.rb @@ -11,28 +11,6 @@ class BatchRequest # Operation arguments (varies with specified `action`). attr_accessor :body - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/boolean_string.rb b/lib/algolia/models/search/boolean_string.rb new file mode 100644 index 00000000..203fcbab --- /dev/null +++ b/lib/algolia/models/search/boolean_string.rb @@ -0,0 +1,32 @@ +# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +require "date" +require "time" + +module Algolia + module Search + class BooleanString + TRUE = "true".freeze + FALSE = "false".freeze + + def self.all_vars + @all_vars ||= [TRUE, FALSE].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if BooleanString.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #BooleanString" + end + end + end +end diff --git a/lib/algolia/models/search/browse_params.rb b/lib/algolia/models/search/browse_params.rb index 97dc65a5..e7bdb6de 100644 --- a/lib/algolia/models/search/browse_params.rb +++ b/lib/algolia/models/search/browse_params.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/browse_params_object.rb b/lib/algolia/models/search/browse_params_object.rb index 8ca2efd8..6532517e 100644 --- a/lib/algolia/models/search/browse_params_object.rb +++ b/lib/algolia/models/search/browse_params_object.rb @@ -220,28 +220,6 @@ class BrowseParamsObject # Cursor to get the next page of the response. The parameter must match the value returned in the response of a previous request. The last page of the response does not return a `cursor` attribute. attr_accessor :cursor - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/built_in_operation.rb b/lib/algolia/models/search/built_in_operation.rb index 101c4b75..2be90ee0 100644 --- a/lib/algolia/models/search/built_in_operation.rb +++ b/lib/algolia/models/search/built_in_operation.rb @@ -11,28 +11,6 @@ class BuiltInOperation attr_accessor :value - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/built_in_operation_value.rb b/lib/algolia/models/search/built_in_operation_value.rb index 90bd3904..5d258c9d 100644 --- a/lib/algolia/models/search/built_in_operation_value.rb +++ b/lib/algolia/models/search/built_in_operation_value.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/condition.rb b/lib/algolia/models/search/condition.rb index 3c72e649..b7754b06 100644 --- a/lib/algolia/models/search/condition.rb +++ b/lib/algolia/models/search/condition.rb @@ -20,28 +20,6 @@ class Condition # Filters that trigger the rule. You can add add filters using the syntax `facet:value` so that the rule is triggered, when the specific filter is selected. You can use `filters` on its own or combine it with the `pattern` parameter. attr_accessor :filters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/consequence_params.rb b/lib/algolia/models/search/consequence_params.rb index 8f780712..a3bbfe37 100644 --- a/lib/algolia/models/search/consequence_params.rb +++ b/lib/algolia/models/search/consequence_params.rb @@ -220,28 +220,6 @@ class ConsequenceParams attr_accessor :automatic_optional_facet_filters - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/consequence_query.rb b/lib/algolia/models/search/consequence_query.rb index 2c42f4a0..e8c0a39f 100644 --- a/lib/algolia/models/search/consequence_query.rb +++ b/lib/algolia/models/search/consequence_query.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/dictionary_entry.rb b/lib/algolia/models/search/dictionary_entry.rb index a0fcb908..930db843 100644 --- a/lib/algolia/models/search/dictionary_entry.rb +++ b/lib/algolia/models/search/dictionary_entry.rb @@ -27,28 +27,6 @@ class DictionaryEntry attr_accessor :additional_properties - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/distinct.rb b/lib/algolia/models/search/distinct.rb index 6b73326b..34ac43b0 100644 --- a/lib/algolia/models/search/distinct.rb +++ b/lib/algolia/models/search/distinct.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/edit.rb b/lib/algolia/models/search/edit.rb index 8f4c45b1..3be42842 100644 --- a/lib/algolia/models/search/edit.rb +++ b/lib/algolia/models/search/edit.rb @@ -14,28 +14,6 @@ class Edit # Text to be added in place of the deleted text inside the query string. attr_accessor :insert - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/facet_filters.rb b/lib/algolia/models/search/facet_filters.rb index 65c7882a..8421fe3e 100644 --- a/lib/algolia/models/search/facet_filters.rb +++ b/lib/algolia/models/search/facet_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/get_task_response.rb b/lib/algolia/models/search/get_task_response.rb index a6f32813..e52acd7e 100644 --- a/lib/algolia/models/search/get_task_response.rb +++ b/lib/algolia/models/search/get_task_response.rb @@ -8,28 +8,6 @@ module Search class GetTaskResponse attr_accessor :status - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/highlight_result.rb b/lib/algolia/models/search/highlight_result.rb index fee0d874..1fff75fa 100644 --- a/lib/algolia/models/search/highlight_result.rb +++ b/lib/algolia/models/search/highlight_result.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/highlight_result_option.rb b/lib/algolia/models/search/highlight_result_option.rb index 585479e4..c72ce281 100644 --- a/lib/algolia/models/search/highlight_result_option.rb +++ b/lib/algolia/models/search/highlight_result_option.rb @@ -18,28 +18,6 @@ class HighlightResultOption # Whether the entire attribute value is highlighted. attr_accessor :fully_highlighted - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/ignore_plurals.rb b/lib/algolia/models/search/ignore_plurals.rb index ee1aa236..2c3afc31 100644 --- a/lib/algolia/models/search/ignore_plurals.rb +++ b/lib/algolia/models/search/ignore_plurals.rb @@ -12,7 +12,8 @@ class << self def openapi_one_of [ :"Array", - :"Boolean" + :"Boolean", + :"BooleanString" ] end @@ -81,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/index_settings.rb b/lib/algolia/models/search/index_settings.rb index d968078d..9178191d 100644 --- a/lib/algolia/models/search/index_settings.rb +++ b/lib/algolia/models/search/index_settings.rb @@ -179,28 +179,6 @@ class IndexSettings attr_accessor :re_ranking_apply_filter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/multiple_batch_request.rb b/lib/algolia/models/search/multiple_batch_request.rb index 8ef83d4f..1b613f27 100644 --- a/lib/algolia/models/search/multiple_batch_request.rb +++ b/lib/algolia/models/search/multiple_batch_request.rb @@ -14,28 +14,6 @@ class MultipleBatchRequest # Index name (case-sensitive). attr_accessor :index_name - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/numeric_filters.rb b/lib/algolia/models/search/numeric_filters.rb index 582e1df3..ae28bd88 100644 --- a/lib/algolia/models/search/numeric_filters.rb +++ b/lib/algolia/models/search/numeric_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/operation_index_params.rb b/lib/algolia/models/search/operation_index_params.rb index 7b0ad5ae..a10d37df 100644 --- a/lib/algolia/models/search/operation_index_params.rb +++ b/lib/algolia/models/search/operation_index_params.rb @@ -14,28 +14,6 @@ class OperationIndexParams # **Only for copying.** If you specify a scope, only the selected scopes are copied. Records and the other scopes are left unchanged. If you omit the `scope` parameter, everything is copied: records, settings, synonyms, and rules. attr_accessor :scope - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/optional_filters.rb b/lib/algolia/models/search/optional_filters.rb index 652cb1a8..be58522f 100644 --- a/lib/algolia/models/search/optional_filters.rb +++ b/lib/algolia/models/search/optional_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/promote.rb b/lib/algolia/models/search/promote.rb index 39b7121e..4f5ac734 100644 --- a/lib/algolia/models/search/promote.rb +++ b/lib/algolia/models/search/promote.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/re_ranking_apply_filter.rb b/lib/algolia/models/search/re_ranking_apply_filter.rb index d8253932..dbe1700d 100644 --- a/lib/algolia/models/search/re_ranking_apply_filter.rb +++ b/lib/algolia/models/search/re_ranking_apply_filter.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/remove_stop_words.rb b/lib/algolia/models/search/remove_stop_words.rb index 56e0a630..e28a9f6f 100644 --- a/lib/algolia/models/search/remove_stop_words.rb +++ b/lib/algolia/models/search/remove_stop_words.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/search_dictionary_entries_params.rb b/lib/algolia/models/search/search_dictionary_entries_params.rb index 643b4a00..bdc6af7f 100644 --- a/lib/algolia/models/search/search_dictionary_entries_params.rb +++ b/lib/algolia/models/search/search_dictionary_entries_params.rb @@ -18,28 +18,6 @@ class SearchDictionaryEntriesParams attr_accessor :language - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_for_facets.rb b/lib/algolia/models/search/search_for_facets.rb index b229b1b5..8ac92360 100644 --- a/lib/algolia/models/search/search_for_facets.rb +++ b/lib/algolia/models/search/search_for_facets.rb @@ -231,28 +231,6 @@ class SearchForFacets attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_for_hits.rb b/lib/algolia/models/search/search_for_hits.rb index 3d132390..ae4056e5 100644 --- a/lib/algolia/models/search/search_for_hits.rb +++ b/lib/algolia/models/search/search_for_hits.rb @@ -225,28 +225,6 @@ class SearchForHits attr_accessor :type - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_method_params.rb b/lib/algolia/models/search/search_method_params.rb index fabb2173..760786d8 100644 --- a/lib/algolia/models/search/search_method_params.rb +++ b/lib/algolia/models/search/search_method_params.rb @@ -10,28 +10,6 @@ class SearchMethodParams attr_accessor :strategy - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_params.rb b/lib/algolia/models/search/search_params.rb index 726ac2ce..f5460d88 100644 --- a/lib/algolia/models/search/search_params.rb +++ b/lib/algolia/models/search/search_params.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/search_params_object.rb b/lib/algolia/models/search/search_params_object.rb index f66063bf..38f322fe 100644 --- a/lib/algolia/models/search/search_params_object.rb +++ b/lib/algolia/models/search/search_params_object.rb @@ -218,28 +218,6 @@ class SearchParamsObject attr_accessor :re_ranking_apply_filter - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_query.rb b/lib/algolia/models/search/search_query.rb index 6786a215..2fa530f7 100644 --- a/lib/algolia/models/search/search_query.rb +++ b/lib/algolia/models/search/search_query.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/search_result.rb b/lib/algolia/models/search/search_result.rb index 557b70c1..58a7734c 100644 --- a/lib/algolia/models/search/search_result.rb +++ b/lib/algolia/models/search/search_result.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/search_rules_params.rb b/lib/algolia/models/search/search_rules_params.rb index c4bf1cbd..04c05088 100644 --- a/lib/algolia/models/search/search_rules_params.rb +++ b/lib/algolia/models/search/search_rules_params.rb @@ -24,28 +24,6 @@ class SearchRulesParams # If `true`, return only enabled rules. If `false`, return only inactive rules. By default, _all_ rules are returned. attr_accessor :enabled - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/search_synonyms_params.rb b/lib/algolia/models/search/search_synonyms_params.rb index 4ee5e5de..21e0e031 100644 --- a/lib/algolia/models/search/search_synonyms_params.rb +++ b/lib/algolia/models/search/search_synonyms_params.rb @@ -17,28 +17,6 @@ class SearchSynonymsParams # Number of hits per page. attr_accessor :hits_per_page - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/settings_response.rb b/lib/algolia/models/search/settings_response.rb index 780743bb..cbfe5afe 100644 --- a/lib/algolia/models/search/settings_response.rb +++ b/lib/algolia/models/search/settings_response.rb @@ -181,28 +181,6 @@ class SettingsResponse # Replica indices only: the name of the primary index for this replica. attr_accessor :primary - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/snippet_result.rb b/lib/algolia/models/search/snippet_result.rb index d2dba989..ec16e695 100644 --- a/lib/algolia/models/search/snippet_result.rb +++ b/lib/algolia/models/search/snippet_result.rb @@ -82,13 +82,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/snippet_result_option.rb b/lib/algolia/models/search/snippet_result_option.rb index 6f22d779..e47327a7 100644 --- a/lib/algolia/models/search/snippet_result_option.rb +++ b/lib/algolia/models/search/snippet_result_option.rb @@ -12,28 +12,6 @@ class SnippetResultOption attr_accessor :match_level - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/synonym_hit.rb b/lib/algolia/models/search/synonym_hit.rb index 39ea507a..d035335f 100644 --- a/lib/algolia/models/search/synonym_hit.rb +++ b/lib/algolia/models/search/synonym_hit.rb @@ -30,28 +30,6 @@ class SynonymHit # Query words that will match the [placeholder token](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/in-depth/synonyms-placeholders/). attr_accessor :replacements - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/search/tag_filters.rb b/lib/algolia/models/search/tag_filters.rb index 948e4d05..a97f8b79 100644 --- a/lib/algolia/models/search/tag_filters.rb +++ b/lib/algolia/models/search/tag_filters.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/typo_tolerance.rb b/lib/algolia/models/search/typo_tolerance.rb index 65019056..6ea116f8 100644 --- a/lib/algolia/models/search/typo_tolerance.rb +++ b/lib/algolia/models/search/typo_tolerance.rb @@ -81,13 +81,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Search.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model diff --git a/lib/algolia/models/search/value.rb b/lib/algolia/models/search/value.rb index 774adfa5..6a686506 100644 --- a/lib/algolia/models/search/value.rb +++ b/lib/algolia/models/search/value.rb @@ -14,28 +14,6 @@ class Value # Hide facet values. attr_accessor :hide - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { diff --git a/lib/algolia/models/usage/statistic_value.rb b/lib/algolia/models/usage/statistic_value.rb index 28f2152d..df93cc42 100644 --- a/lib/algolia/models/usage/statistic_value.rb +++ b/lib/algolia/models/usage/statistic_value.rb @@ -80,13 +80,16 @@ def find_and_cast_into_type(klass, data) else const = Algolia::Usage.const_get(klass) if const - # nested oneOf model if const.respond_to?(:openapi_one_of) + # nested oneOf model model = const.build(data) - else + 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) + else + # maybe it's an enum + model = const.build_from_hash(data) end return model if model