forked from loafle/openapi-generator-original
[Ruby] Fix ruby client generator to generate setter methods with not null validation (#20672)
* fix: Fix ruby client generator to generate setter methods with not null validation Not null validation was missing for required and non-nullable properties when no other validation was present. * fix: Fix an issue where the initialize method did not accept attributes defined in its parent class
This commit is contained in:
@@ -27,9 +27,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -54,9 +59,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Bird`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Bird`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -27,9 +27,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -54,9 +59,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Category`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Category`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -55,9 +55,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about, including the ones defined in its parent(s)
|
||||
def self.acceptable_attribute_map
|
||||
superclass.acceptable_attribute_map.merge(attribute_map)
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about, including the ones defined in its parent(s)
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values.concat(superclass.acceptable_attributes)
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -90,9 +95,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::DataQuery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::DataQuery`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -68,9 +68,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -104,9 +109,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::DefaultValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::DefaultValue`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -30,9 +30,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -58,9 +63,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::NumberPropertiesOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::NumberPropertiesOnly`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -62,9 +62,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -93,9 +98,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Pet`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Pet`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
@@ -160,6 +166,26 @@ module OpenapiClient
|
||||
true
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] name Value to be assigned
|
||||
def name=(name)
|
||||
if name.nil?
|
||||
fail ArgumentError, 'name cannot be nil'
|
||||
end
|
||||
|
||||
@name = name
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] photo_urls Value to be assigned
|
||||
def photo_urls=(photo_urls)
|
||||
if photo_urls.nil?
|
||||
fail ArgumentError, 'photo_urls cannot be nil'
|
||||
end
|
||||
|
||||
@photo_urls = photo_urls
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] status Object to be assigned
|
||||
def status=(status)
|
||||
|
||||
@@ -50,9 +50,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -77,9 +82,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Query`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Query`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -27,9 +27,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -54,9 +59,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Tag`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Tag`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -24,9 +24,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -50,9 +55,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestFormObjectMultipartRequestMarker`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestFormObjectMultipartRequestMarker`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -33,9 +33,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -70,9 +75,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
@@ -24,9 +24,14 @@ module OpenapiClient
|
||||
}
|
||||
end
|
||||
|
||||
# Returns attribute mapping this model knows about
|
||||
def self.acceptable_attribute_map
|
||||
attribute_map
|
||||
end
|
||||
|
||||
# Returns all the JSON keys this model knows about
|
||||
def self.acceptable_attributes
|
||||
attribute_map.values
|
||||
acceptable_attribute_map.values
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
@@ -50,9 +55,10 @@ module OpenapiClient
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
acceptable_attribute_map = self.class.acceptable_attribute_map
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
if (!acceptable_attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user