Skip to content

Commit

Permalink
fix(specs): ignorePlurals can be a boolean string (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3620

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
algolia-bot and millotp committed Aug 30, 2024
1 parent 92c9e62 commit 98be1f6
Show file tree
Hide file tree
Showing 145 changed files with 344 additions and 2,027 deletions.
2 changes: 1 addition & 1 deletion lib/algolia/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/abtesting/ab_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 5 additions & 2 deletions lib/algolia/models/abtesting/add_ab_tests_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/abtesting/minimum_detectable_effect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/analytics/get_top_filter_for_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/analytics/get_top_filters_no_results_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 5 additions & 2 deletions lib/algolia/models/analytics/get_top_hits_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/algolia/models/analytics/get_top_searches_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/algolia/models/ingestion/auth_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions lib/algolia/models/ingestion/auth_input_partial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/authentication_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/authentication_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/destination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/destination_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
22 changes: 0 additions & 22 deletions lib/algolia/models/ingestion/destination_index_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading

0 comments on commit 98be1f6

Please sign in to comment.