Skip to content

Commit 0a370d1

Browse files
algolia-botmillotp
andcommitted
fix(ruby): use discriminators for oneOf [skip-bc] (#4310) (generated) [skip ci]
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent 653b4f3 commit 0a370d1

File tree

471 files changed

+1819
-2223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+1819
-2223
lines changed

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/ab_test.rb

-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ def self.attribute_map
5757
}
5858
end
5959

60-
# Returns all the JSON keys this model knows about
61-
def self.acceptable_attributes
62-
attribute_map.values
63-
end
64-
6560
# Attribute type mapping.
6661
def self.types_mapping
6762
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/ab_test_configuration.rb

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def self.attribute_map
2222
}
2323
end
2424

25-
# Returns all the JSON keys this model knows about
26-
def self.acceptable_attributes
27-
attribute_map.values
28-
end
29-
3025
# Attribute type mapping.
3126
def self.types_mapping
3227
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/ab_test_response.rb

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def self.attribute_map
2424
}
2525
end
2626

27-
# Returns all the JSON keys this model knows about
28-
def self.acceptable_attributes
29-
attribute_map.values
30-
end
31-
3227
# Attribute type mapping.
3328
def self.types_mapping
3429
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/ab_tests_variant.rb

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def self.attribute_map
2424
}
2525
end
2626

27-
# Returns all the JSON keys this model knows about
28-
def self.acceptable_attributes
29-
attribute_map.values
30-
end
31-
3227
# Attribute type mapping.
3328
def self.types_mapping
3429
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ def self.attribute_map
2727
}
2828
end
2929

30-
# Returns all the JSON keys this model knows about
31-
def self.acceptable_attributes
32-
attribute_map.values
30+
# Returns the keys that uniquely identify this oneOf variant when present
31+
def self.discriminator_attributes
32+
[
33+
:customSearchParameters
34+
]
3335
end
3436

3537
# Attribute type mapping.

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/add_ab_tests_request.rb

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def self.attribute_map
2424
}
2525
end
2626

27-
# Returns all the JSON keys this model knows about
28-
def self.acceptable_attributes
29-
attribute_map.values
30-
end
31-
3227
# Attribute type mapping.
3328
def self.types_mapping
3429
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/add_ab_tests_variant.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def build(data)
4444

4545
SchemaMismatchError = Class.new(StandardError)
4646

47-
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
4847
def find_and_cast_into_type(klass, data)
4948
return if data.nil?
5049

@@ -83,12 +82,12 @@ def find_and_cast_into_type(klass, data)
8382
if const.respond_to?(:openapi_one_of)
8483
# nested oneOf model
8584
model = const.build(data)
86-
elsif const.respond_to?(:acceptable_attributes)
87-
# raise if data contains keys that are not known to the model
88-
raise unless (data.keys - const.acceptable_attributes).empty?
89-
model = const.build_from_hash(data)
85+
elsif const.respond_to?(:discriminator_attributes)
86+
if const.discriminator_attributes.all? { |attr| data.key?(attr) }
87+
model = const.build_from_hash(data)
88+
end
9089
else
91-
# maybe it's an enum
90+
# maybe it's an enum, or doens't have discriminators
9291
model = const.build_from_hash(data)
9392
end
9493

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/currency.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/empty_search.rb

-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ def self.attribute_map
1717
}
1818
end
1919

20-
# Returns all the JSON keys this model knows about
21-
def self.acceptable_attributes
22-
attribute_map.values
23-
end
24-
2520
# Attribute type mapping.
2621
def self.types_mapping
2722
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/empty_search_filter.rb

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def self.attribute_map
2121
}
2222
end
2323

24-
# Returns all the JSON keys this model knows about
25-
def self.acceptable_attributes
26-
attribute_map.values
27-
end
28-
2924
# Attribute type mapping.
3025
def self.types_mapping
3126
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/error_base.rb

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ def self.attribute_map
1818
}
1919
end
2020

21-
# Returns all the JSON keys this model knows about
22-
def self.acceptable_attributes
23-
attribute_map.values
24-
end
25-
2621
# Attribute type mapping.
2722
def self.types_mapping
2823
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/estimate_ab_test_request.rb

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ def self.attribute_map
1919
}
2020
end
2121

