fix the model's valid? of Ruby client to prevent runtime error (#3670) (#3671)

This commit is contained in:
Akira Tanimura 2019-08-19 14:31:34 +09:00 committed by William Cheng
parent 589e5c6312
commit 1a6d3671d9

View File

@ -246,14 +246,14 @@
{{#anyOf}} {{#anyOf}}
{{#-first}} {{#-first}}
_any_of_found = false _any_of_found = false
openapi_any_of.each do |_class| self.class.openapi_any_of.each do |_class|
_any_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash) _any_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
if _any_of.valid? if _any_of.valid?
_any_of_found = true _any_of_found = true
end end
end end
if !_any_of_found? if !_any_of_found
return false return false
end end
@ -262,10 +262,10 @@
{{#oneOf}} {{#oneOf}}
{{#-first}} {{#-first}}
_one_of_found = false _one_of_found = false
openapi_one_of.each do |_class| self.class.openapi_one_of.each do |_class|
_one_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash) _one_of = {{moduleName}}.const_get(_class).build_from_hash(self.to_hash)
if _one_of.valid? if _one_of.valid?
if _one_of_found? if _one_of_found
return false return false
else else
_one_of_found = true _one_of_found = true
@ -273,7 +273,7 @@
end end
end end
if !_one_of_found? if !_one_of_found
return false return false
end end