Skip to content

Commit 40d512f

Browse files
committed
fix test cases
1 parent e73957e commit 40d512f

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

modules/swagger-codegen/src/main/resources/ruby/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class {{classname}}
2929
}.merge(opts)
3030

3131
#resource path
32-
path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}})
32+
path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s)
3333
{{/pathParams}}{{newline}}
3434

3535
# pull querystring keys from options

samples/client/petstore/ruby/lib/pet_api.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def self.getPetById (pet_id, opts={})
225225
}.merge(opts)
226226

227227
#resource path
228-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
228+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
229229

230230

231231
# pull querystring keys from options
@@ -271,7 +271,7 @@ def self.updatePetWithForm (pet_id, name, status, opts={})
271271
}.merge(opts)
272272

273273
#resource path
274-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
274+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
275275

276276

277277
# pull querystring keys from options
@@ -316,7 +316,7 @@ def self.deletePet (api_key, pet_id, opts={})
316316
}.merge(opts)
317317

318318
#resource path
319-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
319+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
320320

321321

322322
# pull querystring keys from options
@@ -361,7 +361,7 @@ def self.uploadFile (pet_id, additional_metadata, file, opts={})
361361
}.merge(opts)
362362

363363
#resource path
364-
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
364+
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
365365

366366

367367
# pull querystring keys from options

samples/client/petstore/ruby/lib/store_api.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def self.getOrderById (order_id, opts={})
122122
}.merge(opts)
123123

124124
#resource path
125-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
125+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
126126

127127

128128
# pull querystring keys from options
@@ -164,7 +164,7 @@ def self.deleteOrder (order_id, opts={})
164164
}.merge(opts)
165165

166166
#resource path
167-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
167+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
168168

169169

170170
# pull querystring keys from options

samples/client/petstore/ruby/lib/user_api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def self.getUserByName (username, opts={})
282282
}.merge(opts)
283283

284284
#resource path
285-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
285+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
286286

287287

288288
# pull querystring keys from options
@@ -326,7 +326,7 @@ def self.updateUser (username, body, opts={})
326326
}.merge(opts)
327327

328328
#resource path
329-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
329+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
330330

331331

332332
# pull querystring keys from options
@@ -387,7 +387,7 @@ def self.deleteUser (username, opts={})
387387
}.merge(opts)
388388

389389
#resource path
390-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
390+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
391391

392392

393393
# pull querystring keys from options

samples/client/petstore/ruby/spec/request_spec.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,18 @@
7373
describe "path" do
7474

7575
it "accounts for a total absence of format in the path string" do
76-
@request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({
76+
@request = Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
7777
:format => "xml",
7878
:params => {
79-
:word => "cat"
8079
}
8180
}))
8281
@request.url.should == "http://petstore.swagger.io/v2/word.xml/cat/entries"
8382
end
8483

85-
it "does string substitution on path params" do
86-
@request = Swagger::Request.new(:get, "/word.{format}/{word}/entries", @default_params.merge({
84+
it "does string substitution (format) on path params" do
85+
@request = Swagger::Request.new(:get, "/word.{format}/cat/entries", @default_params.merge({
8786
:format => "xml",
8887
:params => {
89-
:word => "cat"
9088
}
9189
}))
9290
@request.url.should == "http://petstore.swagger.io/v2/word.xml/cat/entries"
@@ -123,7 +121,7 @@
123121
end
124122

125123
it "URI encodes the path" do
126-
@request = Swagger::Request.new(:get, "word.{format}/{word}/definitions", @default_params.merge({
124+
@request = Swagger::Request.new(:get, "word.{format}/bill gates/definitions", @default_params.merge({
127125
:params => {
128126
:word => "bill gates"
129127
}
@@ -200,4 +198,4 @@
200198

201199
end
202200

203-
end
201+
end

0 commit comments

Comments
 (0)