forked from loafle/openapi-generator-original
add methods to validate the ruby object
This commit is contained in:
parent
3c36f1df37
commit
e17a620506
@ -42,7 +42,7 @@ public class CodegenProperty {
|
|||||||
public Map<String, Object> allowableValues;
|
public Map<String, Object> allowableValues;
|
||||||
public CodegenProperty items;
|
public CodegenProperty items;
|
||||||
public Map<String, Object> vendorExtensions;
|
public Map<String, Object> vendorExtensions;
|
||||||
public Boolean needValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
public Boolean hasValidation; // true if pattern, maximum, etc are set (only used in the mustache template)
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
|
@ -1106,7 +1106,7 @@ public class DefaultCodegen {
|
|||||||
|
|
||||||
// check if any validation rule defined
|
// check if any validation rule defined
|
||||||
if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null)
|
if (property.minimum != null || property.maximum != null || property.exclusiveMinimum != null || property.exclusiveMaximum != null)
|
||||||
property.needValidation = true;
|
property.hasValidation = true;
|
||||||
|
|
||||||
// legacy support
|
// legacy support
|
||||||
Map<String, Object> allowableValues = new HashMap<String, Object>();
|
Map<String, Object> allowableValues = new HashMap<String, Object>();
|
||||||
@ -1129,7 +1129,7 @@ public class DefaultCodegen {
|
|||||||
|
|
||||||
// check if any validation rule defined
|
// check if any validation rule defined
|
||||||
if (property.pattern != null || property.minLength != null || property.maxLength != null)
|
if (property.pattern != null || property.minLength != null || property.maxLength != null)
|
||||||
property.needValidation = true;
|
property.hasValidation = true;
|
||||||
|
|
||||||
property.isString = true;
|
property.isString = true;
|
||||||
if (sp.getEnum() != null) {
|
if (sp.getEnum() != null) {
|
||||||
|
@ -39,12 +39,109 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
|||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
if attributes[:'{{{baseName}}}']
|
if attributes[:'{{{baseName}}}']
|
||||||
{{#isContainer}}if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
|
{{#isContainer}}
|
||||||
|
if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
|
||||||
self.{{{name}}} = value
|
self.{{{name}}} = value
|
||||||
end{{/isContainer}}{{^isContainer}}self.{{{name}}} = attributes[:'{{{baseName}}}']{{/isContainer}}{{#defaultValue}}
|
end
|
||||||
|
{{/isContainer}}
|
||||||
|
{{^isContainer}}
|
||||||
|
self.{{{name}}} = attributes[:'{{{baseName}}}']
|
||||||
|
{{/isContainer}}
|
||||||
|
{{#defaultValue}}
|
||||||
else
|
else
|
||||||
self.{{{name}}} = {{{defaultValue}}}{{/defaultValue}}
|
self.{{{name}}} = {{{defaultValue}}}
|
||||||
|
{{/defaultValue}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
{{#isEnum}}
|
||||||
|
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
||||||
|
if {{{name}}} && !allowed_values.include?({{{name}}})
|
||||||
|
invalid_properties.push("invalid value for '{{{name}}}', must be one of #{allowed_values}.")
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/isEnum}}
|
||||||
|
{{#hasValidation}}
|
||||||
|
if {{{name}}}.nil?
|
||||||
|
fail ArgumentError, "{{{name}}} cannot be nil"
|
||||||
|
end
|
||||||
|
|
||||||
|
{{#minLength}}
|
||||||
|
if {{{name}}}.to_s.length > {{{maxLength}}}
|
||||||
|
invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.")
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/minLength}}
|
||||||
|
{{#maxLength}}
|
||||||
|
if {{{name}}}.to_s.length < {{{minLength}}}
|
||||||
|
invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.")
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/maxLength}}
|
||||||
|
{{#maximum}}
|
||||||
|
if {{{name}}} > {{{maximum}}}
|
||||||
|
invalid_properties.push("invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}.")
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/maximum}}
|
||||||
|
{{#minimum}}
|
||||||
|
if {{{name}}} < {{{minimum}}}
|
||||||
|
invalid_properties.push("invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}.")
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/minimum}}
|
||||||
|
{{/hasValidation}}
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
{{#vars}}
|
||||||
|
{{#required}}
|
||||||
|
if @{{{name}}}.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/required}}
|
||||||
|
{{#isEnum}}
|
||||||
|
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
||||||
|
if {{{name}}} && !allowed_values.include?({{{name}}})
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
{{/isEnum}}
|
||||||
|
{{#hasValidation}}
|
||||||
|
{{#minLength}}
|
||||||
|
if {{{name}}}.to_s.length > {{{maxLength}}}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/minLength}}
|
||||||
|
{{#maxLength}}
|
||||||
|
if {{{name}}}.to_s.length < {{{minLength}}}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/maxLength}}
|
||||||
|
{{#maximum}}
|
||||||
|
if {{{name}}} > {{{maximum}}}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/maximum}}
|
||||||
|
{{#minimum}}
|
||||||
|
if {{{name}}} < {{{minimum}}}
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
{{/minimum}}
|
||||||
|
{{/hasValidation}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,14 +152,14 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
|||||||
def {{{name}}}=({{{name}}})
|
def {{{name}}}=({{{name}}})
|
||||||
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
||||||
if {{{name}}} && !allowed_values.include?({{{name}}})
|
if {{{name}}} && !allowed_values.include?({{{name}}})
|
||||||
fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}"
|
fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}."
|
||||||
end
|
end
|
||||||
@{{{name}}} = {{{name}}}
|
@{{{name}}} = {{{name}}}
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{^isEnum}}
|
{{^isEnum}}
|
||||||
{{#needValidation}}
|
{{#hasValidation}}
|
||||||
# Custom attribute writer method with validation
|
# Custom attribute writer method with validation
|
||||||
# @param [Object] {{{name}}} Value to be assigned
|
# @param [Object] {{{name}}} Value to be assigned
|
||||||
def {{{name}}}=({{{name}}})
|
def {{{name}}}=({{{name}}})
|
||||||
@ -72,32 +169,32 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
|||||||
|
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if {{{name}}}.to_s.length > {{{maxLength}}}
|
if {{{name}}}.to_s.length > {{{maxLength}}}
|
||||||
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}"
|
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
{{#maxLength}}
|
{{#maxLength}}
|
||||||
if {{{name}}}.to_s.length < {{{minLength}}}
|
if {{{name}}}.to_s.length < {{{minLength}}}
|
||||||
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}"
|
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#maximum}}
|
{{#maximum}}
|
||||||
if {{{name}}} > {{{maximum}}}
|
if {{{name}}} > {{{maximum}}}
|
||||||
fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}"
|
fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than or equal to {{{maximum}}}."
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/maximum}}
|
{{/maximum}}
|
||||||
{{#minimum}}
|
{{#minimum}}
|
||||||
if {{{name}}} < {{{minimum}}}
|
if {{{name}}} < {{{minimum}}}
|
||||||
fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}"
|
fail ArgumentError, "invalid value for '{{{name}}}', must be greater than or equal to {{{minimum}}}."
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/minimum}}
|
{{/minimum}}
|
||||||
@{{{name}}} = {{{name}}}
|
@{{{name}}} = {{{name}}}
|
||||||
end
|
end
|
||||||
|
|
||||||
{{/needValidation}}
|
{{/hasValidation}}
|
||||||
{{/isEnum}}
|
{{/isEnum}}
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
|||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Package version: 1.0.0
|
- Package version: 1.0.0
|
||||||
- Build date: 2016-04-25T17:38:59.414+08:00
|
- Build date: 2016-04-25T19:16:37.992+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -45,6 +45,23 @@ module Petstore
|
|||||||
if attributes[:'className']
|
if attributes[:'className']
|
||||||
self.class_name = attributes[:'className']
|
self.class_name = attributes[:'className']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if @class_name.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -53,12 +53,27 @@ module Petstore
|
|||||||
if attributes[:'code']
|
if attributes[:'code']
|
||||||
self.code = attributes[:'code']
|
self.code = attributes[:'code']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'type']
|
if attributes[:'type']
|
||||||
self.type = attributes[:'type']
|
self.type = attributes[:'type']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'message']
|
if attributes[:'message']
|
||||||
self.message = attributes[:'message']
|
self.message = attributes[:'message']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -49,9 +49,27 @@ module Petstore
|
|||||||
if attributes[:'className']
|
if attributes[:'className']
|
||||||
self.class_name = attributes[:'className']
|
self.class_name = attributes[:'className']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'declawed']
|
if attributes[:'declawed']
|
||||||
self.declawed = attributes[:'declawed']
|
self.declawed = attributes[:'declawed']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if @class_name.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -49,9 +49,23 @@ module Petstore
|
|||||||
if attributes[:'id']
|
if attributes[:'id']
|
||||||
self.id = attributes[:'id']
|
self.id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'name']
|
if attributes[:'name']
|
||||||
self.name = attributes[:'name']
|
self.name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -49,9 +49,27 @@ module Petstore
|
|||||||
if attributes[:'className']
|
if attributes[:'className']
|
||||||
self.class_name = attributes[:'className']
|
self.class_name = attributes[:'className']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'breed']
|
if attributes[:'breed']
|
||||||
self.breed = attributes[:'breed']
|
self.breed = attributes[:'breed']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if @class_name.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -89,39 +89,127 @@ module Petstore
|
|||||||
if attributes[:'integer']
|
if attributes[:'integer']
|
||||||
self.integer = attributes[:'integer']
|
self.integer = attributes[:'integer']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'int32']
|
if attributes[:'int32']
|
||||||
self.int32 = attributes[:'int32']
|
self.int32 = attributes[:'int32']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'int64']
|
if attributes[:'int64']
|
||||||
self.int64 = attributes[:'int64']
|
self.int64 = attributes[:'int64']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'number']
|
if attributes[:'number']
|
||||||
self.number = attributes[:'number']
|
self.number = attributes[:'number']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'float']
|
if attributes[:'float']
|
||||||
self.float = attributes[:'float']
|
self.float = attributes[:'float']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'double']
|
if attributes[:'double']
|
||||||
self.double = attributes[:'double']
|
self.double = attributes[:'double']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'string']
|
if attributes[:'string']
|
||||||
self.string = attributes[:'string']
|
self.string = attributes[:'string']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'byte']
|
if attributes[:'byte']
|
||||||
self.byte = attributes[:'byte']
|
self.byte = attributes[:'byte']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'binary']
|
if attributes[:'binary']
|
||||||
self.binary = attributes[:'binary']
|
self.binary = attributes[:'binary']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'date']
|
if attributes[:'date']
|
||||||
self.date = attributes[:'date']
|
self.date = attributes[:'date']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'dateTime']
|
if attributes[:'dateTime']
|
||||||
self.date_time = attributes[:'dateTime']
|
self.date_time = attributes[:'dateTime']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'password']
|
if attributes[:'password']
|
||||||
self.password = attributes[:'password']
|
self.password = attributes[:'password']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if integer > 100.0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if integer < 10.0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if int32 > 200.0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if int32 < 20.0
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if @number.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if number > 543.2
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if number < 32.1
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if float > 987.6
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if float < 54.3
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if double > 123.4
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if double < 67.8
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if @byte.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if @date.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if @password.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if password.to_s.length > 64
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if password.to_s.length < 10
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Custom attribute writer method with validation
|
# Custom attribute writer method with validation
|
||||||
@ -132,11 +220,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if integer > 100.0
|
if integer > 100.0
|
||||||
fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0"
|
fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100.0."
|
||||||
end
|
end
|
||||||
|
|
||||||
if integer < 10.0
|
if integer < 10.0
|
||||||
fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0"
|
fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10.0."
|
||||||
end
|
end
|
||||||
|
|
||||||
@integer = integer
|
@integer = integer
|
||||||
@ -150,11 +238,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if int32 > 200.0
|
if int32 > 200.0
|
||||||
fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0"
|
fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200.0."
|
||||||
end
|
end
|
||||||
|
|
||||||
if int32 < 20.0
|
if int32 < 20.0
|
||||||
fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0"
|
fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20.0."
|
||||||
end
|
end
|
||||||
|
|
||||||
@int32 = int32
|
@int32 = int32
|
||||||
@ -168,11 +256,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if number > 543.2
|
if number > 543.2
|
||||||
fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2"
|
fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2."
|
||||||
end
|
end
|
||||||
|
|
||||||
if number < 32.1
|
if number < 32.1
|
||||||
fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1"
|
fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1."
|
||||||
end
|
end
|
||||||
|
|
||||||
@number = number
|
@number = number
|
||||||
@ -186,11 +274,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if float > 987.6
|
if float > 987.6
|
||||||
fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6"
|
fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6."
|
||||||
end
|
end
|
||||||
|
|
||||||
if float < 54.3
|
if float < 54.3
|
||||||
fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3"
|
fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3."
|
||||||
end
|
end
|
||||||
|
|
||||||
@float = float
|
@float = float
|
||||||
@ -204,11 +292,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if double > 123.4
|
if double > 123.4
|
||||||
fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4"
|
fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4."
|
||||||
end
|
end
|
||||||
|
|
||||||
if double < 67.8
|
if double < 67.8
|
||||||
fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8"
|
fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8."
|
||||||
end
|
end
|
||||||
|
|
||||||
@double = double
|
@double = double
|
||||||
@ -232,11 +320,11 @@ module Petstore
|
|||||||
end
|
end
|
||||||
|
|
||||||
if password.to_s.length > 64
|
if password.to_s.length > 64
|
||||||
fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64"
|
fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64."
|
||||||
end
|
end
|
||||||
|
|
||||||
if password.to_s.length < 10
|
if password.to_s.length < 10
|
||||||
fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10"
|
fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10."
|
||||||
end
|
end
|
||||||
|
|
||||||
@password = password
|
@password = password
|
||||||
|
@ -46,6 +46,19 @@ module Petstore
|
|||||||
if attributes[:'name']
|
if attributes[:'name']
|
||||||
self.name = attributes[:'name']
|
self.name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -46,6 +46,19 @@ module Petstore
|
|||||||
if attributes[:'return']
|
if attributes[:'return']
|
||||||
self._return = attributes[:'return']
|
self._return = attributes[:'return']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -54,12 +54,31 @@ module Petstore
|
|||||||
if attributes[:'name']
|
if attributes[:'name']
|
||||||
self.name = attributes[:'name']
|
self.name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'snake_case']
|
if attributes[:'snake_case']
|
||||||
self.snake_case = attributes[:'snake_case']
|
self.snake_case = attributes[:'snake_case']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'property']
|
if attributes[:'property']
|
||||||
self.property = attributes[:'property']
|
self.property = attributes[:'property']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if @name.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -66,23 +66,45 @@ module Petstore
|
|||||||
if attributes[:'id']
|
if attributes[:'id']
|
||||||
self.id = attributes[:'id']
|
self.id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'petId']
|
if attributes[:'petId']
|
||||||
self.pet_id = attributes[:'petId']
|
self.pet_id = attributes[:'petId']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'quantity']
|
if attributes[:'quantity']
|
||||||
self.quantity = attributes[:'quantity']
|
self.quantity = attributes[:'quantity']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'shipDate']
|
if attributes[:'shipDate']
|
||||||
self.ship_date = attributes[:'shipDate']
|
self.ship_date = attributes[:'shipDate']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'status']
|
if attributes[:'status']
|
||||||
self.status = attributes[:'status']
|
self.status = attributes[:'status']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'complete']
|
if attributes[:'complete']
|
||||||
self.complete = attributes[:'complete']
|
self.complete = attributes[:'complete']
|
||||||
else
|
else
|
||||||
self.complete = false
|
self.complete = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
allowed_values = ["placed", "approved", "delivered"]
|
||||||
|
if status && !allowed_values.include?(status)
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Custom attribute writer method checking allowed values (enum).
|
# Custom attribute writer method checking allowed values (enum).
|
||||||
@ -90,7 +112,7 @@ module Petstore
|
|||||||
def status=(status)
|
def status=(status)
|
||||||
allowed_values = ["placed", "approved", "delivered"]
|
allowed_values = ["placed", "approved", "delivered"]
|
||||||
if status && !allowed_values.include?(status)
|
if status && !allowed_values.include?(status)
|
||||||
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}"
|
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}."
|
||||||
end
|
end
|
||||||
@status = status
|
@status = status
|
||||||
end
|
end
|
||||||
|
@ -66,25 +66,55 @@ module Petstore
|
|||||||
if attributes[:'id']
|
if attributes[:'id']
|
||||||
self.id = attributes[:'id']
|
self.id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'category']
|
if attributes[:'category']
|
||||||
self.category = attributes[:'category']
|
self.category = attributes[:'category']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'name']
|
if attributes[:'name']
|
||||||
self.name = attributes[:'name']
|
self.name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'photoUrls']
|
if attributes[:'photoUrls']
|
||||||
if (value = attributes[:'photoUrls']).is_a?(Array)
|
if (value = attributes[:'photoUrls']).is_a?(Array)
|
||||||
self.photo_urls = value
|
self.photo_urls = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'tags']
|
if attributes[:'tags']
|
||||||
if (value = attributes[:'tags']).is_a?(Array)
|
if (value = attributes[:'tags']).is_a?(Array)
|
||||||
self.tags = value
|
self.tags = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'status']
|
if attributes[:'status']
|
||||||
self.status = attributes[:'status']
|
self.status = attributes[:'status']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
|
if @name.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if @photo_urls.nil?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
allowed_values = ["available", "pending", "sold"]
|
||||||
|
if status && !allowed_values.include?(status)
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Custom attribute writer method checking allowed values (enum).
|
# Custom attribute writer method checking allowed values (enum).
|
||||||
@ -92,7 +122,7 @@ module Petstore
|
|||||||
def status=(status)
|
def status=(status)
|
||||||
allowed_values = ["available", "pending", "sold"]
|
allowed_values = ["available", "pending", "sold"]
|
||||||
if status && !allowed_values.include?(status)
|
if status && !allowed_values.include?(status)
|
||||||
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}"
|
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}."
|
||||||
end
|
end
|
||||||
@status = status
|
@status = status
|
||||||
end
|
end
|
||||||
|
@ -45,6 +45,19 @@ module Petstore
|
|||||||
if attributes[:'$special[property.name]']
|
if attributes[:'$special[property.name]']
|
||||||
self.special_property_name = attributes[:'$special[property.name]']
|
self.special_property_name = attributes[:'$special[property.name]']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -49,9 +49,23 @@ module Petstore
|
|||||||
if attributes[:'id']
|
if attributes[:'id']
|
||||||
self.id = attributes[:'id']
|
self.id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'name']
|
if attributes[:'name']
|
||||||
self.name = attributes[:'name']
|
self.name = attributes[:'name']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
@ -74,27 +74,47 @@ module Petstore
|
|||||||
if attributes[:'id']
|
if attributes[:'id']
|
||||||
self.id = attributes[:'id']
|
self.id = attributes[:'id']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'username']
|
if attributes[:'username']
|
||||||
self.username = attributes[:'username']
|
self.username = attributes[:'username']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'firstName']
|
if attributes[:'firstName']
|
||||||
self.first_name = attributes[:'firstName']
|
self.first_name = attributes[:'firstName']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'lastName']
|
if attributes[:'lastName']
|
||||||
self.last_name = attributes[:'lastName']
|
self.last_name = attributes[:'lastName']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'email']
|
if attributes[:'email']
|
||||||
self.email = attributes[:'email']
|
self.email = attributes[:'email']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'password']
|
if attributes[:'password']
|
||||||
self.password = attributes[:'password']
|
self.password = attributes[:'password']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'phone']
|
if attributes[:'phone']
|
||||||
self.phone = attributes[:'phone']
|
self.phone = attributes[:'phone']
|
||||||
end
|
end
|
||||||
|
|
||||||
if attributes[:'userStatus']
|
if attributes[:'userStatus']
|
||||||
self.user_status = attributes[:'userStatus']
|
self.user_status = attributes[:'userStatus']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Show invalid properties with the reasons. Usually used together with valid?
|
||||||
|
# @return Array for valid properies with the reasons
|
||||||
|
def list_invalid_properties
|
||||||
|
invalid_properties = Array.new
|
||||||
|
return invalid_properties
|
||||||
|
end
|
||||||
|
|
||||||
|
# Check to see if the all the properties in the model are valid
|
||||||
|
# @return true if the model is valid
|
||||||
|
def valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks equality by comparing each attribute.
|
# Checks equality by comparing each attribute.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user