Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module {{moduleName}}
@api_client.config.logger.debug 'Calling API: {{classname}}.{{operationId}} ...'
end
{{#allParams}}
{{^isNullable}}
{{#required}}
# verify the required parameter '{{paramName}}' is set
if @api_client.config.client_side_validation && {{{paramName}}}.nil?
Expand All @@ -57,6 +58,7 @@ module {{moduleName}}
{{/isContainer}}
{{/isEnum}}
{{/required}}
{{/isNullable}}
{{^required}}
{{#isEnum}}
{{#collectionFormat}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@
def list_invalid_properties
invalid_properties = Array.new
{{#vars}}
{{^isNullable}}
{{#required}}
if @{{{name}}}.nil?
invalid_properties.push('invalid value for "{{{name}}}", {{{name}}} cannot be nil.')
end

{{/required}}
{{/isNullable}}
{{#hasValidation}}
{{#maxLength}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
Expand Down Expand Up @@ -145,9 +147,11 @@
# @return true if the model is valid
def valid?
{{#vars}}
{{^isNullable}}
{{#required}}
return false if @{{{name}}}.nil?
{{/required}}
{{/isNullable}}
{{#isEnum}}
{{^isContainer}}
{{{name}}}_validator = EnumAttributeValidator.new('{{{dataType}}}', [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
Expand Down Expand Up @@ -201,12 +205,14 @@
# Custom attribute writer method with validation
# @param [Object] {{{name}}} Value to be assigned
def {{{name}}}=({{{name}}})
{{^isNullable}}
{{#required}}
if {{{name}}}.nil?
fail ArgumentError, '{{{name}}} cannot be nil'
end

{{/required}}
{{/isNullable}}
{{#maxLength}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}}
fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.'
Expand Down