mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
[ruby] Validate array correctly
It never throws error with any values in array. Every element should be validated against the enum.
This commit is contained in:
parent
c2ca59e677
commit
af4b32178f
@ -50,9 +50,16 @@ module {{moduleName}}
|
||||
{{/required}}
|
||||
{{^required}}
|
||||
{{#isEnum}}
|
||||
{{#collectionFormat}}
|
||||
if opts[:'{{{paramName}}}'] && !opts[:'{{{paramName}}}'].all?{|item| [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(item)}
|
||||
fail ArgumentError, 'invalid value for "{{{paramName}}}", must include one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}'
|
||||
end
|
||||
{{/collectionFormat}}
|
||||
{{^collectionFormat}}
|
||||
if opts[:'{{{paramName}}}'] && ![{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(opts[:'{{{paramName}}}'])
|
||||
fail ArgumentError, 'invalid value for "{{{paramName}}}", must be one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}'
|
||||
end
|
||||
{{/collectionFormat}}
|
||||
{{/isEnum}}
|
||||
{{/required}}
|
||||
{{#hasValidation}}
|
||||
|
@ -275,20 +275,20 @@ module Petstore
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "Calling API: FakeApi.test_enum_parameters ..."
|
||||
end
|
||||
if opts[:'enum_form_string_array'] && !['>', '$'].include?(opts[:'enum_form_string_array'])
|
||||
fail ArgumentError, 'invalid value for "enum_form_string_array", must be one of >, $'
|
||||
if opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all?{|item| ['>', '$'].include?(item)}
|
||||
fail ArgumentError, 'invalid value for "enum_form_string_array", must include one of >, $'
|
||||
end
|
||||
if opts[:'enum_form_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_form_string'])
|
||||
fail ArgumentError, 'invalid value for "enum_form_string", must be one of _abc, -efg, (xyz)'
|
||||
end
|
||||
if opts[:'enum_header_string_array'] && !['>', '$'].include?(opts[:'enum_header_string_array'])
|
||||
fail ArgumentError, 'invalid value for "enum_header_string_array", must be one of >, $'
|
||||
if opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all?{|item| ['>', '$'].include?(item)}
|
||||
fail ArgumentError, 'invalid value for "enum_header_string_array", must include one of >, $'
|
||||
end
|
||||
if opts[:'enum_header_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_header_string'])
|
||||
fail ArgumentError, 'invalid value for "enum_header_string", must be one of _abc, -efg, (xyz)'
|
||||
end
|
||||
if opts[:'enum_query_string_array'] && !['>', '$'].include?(opts[:'enum_query_string_array'])
|
||||
fail ArgumentError, 'invalid value for "enum_query_string_array", must be one of >, $'
|
||||
if opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all?{|item| ['>', '$'].include?(item)}
|
||||
fail ArgumentError, 'invalid value for "enum_query_string_array", must include one of >, $'
|
||||
end
|
||||
if opts[:'enum_query_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_query_string'])
|
||||
fail ArgumentError, 'invalid value for "enum_query_string", must be one of _abc, -efg, (xyz)'
|
||||
|
Loading…
Reference in New Issue
Block a user