mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
fix index check, add test cases (#1993)
This commit is contained in:
parent
c438f67b66
commit
9029103c94
@ -261,8 +261,8 @@ module {{moduleName}}
|
||||
servers = server_settings
|
||||
|
||||
# check array index out of bound
|
||||
if (index < 0 || index > servers.size)
|
||||
fail ArgumentError "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
if (index < 0 || index >= servers.size)
|
||||
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
end
|
||||
|
||||
server = servers[index]
|
||||
|
@ -245,8 +245,8 @@ module Petstore
|
||||
servers = server_settings
|
||||
|
||||
# check array index out of bound
|
||||
if (index < 0 || index > servers.size)
|
||||
fail ArgumentError "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
if (index < 0 || index >= servers.size)
|
||||
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
end
|
||||
|
||||
server = servers[index]
|
||||
|
@ -278,8 +278,8 @@ module Petstore
|
||||
servers = server_settings
|
||||
|
||||
# check array index out of bound
|
||||
if (index < 0 || index > servers.size)
|
||||
fail ArgumentError "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
if (index < 0 || index >= servers.size)
|
||||
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
end
|
||||
|
||||
server = servers[index]
|
||||
|
@ -51,5 +51,9 @@ describe Petstore::Configuration do
|
||||
it 'should raise error due to invalid enum value' do
|
||||
expect{config.server_url(1, version: "v6")}.to raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it 'should raise error due to invalid index' do
|
||||
expect{config.server_url(2)}.to raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user