Skip to content

Commit bc24e5e

Browse files
committed
update ruby accept header
1 parent b6be19b commit bc24e5e

File tree

4 files changed

+210
-21
lines changed

4 files changed

+210
-21
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,17 @@ 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+
}
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+
54+
4655
{{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}}
4756
{{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}}
4857
# http body (model)

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

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ 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+
}
42+
_header_content_type = [('application/json','application/xml',);
43+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
44+
45+
3746

3847

3948
# http body (model)
@@ -92,8 +101,17 @@ def self.addPet (body, opts={})
92101
query_param_keys.include? key
93102
end
94103

95-
# header parameters, if any
104+
# header parameters
96105
headers = {}
106+
107+
_header_accept = 'application/json, application/xml';
108+
if (_header_accept != '') {
109+
headerParams['Accept'] = _header_accept;
110+
}
111+
_header_content_type = [('application/json','application/xml',);
112+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
113+
114+
97115

98116

99117
# http body (model)
@@ -152,8 +170,17 @@ def self.findPetsByStatus (status, opts={})
152170
query_param_keys.include? key
153171
end
154172

155-
# header parameters, if any
173+
# header parameters
156174
headers = {}
175+
176+
_header_accept = 'application/json, application/xml';
177+
if (_header_accept != '') {
178+
headerParams['Accept'] = _header_accept;
179+
}
180+
_header_content_type = [();
181+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
182+
183+
157184

158185

159186
# http body (model)
@@ -194,8 +221,17 @@ def self.findPetsByTags (tags, opts={})
194221
query_param_keys.include? key
195222
end
196223

197-
# header parameters, if any
224+
# header parameters
198225
headers = {}
226+
227+
_header_accept = 'application/json, application/xml';
228+
if (_header_accept != '') {
229+
headerParams['Accept'] = _header_accept;
230+
}
231+
_header_content_type = [();
232+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
233+
234+
199235

200236

201237
# http body (model)
@@ -237,8 +273,17 @@ def self.getPetById (pet_id, opts={})
237273
query_param_keys.include? key
238274
end
239275

240-
# header parameters, if any
276+
# header parameters
241277
headers = {}
278+
279+
_header_accept = 'application/json, application/xml';
280+
if (_header_accept != '') {
281+
headerParams['Accept'] = _header_accept;
282+
}
283+
_header_content_type = [();
284+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
285+
286+
242287

243288

244289
# http body (model)
@@ -283,8 +328,17 @@ def self.updatePetWithForm (pet_id, name, status, opts={})
283328
query_param_keys.include? key
284329
end
285330

286-
# header parameters, if any
331+
# header parameters
287332
headers = {}
333+
334+
_header_accept = 'application/json, application/xml';
335+
if (_header_accept != '') {
336+
headerParams['Accept'] = _header_accept;
337+
}
338+
_header_content_type = [('application/x-www-form-urlencoded',);
339+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
340+
341+
288342

289343

290344
# http body (model)
@@ -328,8 +382,17 @@ def self.deletePet (api_key, pet_id, opts={})
328382
query_param_keys.include? key
329383
end
330384

331-
# header parameters, if any
385+
# header parameters
332386
headers = {}
387+
388+
_header_accept = 'application/json, application/xml';
389+
if (_header_accept != '') {
390+
headerParams['Accept'] = _header_accept;
391+
}
392+
_header_content_type = [();
393+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
394+
395+
333396

334397
headers[:'api_key'] = api_key
335398
# http body (model)
@@ -373,8 +436,17 @@ def self.uploadFile (pet_id, additional_metadata, file, opts={})
373436
query_param_keys.include? key
374437
end
375438

376-
# header parameters, if any
439+
# header parameters
377440
headers = {}
441+
442+
_header_accept = 'application/json, application/xml';
443+
if (_header_accept != '') {
444+
headerParams['Accept'] = _header_accept;
445+
}
446+
_header_content_type = [('multipart/form-data',);
447+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
448+
449+
378450

379451

380452
# http body (model)

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,17 @@ 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+
}
40+
_header_content_type = [();
41+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
42+
43+
3544

3645

3746
# http body (model)
@@ -72,8 +81,17 @@ def self.placeOrder (body, opts={})
7281
query_param_keys.include? key
7382
end
7483

75-
# header parameters, if any
84+
# header parameters
7685
headers = {}
86+
87+
_header_accept = 'application/json, application/xml';
88+
if (_header_accept != '') {
89+
headerParams['Accept'] = _header_accept;
90+
}
91+
_header_content_type = [();
92+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
93+
94+
7795

7896

7997
# http body (model)
@@ -134,8 +152,17 @@ def self.getOrderById (order_id, opts={})
134152
query_param_keys.include? key
135153
end
136154

137-
# header parameters, if any
155+
# header parameters
138156
headers = {}
157+
158+
_header_accept = 'application/json, application/xml';
159+
if (_header_accept != '') {
160+
headerParams['Accept'] = _header_accept;
161+
}
162+
_header_content_type = [();
163+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
164+
165+
139166

140167

141168
# http body (model)
@@ -176,8 +203,17 @@ def self.deleteOrder (order_id, opts={})
176203
query_param_keys.include? key
177204
end
178205

179-
# header parameters, if any
206+
# header parameters
180207
headers = {}
208+
209+
_header_accept = 'application/json, application/xml';
210+
if (_header_accept != '') {
211+
headerParams['Accept'] = _header_accept;
212+
}
213+
_header_content_type = [();
214+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
215+
216+
181217

182218

183219
# http body (model)

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

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ def self.createUser (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+
}
42+
_header_content_type = [();
43+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
44+
45+
3746

3847

3948
# http body (model)
@@ -92,8 +101,17 @@ def self.createUsersWithArrayInput (body, opts={})
92101
query_param_keys.include? key
93102
end
94103

95-
# header parameters, if any
104+
# header parameters
96105
headers = {}
106+
107+
_header_accept = 'application/json, application/xml';
108+
if (_header_accept != '') {
109+
headerParams['Accept'] = _header_accept;
110+
}
111+
_header_content_type = [();
112+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
113+
114+
97115

98116

99117
# http body (model)
@@ -152,8 +170,17 @@ def self.createUsersWithListInput (body, opts={})
152170
query_param_keys.include? key
153171
end
154172

155-
# header parameters, if any
173+
# header parameters
156174
headers = {}
175+
176+
_header_accept = 'application/json, application/xml';
177+
if (_header_accept != '') {
178+
headerParams['Accept'] = _header_accept;
179+
}
180+
_header_content_type = [();
181+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
182+
183+
157184

158185

159186
# http body (model)
@@ -214,8 +241,17 @@ def self.loginUser (username, password, opts={})
214241
query_param_keys.include? key
215242
end
216243

217-
# header parameters, if any
244+
# header parameters
218245
headers = {}
246+
247+
_header_accept = 'application/json, application/xml';
248+
if (_header_accept != '') {
249+
headerParams['Accept'] = _header_accept;
250+
}
251+
_header_content_type = [();
252+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
253+
254+
219255

220256

221257
# http body (model)
@@ -253,8 +289,17 @@ def self.logoutUser (opts={})
253289
query_param_keys.include? key
254290
end
255291

256-
# header parameters, if any
292+
# header parameters
257293
headers = {}
294+
295+
_header_accept = 'application/json, application/xml';
296+
if (_header_accept != '') {
297+
headerParams['Accept'] = _header_accept;
298+
}
299+
_header_content_type = [();
300+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
301+
302+
258303

259304

260305
# http body (model)
@@ -294,8 +339,17 @@ def self.getUserByName (username, opts={})
294339
query_param_keys.include? key
295340
end
296341

297-
# header parameters, if any
342+
# header parameters
298343
headers = {}
344+
345+
_header_accept = 'application/json, application/xml';
346+
if (_header_accept != '') {
347+
headerParams['Accept'] = _header_accept;
348+
}
349+
_header_content_type = [();
350+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
351+
352+
299353

300354

301355
# http body (model)
@@ -338,8 +392,17 @@ def self.updateUser (username, body, opts={})
338392
query_param_keys.include? key
339393
end
340394

341-
# header parameters, if any
395+
# header parameters
342396
headers = {}
397+
398+
_header_accept = 'application/json, application/xml';
399+
if (_header_accept != '') {
400+
headerParams['Accept'] = _header_accept;
401+
}
402+
_header_content_type = [();
403+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
404+
405+
343406

344407

345408
# http body (model)
@@ -399,8 +462,17 @@ def self.deleteUser (username, opts={})
399462
query_param_keys.include? key
400463
end
401464

402-
# header parameters, if any
465+
# header parameters
403466
headers = {}
467+
468+
_header_accept = 'application/json, application/xml';
469+
if (_header_accept != '') {
470+
headerParams['Accept'] = _header_accept;
471+
}
472+
_header_content_type = [();
473+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json';
474+
475+
404476

405477

406478
# http body (model)

0 commit comments

Comments
 (0)