4
4
import com .wordnik .client .ApiInvoker ;
5
5
6
6
import com .wordnik .petstore .model .Pet ;
7
+ import com .sun .jersey .multipart .FormDataMultiPart ;
8
+
9
+ import javax .ws .rs .core .MediaType ;
10
+
7
11
import java .io .File ;
8
12
import java .util .*;
9
13
@@ -26,6 +30,7 @@ public String getBasePath() {
26
30
//error info- code: 400 reason: "Invalid ID supplied" model: <none>
27
31
//error info- code: 404 reason: "Pet not found" model: <none>
28
32
public Pet getPetById (Long petId ) throws ApiException {
33
+ Object postBody = null ;
29
34
// verify required params are set
30
35
if (petId == null ) {
31
36
throw new ApiException (400 , "missing required params" );
@@ -43,8 +48,17 @@ public Pet getPetById (Long petId) throws ApiException {
43
48
44
49
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
45
50
51
+ if (contentType .startsWith ("multipart/form-data" )) {
52
+ boolean hasFields = false ;
53
+ FormDataMultiPart mp = new FormDataMultiPart ();
54
+ if (hasFields )
55
+ postBody = mp ;
56
+ }
57
+ else {
58
+ }
59
+
46
60
try {
47
- String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , null , headerParams , formParams , contentType );
61
+ String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , postBody , headerParams , formParams , contentType );
48
62
if (response != null ){
49
63
return (Pet ) ApiInvoker .deserialize (response , "" , Pet .class );
50
64
}
@@ -62,6 +76,7 @@ public Pet getPetById (Long petId) throws ApiException {
62
76
}
63
77
//error info- code: 400 reason: "Invalid pet value" model: <none>
64
78
public void deletePet (String petId ) throws ApiException {
79
+ Object postBody = null ;
65
80
// verify required params are set
66
81
if (petId == null ) {
67
82
throw new ApiException (400 , "missing required params" );
@@ -79,8 +94,17 @@ public void deletePet (String petId) throws ApiException {
79
94
80
95
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
81
96
97
+ if (contentType .startsWith ("multipart/form-data" )) {
98
+ boolean hasFields = false ;
99
+ FormDataMultiPart mp = new FormDataMultiPart ();
100
+ if (hasFields )
101
+ postBody = mp ;
102
+ }
103
+ else {
104
+ }
105
+
82
106
try {
83
- String response = apiInvoker .invokeAPI (basePath , path , "DELETE" , queryParams , null , headerParams , formParams , contentType );
107
+ String response = apiInvoker .invokeAPI (basePath , path , "DELETE" , queryParams , postBody , headerParams , formParams , contentType );
84
108
if (response != null ){
85
109
return ;
86
110
}
@@ -98,6 +122,7 @@ public void deletePet (String petId) throws ApiException {
98
122
}
99
123
//error info- code: 400 reason: "Invalid tag value" model: <none>
100
124
public List <Pet > partialUpdate (String petId , Pet body ) throws ApiException {
125
+ Object postBody = body ;
101
126
// verify required params are set
102
127
if (petId == null || body == null ) {
103
128
throw new ApiException (400 , "missing required params" );
@@ -115,10 +140,19 @@ public List<Pet> partialUpdate (String petId, Pet body) throws ApiException {
115
140
116
141
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
117
142
143
+ if (contentType .startsWith ("multipart/form-data" )) {
144
+ boolean hasFields = false ;
145
+ FormDataMultiPart mp = new FormDataMultiPart ();
146
+ if (hasFields )
147
+ postBody = mp ;
148
+ }
149
+ else {
150
+ }
151
+
118
152
try {
119
- String response = apiInvoker .invokeAPI (basePath , path , "PATCH" , queryParams , body , headerParams , formParams , contentType );
153
+ String response = apiInvoker .invokeAPI (basePath , path , "PATCH" , queryParams , postBody , headerParams , formParams , contentType );
120
154
if (response != null ){
121
- return (List <Pet >) ApiInvoker .deserialize (response , "Array " , Pet .class );
155
+ return (List <Pet >) ApiInvoker .deserialize (response , "List " , Pet .class );
122
156
}
123
157
else {
124
158
return null ;
@@ -134,6 +168,7 @@ public List<Pet> partialUpdate (String petId, Pet body) throws ApiException {
134
168
}
135
169
//error info- code: 405 reason: "Invalid input" model: <none>
136
170
public void updatePetWithForm (String petId , String name , String status ) throws ApiException {
171
+ Object postBody = null ;
137
172
// verify required params are set
138
173
if (petId == null ) {
139
174
throw new ApiException (400 , "missing required params" );
@@ -146,47 +181,26 @@ public void updatePetWithForm (String petId, String name, String status) throws
146
181
Map <String , String > headerParams = new HashMap <String , String >();
147
182
Map <String , String > formParams = new HashMap <String , String >();
148
183
149
- formParams .put ("name" , name );
150
- formParams .put ("status" , status );
151
184
String [] contentTypes = {
152
185
"application/x-www-form-urlencoded" };
153
186
154
187
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
155
188
156
- try {
157
- String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , null , headerParams , formParams , contentType );
158
- if (response != null ){
159
- return ;
160
- }
161
- else {
162
- return ;
163
- }
164
- } catch (ApiException ex ) {
165
- if (ex .getCode () == 404 ) {
166
- return ;
167
- }
168
- else {
169
- throw ex ;
170
- }
189
+ if (contentType .startsWith ("multipart/form-data" )) {
190
+ boolean hasFields = false ;
191
+ FormDataMultiPart mp = new FormDataMultiPart ();
192
+ hasFields = true ;
193
+ mp .field ("name" , "name" , MediaType .MULTIPART_FORM_DATA_TYPE );
194
+ hasFields = true ;
195
+ mp .field ("status" , "status" , MediaType .MULTIPART_FORM_DATA_TYPE );
196
+ if (hasFields )
197
+ postBody = mp ;
171
198
}
172
- }
173
- public void uploadFile (String additionalMetadata , File body ) throws ApiException {
174
- // create path and map variables
175
- String path = "/pet/uploadImage" .replaceAll ("\\ {format\\ }" ,"json" );
176
-
177
- // query params
178
- Map <String , String > queryParams = new HashMap <String , String >();
179
- Map <String , String > headerParams = new HashMap <String , String >();
180
- Map <String , String > formParams = new HashMap <String , String >();
181
-
182
- formParams .put ("additionalMetadata" , additionalMetadata );
183
- String [] contentTypes = {
184
- "multipart/form-data" };
185
-
186
- String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
199
+ else {
200
+ formParams .put ("name" , name );formParams .put ("status" , status );}
187
201
188
202
try {
189
- String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , body , headerParams , formParams , contentType );
203
+ String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , postBody , headerParams , formParams , contentType );
190
204
if (response != null ){
191
205
return ;
192
206
}
@@ -204,6 +218,7 @@ public void uploadFile (String additionalMetadata, File body) throws ApiExceptio
204
218
}
205
219
//error info- code: 405 reason: "Invalid input" model: <none>
206
220
public void addPet (Pet body ) throws ApiException {
221
+ Object postBody = body ;
207
222
// verify required params are set
208
223
if (body == null ) {
209
224
throw new ApiException (400 , "missing required params" );
@@ -221,8 +236,17 @@ public void addPet (Pet body) throws ApiException {
221
236
222
237
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
223
238
239
+ if (contentType .startsWith ("multipart/form-data" )) {
240
+ boolean hasFields = false ;
241
+ FormDataMultiPart mp = new FormDataMultiPart ();
242
+ if (hasFields )
243
+ postBody = mp ;
244
+ }
245
+ else {
246
+ }
247
+
224
248
try {
225
- String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , body , headerParams , formParams , contentType );
249
+ String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , postBody , headerParams , formParams , contentType );
226
250
if (response != null ){
227
251
return ;
228
252
}
@@ -242,6 +266,7 @@ public void addPet (Pet body) throws ApiException {
242
266
//error info- code: 404 reason: "Pet not found" model: <none>
243
267
//error info- code: 405 reason: "Validation exception" model: <none>
244
268
public void updatePet (Pet body ) throws ApiException {
269
+ Object postBody = body ;
245
270
// verify required params are set
246
271
if (body == null ) {
247
272
throw new ApiException (400 , "missing required params" );
@@ -259,8 +284,17 @@ public void updatePet (Pet body) throws ApiException {
259
284
260
285
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
261
286
287
+ if (contentType .startsWith ("multipart/form-data" )) {
288
+ boolean hasFields = false ;
289
+ FormDataMultiPart mp = new FormDataMultiPart ();
290
+ if (hasFields )
291
+ postBody = mp ;
292
+ }
293
+ else {
294
+ }
295
+
262
296
try {
263
- String response = apiInvoker .invokeAPI (basePath , path , "PUT" , queryParams , body , headerParams , formParams , contentType );
297
+ String response = apiInvoker .invokeAPI (basePath , path , "PUT" , queryParams , postBody , headerParams , formParams , contentType );
264
298
if (response != null ){
265
299
return ;
266
300
}
@@ -278,6 +312,7 @@ public void updatePet (Pet body) throws ApiException {
278
312
}
279
313
//error info- code: 400 reason: "Invalid status value" model: <none>
280
314
public List <Pet > findPetsByStatus (String status ) throws ApiException {
315
+ Object postBody = null ;
281
316
// verify required params are set
282
317
if (status == null ) {
283
318
throw new ApiException (400 , "missing required params" );
@@ -297,10 +332,19 @@ public List<Pet> findPetsByStatus (String status) throws ApiException {
297
332
298
333
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
299
334
335
+ if (contentType .startsWith ("multipart/form-data" )) {
336
+ boolean hasFields = false ;
337
+ FormDataMultiPart mp = new FormDataMultiPart ();
338
+ if (hasFields )
339
+ postBody = mp ;
340
+ }
341
+ else {
342
+ }
343
+
300
344
try {
301
- String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , null , headerParams , formParams , contentType );
345
+ String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , postBody , headerParams , formParams , contentType );
302
346
if (response != null ){
303
- return (List <Pet >) ApiInvoker .deserialize (response , "Array " , Pet .class );
347
+ return (List <Pet >) ApiInvoker .deserialize (response , "List " , Pet .class );
304
348
}
305
349
else {
306
350
return null ;
@@ -316,6 +360,7 @@ public List<Pet> findPetsByStatus (String status) throws ApiException {
316
360
}
317
361
//error info- code: 400 reason: "Invalid tag value" model: <none>
318
362
public List <Pet > findPetsByTags (String tags ) throws ApiException {
363
+ Object postBody = null ;
319
364
// verify required params are set
320
365
if (tags == null ) {
321
366
throw new ApiException (400 , "missing required params" );
@@ -335,10 +380,19 @@ public List<Pet> findPetsByTags (String tags) throws ApiException {
335
380
336
381
String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
337
382
383
+ if (contentType .startsWith ("multipart/form-data" )) {
384
+ boolean hasFields = false ;
385
+ FormDataMultiPart mp = new FormDataMultiPart ();
386
+ if (hasFields )
387
+ postBody = mp ;
388
+ }
389
+ else {
390
+ }
391
+
338
392
try {
339
- String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , null , headerParams , formParams , contentType );
393
+ String response = apiInvoker .invokeAPI (basePath , path , "GET" , queryParams , postBody , headerParams , formParams , contentType );
340
394
if (response != null ){
341
- return (List <Pet >) ApiInvoker .deserialize (response , "Array " , Pet .class );
395
+ return (List <Pet >) ApiInvoker .deserialize (response , "List " , Pet .class );
342
396
}
343
397
else {
344
398
return null ;
@@ -352,5 +406,50 @@ public List<Pet> findPetsByTags (String tags) throws ApiException {
352
406
}
353
407
}
354
408
}
409
+ public void uploadFile (String additionalMetadata , File file ) throws ApiException {
410
+ Object postBody = null ;
411
+ // create path and map variables
412
+ String path = "/pet/uploadImage" .replaceAll ("\\ {format\\ }" ,"json" );
413
+
414
+ // query params
415
+ Map <String , String > queryParams = new HashMap <String , String >();
416
+ Map <String , String > headerParams = new HashMap <String , String >();
417
+ Map <String , String > formParams = new HashMap <String , String >();
418
+
419
+ String [] contentTypes = {
420
+ "multipart/form-data" };
421
+
422
+ String contentType = contentTypes .length > 0 ? contentTypes [0 ] : "application/json" ;
423
+
424
+ if (contentType .startsWith ("multipart/form-data" )) {
425
+ boolean hasFields = false ;
426
+ FormDataMultiPart mp = new FormDataMultiPart ();
427
+ hasFields = true ;
428
+ mp .field ("additionalMetadata" , "additionalMetadata" , MediaType .MULTIPART_FORM_DATA_TYPE );
429
+ hasFields = true ;
430
+ mp .field ("file" , file , MediaType .MULTIPART_FORM_DATA_TYPE );
431
+ if (hasFields )
432
+ postBody = mp ;
433
+ }
434
+ else {
435
+ formParams .put ("additionalMetadata" , additionalMetadata );}
436
+
437
+ try {
438
+ String response = apiInvoker .invokeAPI (basePath , path , "POST" , queryParams , postBody , headerParams , formParams , contentType );
439
+ if (response != null ){
440
+ return ;
441
+ }
442
+ else {
443
+ return ;
444
+ }
445
+ } catch (ApiException ex ) {
446
+ if (ex .getCode () == 404 ) {
447
+ return ;
448
+ }
449
+ else {
450
+ throw ex ;
451
+ }
452
+ }
453
+ }
355
454
}
356
455
0 commit comments