forked from loafle/openapi-generator-original
use ArgumentError in ruby model
This commit is contained in:
parent
ab986a7228
commit
3c36f1df37
@ -55,7 +55,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
def {{{name}}}=({{{name}}})
|
||||
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
||||
if {{{name}}} && !allowed_values.include?({{{name}}})
|
||||
fail "invalid value for '{{{name}}}', must be one of #{allowed_values}"
|
||||
fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{allowed_values}"
|
||||
end
|
||||
@{{{name}}} = {{{name}}}
|
||||
end
|
||||
@ -67,30 +67,30 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
||||
# @param [Object] {{{name}}} Value to be assigned
|
||||
def {{{name}}}=({{{name}}})
|
||||
if {{{name}}}.nil?
|
||||
fail "{{{name}}} cannot be nil"
|
||||
fail ArgumentError, "{{{name}}} cannot be nil"
|
||||
end
|
||||
|
||||
{{#minLength}}
|
||||
if {{{name}}}.to_s.length > {{{maxLength}}}
|
||||
fail "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
|
||||
|
||||
{{/minLength}}
|
||||
{{#maxLength}}
|
||||
if {{{name}}}.to_s.length < {{{minLength}}}
|
||||
fail "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
|
||||
|
||||
{{/maxLength}}
|
||||
{{#maximum}}
|
||||
if {{{name}}} > {{{maximum}}}
|
||||
fail "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
|
||||
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
if {{{name}}} < {{{minimum}}}
|
||||
fail "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
|
||||
|
||||
{{/minimum}}
|
||||
|
@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build date: 2016-04-25T17:21:35.959+08:00
|
||||
- Build date: 2016-04-25T17:38:59.414+08:00
|
||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||
|
||||
## Installation
|
||||
|
@ -128,15 +128,15 @@ module Petstore
|
||||
# @param [Object] integer Value to be assigned
|
||||
def integer=(integer)
|
||||
if integer.nil?
|
||||
fail "integer cannot be nil"
|
||||
fail ArgumentError, "integer cannot be nil"
|
||||
end
|
||||
|
||||
if integer > 100.0
|
||||
fail "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
|
||||
|
||||
if integer < 10.0
|
||||
fail "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
|
||||
|
||||
@integer = integer
|
||||
@ -146,15 +146,15 @@ module Petstore
|
||||
# @param [Object] int32 Value to be assigned
|
||||
def int32=(int32)
|
||||
if int32.nil?
|
||||
fail "int32 cannot be nil"
|
||||
fail ArgumentError, "int32 cannot be nil"
|
||||
end
|
||||
|
||||
if int32 > 200.0
|
||||
fail "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
|
||||
|
||||
if int32 < 20.0
|
||||
fail "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
|
||||
|
||||
@int32 = int32
|
||||
@ -164,15 +164,15 @@ module Petstore
|
||||
# @param [Object] number Value to be assigned
|
||||
def number=(number)
|
||||
if number.nil?
|
||||
fail "number cannot be nil"
|
||||
fail ArgumentError, "number cannot be nil"
|
||||
end
|
||||
|
||||
if number > 543.2
|
||||
fail "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
|
||||
|
||||
if number < 32.1
|
||||
fail "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
|
||||
|
||||
@number = number
|
||||
@ -182,15 +182,15 @@ module Petstore
|
||||
# @param [Object] float Value to be assigned
|
||||
def float=(float)
|
||||
if float.nil?
|
||||
fail "float cannot be nil"
|
||||
fail ArgumentError, "float cannot be nil"
|
||||
end
|
||||
|
||||
if float > 987.6
|
||||
fail "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
|
||||
|
||||
if float < 54.3
|
||||
fail "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
|
||||
|
||||
@float = float
|
||||
@ -200,15 +200,15 @@ module Petstore
|
||||
# @param [Object] double Value to be assigned
|
||||
def double=(double)
|
||||
if double.nil?
|
||||
fail "double cannot be nil"
|
||||
fail ArgumentError, "double cannot be nil"
|
||||
end
|
||||
|
||||
if double > 123.4
|
||||
fail "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
|
||||
|
||||
if double < 67.8
|
||||
fail "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
|
||||
|
||||
@double = double
|
||||
@ -218,7 +218,7 @@ module Petstore
|
||||
# @param [Object] string Value to be assigned
|
||||
def string=(string)
|
||||
if string.nil?
|
||||
fail "string cannot be nil"
|
||||
fail ArgumentError, "string cannot be nil"
|
||||
end
|
||||
|
||||
@string = string
|
||||
@ -228,15 +228,15 @@ module Petstore
|
||||
# @param [Object] password Value to be assigned
|
||||
def password=(password)
|
||||
if password.nil?
|
||||
fail "password cannot be nil"
|
||||
fail ArgumentError, "password cannot be nil"
|
||||
end
|
||||
|
||||
if password.to_s.length > 64
|
||||
fail "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
|
||||
|
||||
if password.to_s.length < 10
|
||||
fail "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
|
||||
|
||||
@password = password
|
||||
|
@ -90,7 +90,7 @@ module Petstore
|
||||
def status=(status)
|
||||
allowed_values = ["placed", "approved", "delivered"]
|
||||
if status && !allowed_values.include?(status)
|
||||
fail "invalid value for 'status', must be one of #{allowed_values}"
|
||||
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}"
|
||||
end
|
||||
@status = status
|
||||
end
|
||||
|
@ -92,7 +92,7 @@ module Petstore
|
||||
def status=(status)
|
||||
allowed_values = ["available", "pending", "sold"]
|
||||
if status && !allowed_values.include?(status)
|
||||
fail "invalid value for 'status', must be one of #{allowed_values}"
|
||||
fail ArgumentError, "invalid value for 'status', must be one of #{allowed_values}"
|
||||
end
|
||||
@status = status
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user