Skip to content

Commit 0a4fc6a

Browse files
committed
update ruby petstore sample
1 parent a717aba commit 0a4fc6a

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ class PetApi
44
basePath = "http://petstore.swagger.io/v2"
55
# apiInvoker = APIInvoker
66

7-
def self.escapeString(string)
8-
URI.encode(string.to_s)
9-
end
10-
117

128
# Update an existing pet
139
#
@@ -266,7 +262,7 @@ def self.getPetById (pet_id, opts={})
266262
}.merge(opts)
267263

268264
#resource path
269-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
265+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
270266

271267

272268
# pull querystring keys from options
@@ -321,7 +317,7 @@ def self.updatePetWithForm (pet_id, name, status, opts={})
321317
}.merge(opts)
322318

323319
#resource path
324-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
320+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
325321

326322

327323
# pull querystring keys from options
@@ -375,7 +371,7 @@ def self.deletePet (api_key, pet_id, opts={})
375371
}.merge(opts)
376372

377373
#resource path
378-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
374+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
379375

380376

381377
# pull querystring keys from options
@@ -429,7 +425,7 @@ def self.uploadFile (pet_id, additional_metadata, file, opts={})
429425
}.merge(opts)
430426

431427
#resource path
432-
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
428+
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
433429

434430

435431
# pull querystring keys from options

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ class StoreApi
44
basePath = "http://petstore.swagger.io/v2"
55
# apiInvoker = APIInvoker
66

7-
def self.escapeString(string)
8-
URI.encode(string.to_s)
9-
end
10-
117

128
# Returns pet inventories by status
139
# Returns a map of status codes to quantities
@@ -145,7 +141,7 @@ def self.getOrderById (order_id, opts={})
145141
}.merge(opts)
146142

147143
#resource path
148-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
144+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
149145

150146

151147
# pull querystring keys from options
@@ -196,7 +192,7 @@ def self.deleteOrder (order_id, opts={})
196192
}.merge(opts)
197193

198194
#resource path
199-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
195+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
200196

201197

202198
# pull querystring keys from options

samples/client/petstore/ruby/lib/swagger/request.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ def url(options = {})
7474
def interpreted_path
7575
p = self.path.dup
7676

77-
# Fill in the path params
78-
self.params.each_pair do |key, value|
79-
p = p.gsub("{#{key}}", value.to_s)
80-
end
81-
8277
# Stick a .{format} placeholder into the path if there isn't
8378
# one already or an actual format like json or xml
8479
# e.g. /words/blah => /words.{format}/blah

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ class UserApi
44
basePath = "http://petstore.swagger.io/v2"
55
# apiInvoker = APIInvoker
66

7-
def self.escapeString(string)
8-
URI.encode(string.to_s)
9-
end
10-
117

128
# Create user
139
# This can only be done by the logged in user.
@@ -332,7 +328,7 @@ def self.getUserByName (username, opts={})
332328
}.merge(opts)
333329

334330
#resource path
335-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
331+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
336332

337333

338334
# pull querystring keys from options
@@ -385,7 +381,7 @@ def self.updateUser (username, body, opts={})
385381
}.merge(opts)
386382

387383
#resource path
388-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
384+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
389385

390386

391387
# pull querystring keys from options
@@ -455,7 +451,7 @@ def self.deleteUser (username, opts={})
455451
}.merge(opts)
456452

457453
#resource path
458-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
454+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
459455

460456

461457
# pull querystring keys from options

0 commit comments

Comments
 (0)