22-
# Returns all the JSON keys this model knows about
23-
def self.acceptable_attributes
24-
attribute_map.values
25-
end
26-
2722
# Attribute type mapping.
2823
def self.types_mapping
2924
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/estimate_ab_test_response.rb

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ def self.attribute_map
2020
}
2121
end
2222

23-
# Returns all the JSON keys this model knows about
24-
def self.acceptable_attributes
25-
attribute_map.values
26-
end
27-
2823
# Attribute type mapping.
2924
def self.types_mapping
3025
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/estimate_configuration.rb

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ def self.attribute_map
2222
}
2323
end
2424

25-
# Returns all the JSON keys this model knows about
26-
def self.acceptable_attributes
27-
attribute_map.values
28-
end
29-
3025
# Attribute type mapping.
3126
def self.types_mapping
3227
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/filter_effects.rb

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ def self.attribute_map
1919
}
2020
end
2121

22-
# Returns all the JSON keys this model knows about
23-
def self.acceptable_attributes
24-
attribute_map.values
25-
end
26-
2722
# Attribute type mapping.
2823
def self.types_mapping
2924
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/list_ab_tests_response.rb

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def self.attribute_map
2424
}
2525
end
2626

27-
# Returns all the JSON keys this model knows about
28-
def self.acceptable_attributes
29-
attribute_map.values
30-
end
31-
3227
# Attribute type mapping.
3328
def self.types_mapping
3429
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/minimum_detectable_effect.rb

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ def self.attribute_map
2020
}
2121
end
2222

23-
# Returns all the JSON keys this model knows about
24-
def self.acceptable_attributes
25-
attribute_map.values
26-
end
27-
2823
# Attribute type mapping.
2924
def self.types_mapping
3025
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/outliers.rb

-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ def self.attribute_map
1717
}
1818
end
1919

20-
# Returns all the JSON keys this model knows about
21-
def self.acceptable_attributes
22-
attribute_map.values
23-
end
24-
2520
# Attribute type mapping.
2621
def self.types_mapping
2722
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/outliers_filter.rb

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def self.attribute_map
2121
}
2222
end
2323

24-
# Returns all the JSON keys this model knows about
25-
def self.acceptable_attributes
26-
attribute_map.values
27-
end
28-
2924
# Attribute type mapping.
3025
def self.types_mapping
3126
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/schedule_ab_test_response.rb

-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ def self.attribute_map
1616
}
1717
end
1818

19-
# Returns all the JSON keys this model knows about
20-
def self.acceptable_attributes
21-
attribute_map.values
22-
end
23-
2419
# Attribute type mapping.
2520
def self.types_mapping
2621
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/schedule_ab_tests_request.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/abtesting/variant.rb

-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ def self.attribute_map
9191
}
9292
end
9393

94-
# Returns all the JSON keys this model knows about
95-
def self.acceptable_attributes
96-
attribute_map.values
97-
end
98-
9994
# Attribute type mapping.
10095
def self.types_mapping
10196
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/click_position.rb

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def self.attribute_map
2121
}
2222
end
2323

24-
# Returns all the JSON keys this model knows about
25-
def self.acceptable_attributes
26-
attribute_map.values
27-
end
28-
2924
# Attribute type mapping.
3025
def self.types_mapping
3126
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/currency_code.rb

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ def self.attribute_map
2121
}
2222
end
2323

24-
# Returns all the JSON keys this model knows about
25-
def self.acceptable_attributes
26-
attribute_map.values
27-
end
28-
2924
# Attribute type mapping.
3025
def self.types_mapping
3126
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_add_to_cart_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_average_clicks.rb

-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def self.attribute_map
2424
}
2525
end
2626

27-
# Returns all the JSON keys this model knows about
28-
def self.acceptable_attributes
29-
attribute_map.values
30-
end
31-
3227
# Attribute type mapping.
3328
def self.types_mapping
3429
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_click_through_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_conversion_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_no_click_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_no_results_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

clients/algoliasearch-client-ruby/lib/algolia/models/analytics/daily_purchase_rates.rb

-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def self.attribute_map
2828
}
2929
end
3030

31-
# Returns all the JSON keys this model knows about
32-
def self.acceptable_attributes
33-
attribute_map.values
34-
end
35-
3631
# Attribute type mapping.
3732
def self.types_mapping
3833
{

0 commit comments

Comments
 (0)