Skip to content

Commit e73957e

Browse files
committed
update ruby petstore sample
1 parent b773d40 commit e73957e

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
#
@@ -229,7 +225,7 @@ def self.getPetById (pet_id, opts={})
229225
}.merge(opts)
230226

231227
#resource path
232-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
228+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
233229

234230

235231
# pull querystring keys from options
@@ -275,7 +271,7 @@ def self.updatePetWithForm (pet_id, name, status, opts={})
275271
}.merge(opts)
276272

277273
#resource path
278-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
274+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
279275

280276

281277
# pull querystring keys from options
@@ -320,7 +316,7 @@ def self.deletePet (api_key, pet_id, opts={})
320316
}.merge(opts)
321317

322318
#resource path
323-
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
319+
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
324320

325321

326322
# pull querystring keys from options
@@ -365,7 +361,7 @@ def self.uploadFile (pet_id, additional_metadata, file, opts={})
365361
}.merge(opts)
366362

367363
#resource path
368-
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
364+
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id)
369365

370366

371367
# 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
@@ -126,7 +122,7 @@ def self.getOrderById (order_id, opts={})
126122
}.merge(opts)
127123

128124
#resource path
129-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
125+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
130126

131127

132128
# pull querystring keys from options
@@ -168,7 +164,7 @@ def self.deleteOrder (order_id, opts={})
168164
}.merge(opts)
169165

170166
#resource path
171-
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
167+
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id)
172168

173169

174170
# 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.
@@ -286,7 +282,7 @@ def self.getUserByName (username, opts={})
286282
}.merge(opts)
287283

288284
#resource path
289-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
285+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
290286

291287

292288
# pull querystring keys from options
@@ -330,7 +326,7 @@ def self.updateUser (username, body, opts={})
330326
}.merge(opts)
331327

332328
#resource path
333-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
329+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
334330

335331

336332
# pull querystring keys from options
@@ -391,7 +387,7 @@ def self.deleteUser (username, opts={})
391387
}.merge(opts)
392388

393389
#resource path
394-
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
390+
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username)
395391

396392

397393
# pull querystring keys from options

0 commit comments

Comments
 (0)