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}}})
|
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 "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
|
||||||
@ -67,30 +67,30 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
|
|||||||
# @param [Object] {{{name}}} Value to be assigned
|
# @param [Object] {{{name}}} Value to be assigned
|
||||||
def {{{name}}}=({{{name}}})
|
def {{{name}}}=({{{name}}})
|
||||||
if {{{name}}}.nil?
|
if {{{name}}}.nil?
|
||||||
fail "{{{name}}} cannot be nil"
|
fail ArgumentError, "{{{name}}} cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
{{#minLength}}
|
{{#minLength}}
|
||||||
if {{{name}}}.to_s.length > {{{maxLength}}}
|
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
|
end
|
||||||
|
|
||||||
{{/minLength}}
|
{{/minLength}}
|
||||||
{{#maxLength}}
|
{{#maxLength}}
|
||||||
if {{{name}}}.to_s.length < {{{minLength}}}
|
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
|
end
|
||||||
|
|
||||||
{{/maxLength}}
|
{{/maxLength}}
|
||||||
{{#maximum}}
|
{{#maximum}}
|
||||||
if {{{name}}} > {{{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
|
end
|
||||||
|
|
||||||
{{/maximum}}
|
{{/maximum}}
|
||||||
{{#minimum}}
|
{{#minimum}}
|
||||||
if {{{name}}} < {{{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
|
end
|
||||||
|
|
||||||
{{/minimum}}
|
{{/minimum}}
|
||||||
|
@ -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:21:35.959+08:00
|
- Build date: 2016-04-25T17:38:59.414+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -128,15 +128,15 @@ module Petstore
|
|||||||
# @param [Object] integer Value to be assigned
|
# @param [Object] integer Value to be assigned
|
||||||
def integer=(integer)
|
def integer=(integer)
|
||||||
if integer.nil?
|
if integer.nil?
|
||||||
fail "integer cannot be nil"
|
fail ArgumentError, "integer cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if integer > 100.0
|
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
|
end
|
||||||
|
|
||||||
if integer < 10.0
|
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
|
end
|
||||||
|
|
||||||
@integer = integer
|
@integer = integer
|
||||||
@ -146,15 +146,15 @@ module Petstore
|
|||||||
# @param [Object] int32 Value to be assigned
|
# @param [Object] int32 Value to be assigned
|
||||||
def int32=(int32)
|
def int32=(int32)
|
||||||
if int32.nil?
|
if int32.nil?
|
||||||
fail "int32 cannot be nil"
|
fail ArgumentError, "int32 cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if int32 > 200.0
|
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
|
end
|
||||||
|
|
||||||
if int32 < 20.0
|
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
|
end
|
||||||
|
|
||||||
@int32 = int32
|
@int32 = int32
|
||||||
@ -164,15 +164,15 @@ module Petstore
|
|||||||
# @param [Object] number Value to be assigned
|
# @param [Object] number Value to be assigned
|
||||||
def number=(number)
|
def number=(number)
|
||||||
if number.nil?
|
if number.nil?
|
||||||
fail "number cannot be nil"
|
fail ArgumentError, "number cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if number > 543.2
|
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
|
end
|
||||||
|
|
||||||
if number < 32.1
|
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
|
end
|
||||||
|
|
||||||
@number = number
|
@number = number
|
||||||
@ -182,15 +182,15 @@ module Petstore
|
|||||||
# @param [Object] float Value to be assigned
|
# @param [Object] float Value to be assigned
|
||||||
def float=(float)
|
def float=(float)
|
||||||
if float.nil?
|
if float.nil?
|
||||||
fail "float cannot be nil"
|
fail ArgumentError, "float cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if float > 987.6
|
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
|
end
|
||||||
|
|
||||||
if float < 54.3
|
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
|
end
|
||||||
|
|
||||||
@float = float
|
@float = float
|
||||||
@ -200,15 +200,15 @@ module Petstore
|
|||||||
# @param [Object] double Value to be assigned
|
# @param [Object] double Value to be assigned
|
||||||
def double=(double)
|
def double=(double)
|
||||||
if double.nil?
|
if double.nil?
|
||||||
fail "double cannot be nil"
|
fail ArgumentError, "double cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if double > 123.4
|
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
|
end
|
||||||
|
|
||||||
if double < 67.8
|
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
|
end
|
||||||
|
|
||||||
@double = double
|
@double = double
|
||||||
@ -218,7 +218,7 @@ module Petstore
|
|||||||
# @param [Object] string Value to be assigned
|
# @param [Object] string Value to be assigned
|
||||||
def string=(string)
|
def string=(string)
|
||||||
if string.nil?
|
if string.nil?
|
||||||
fail "string cannot be nil"
|
fail ArgumentError, "string cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
@string = string
|
@string = string
|
||||||
@ -228,15 +228,15 @@ module Petstore
|
|||||||
# @param [Object] password Value to be assigned
|
# @param [Object] password Value to be assigned
|
||||||
def password=(password)
|
def password=(password)
|
||||||
if password.nil?
|
if password.nil?
|
||||||
fail "password cannot be nil"
|
fail ArgumentError, "password cannot be nil"
|
||||||
end
|
end
|
||||||
|
|
||||||
if password.to_s.length > 64
|
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
|
end
|
||||||
|
|
||||||
if password.to_s.length < 10
|
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
|
end
|
||||||
|
|
||||||
@password = password
|
@password = password
|
||||||
|
@ -90,7 +90,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 "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
|
||||||
|
@ -92,7 +92,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 "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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user