Skip to content

Commit 2cc9b10

Browse files
committed
Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0
2 parents f3ab28b + 15c25c8 commit 2cc9b10

File tree

7 files changed

+213
-25
lines changed

7 files changed

+213
-25
lines changed

modules/swagger-codegen/src/main/resources/python/swagger.mustache

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ class ApiClient(object):
3434
self.host = host
3535
self.cookie = None
3636
self.boundary = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(30))
37+
# Set default User-Agent.
38+
self.user_agent = 'Python-Swagger'
39+
40+
@property
41+
def user_agent(self):
42+
return self.defaultHeaders['User-Agent']
43+
44+
@user_agent.setter
45+
def user_agent(self, value):
46+
self.defaultHeaders['User-Agent'] = value
3747

3848
def setDefaultHeader(self, headerName, headerValue):
3949
self.defaultHeaders[headerName] = headerValue

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,16 @@ class {{classname}}
4141
query_param_keys.include? key
4242
end
4343

44-
# header parameters, if any
44+
# header parameters
4545
headers = {}
46+
47+
_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}'
48+
if _header_accept != ''
49+
headerParams['Accept'] = _header_accept
50+
end
51+
_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
52+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
53+
4654
{{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}}
4755
{{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}}
4856
# http body (model)

samples/client/petstore/python/client/PetApi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def updatePet(self, **kwargs):
6363
bodyParam = None
6464

6565
headerParams['Accept'] = 'application/json,application/xml'
66-
headerParams['Content-Type'] = 'application/json,application/xml'
66+
headerParams['Content-Type'] = 'application/json,application/xml,'
6767

6868

6969

@@ -119,7 +119,7 @@ def addPet(self, **kwargs):
119119
bodyParam = None
120120

121121
headerParams['Accept'] = 'application/json,application/xml'
122-
headerParams['Content-Type'] = 'application/json,application/xml'
122+
headerParams['Content-Type'] = 'application/json,application/xml,'
123123

124124

125125

@@ -370,7 +370,7 @@ def updatePetWithForm(self, **kwargs):
370370
bodyParam = None
371371

372372
headerParams['Accept'] = 'application/json,application/xml'
373-
headerParams['Content-Type'] = 'application/x-www-form-urlencoded'
373+
headerParams['Content-Type'] = 'application/x-www-form-urlencoded,'
374374

375375

376376

@@ -506,7 +506,7 @@ def uploadFile(self, **kwargs):
506506
bodyParam = None
507507

508508
headerParams['Accept'] = 'application/json,application/xml'
509-
headerParams['Content-Type'] = 'multipart/form-data'
509+
headerParams['Content-Type'] = 'multipart/form-data,'
510510

511511

512512

samples/client/petstore/python/client/swagger.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ def __init__(self, host=None, headerName=None, headerValue=None):
3434
self.host = host
3535
self.cookie = None
3636
self.boundary = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(30))
37+
# Set default User-Agent.
38+
self.user_agent = 'Python-Swagger'
39+
40+
@property
41+
def user_agent(self):
42+
return self.defaultHeaders['User-Agent']
43+
44+
@user_agent.setter
45+
def user_agent(self, value):
46+
self.defaultHeaders['User-Agent'] = value
3747

3848
def setDefaultHeader(self, headerName, headerValue):
3949
self.defaultHeaders[headerName] = headerValue

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

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ def self.updatePet (body, opts={})
3232
query_param_keys.include? key
3333
end
3434

35-
# header parameters, if any
35+
# header parameters
3636
headers = {}
37+
38+
_header_accept = 'application/json, application/xml'
39+
if _header_accept != ''
40+
headerParams['Accept'] = _header_accept
41+
end
42+
_header_content_type = ['application/json', 'application/xml', ]
43+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
44+
3745

3846

3947
# http body (model)
@@ -92,8 +100,16 @@ def self.addPet (body, opts={})
92100
query_param_keys.include? key
93101
end
94102

95-
# header parameters, if any
103+
# header parameters
96104
headers = {}
105+
106+
_header_accept = 'application/json, application/xml'
107+
if _header_accept != ''
108+
headerParams['Accept'] = _header_accept
109+
end
110+
_header_content_type = ['application/json', 'application/xml', ]
111+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
112+
97113

98114

99115
# http body (model)
@@ -152,8 +168,16 @@ def self.findPetsByStatus (status, opts={})
152168
query_param_keys.include? key
153169
end
154170

155-
# header parameters, if any
171+
# header parameters
156172
headers = {}
173+
174+
_header_accept = 'application/json, application/xml'
175+
if _header_accept != ''
176+
headerParams['Accept'] = _header_accept
177+
end
178+
_header_content_type = []
179+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
180+
157181

158182

159183
# http body (model)
@@ -194,8 +218,16 @@ def self.findPetsByTags (tags, opts={})
194218
query_param_keys.include? key
195219
end
196220

197-
# header parameters, if any
221+
# header parameters
198222
headers = {}
223+
224+
_header_accept = 'application/json, application/xml'
225+
if _header_accept != ''
226+
headerParams['Accept'] = _header_accept
227+
end
228+
_header_content_type = []
229+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
230+
199231

200232

201233
# http body (model)
@@ -237,8 +269,16 @@ def self.getPetById (pet_id, opts={})
237269
query_param_keys.include? key
238270
end
239271

240-
# header parameters, if any
272+
# header parameters
241273
headers = {}
274+
275+
_header_accept = 'application/json, application/xml'
276+
if _header_accept != ''
277+
headerParams['Accept'] = _header_accept
278+
end
279+
_header_content_type = []
280+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
281+
242282

243283

244284
# http body (model)
@@ -283,8 +323,16 @@ def self.updatePetWithForm (pet_id, name, status, opts={})
283323
query_param_keys.include? key
284324
end
285325

286-
# header parameters, if any
326+
# header parameters
287327
headers = {}
328+
329+
_header_accept = 'application/json, application/xml'
330+
if _header_accept != ''
331+
headerParams['Accept'] = _header_accept
332+
end
333+
_header_content_type = ['application/x-www-form-urlencoded', ]
334+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
335+
288336

289337

290338
# http body (model)
@@ -328,8 +376,16 @@ def self.deletePet (api_key, pet_id, opts={})
328376
query_param_keys.include? key
329377
end
330378

331-
# header parameters, if any
379+
# header parameters
332380
headers = {}
381+
382+
_header_accept = 'application/json, application/xml'
383+
if _header_accept != ''
384+
headerParams['Accept'] = _header_accept
385+
end
386+
_header_content_type = []
387+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
388+
333389

334390
headers[:'api_key'] = api_key
335391
# http body (model)
@@ -373,8 +429,16 @@ def self.uploadFile (pet_id, additional_metadata, file, opts={})
373429
query_param_keys.include? key
374430
end
375431

376-
# header parameters, if any
432+
# header parameters
377433
headers = {}
434+
435+
_header_accept = 'application/json, application/xml'
436+
if _header_accept != ''
437+
headerParams['Accept'] = _header_accept
438+
end
439+
_header_content_type = ['multipart/form-data', ]
440+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
441+
378442

379443

380444
# http body (model)

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

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,16 @@ def self.getInventory (opts={})
3030
query_param_keys.include? key
3131
end
3232

33-
# header parameters, if any
33+
# header parameters
3434
headers = {}
35+
36+
_header_accept = 'application/json, application/xml'
37+
if _header_accept != ''
38+
headerParams['Accept'] = _header_accept
39+
end
40+
_header_content_type = []
41+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
42+
3543

3644

3745
# http body (model)
@@ -72,8 +80,16 @@ def self.placeOrder (body, opts={})
7280
query_param_keys.include? key
7381
end
7482

75-
# header parameters, if any
83+
# header parameters
7684
headers = {}
85+
86+
_header_accept = 'application/json, application/xml'
87+
if _header_accept != ''
88+
headerParams['Accept'] = _header_accept
89+
end
90+
_header_content_type = []
91+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
92+
7793

7894

7995
# http body (model)
@@ -134,8 +150,16 @@ def self.getOrderById (order_id, opts={})
134150
query_param_keys.include? key
135151
end
136152

137-
# header parameters, if any
153+
# header parameters
138154
headers = {}
155+
156+
_header_accept = 'application/json, application/xml'
157+
if _header_accept != ''
158+
headerParams['Accept'] = _header_accept
159+
end
160+
_header_content_type = []
161+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
162+
139163

140164

141165
# http body (model)
@@ -176,8 +200,16 @@ def self.deleteOrder (order_id, opts={})
176200
query_param_keys.include? key
177201
end
178202

179-
# header parameters, if any
203+
# header parameters
180204
headers = {}
205+
206+
_header_accept = 'application/json, application/xml'
207+
if _header_accept != ''
208+
headerParams['Accept'] = _header_accept
209+
end
210+
_header_content_type = []
211+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
212+
181213

182214

183215
# http body (model)

0 commit comments

Comments
 (0)