@@ -26,7 +26,7 @@ class PetApi {
26
26
Future addPetWithHttpInfo (Pet body) async {
27
27
// Verify required params are set.
28
28
if (body == null ) {
29
- throw ApiException (400 , 'Missing required param: body' );
29
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: body' );
30
30
}
31
31
32
32
final path = '/pet' .replaceAll ('{format}' , 'json' );
@@ -74,12 +74,9 @@ class PetApi {
74
74
/// Pet object that needs to be added to the store
75
75
Future addPet (Pet body) async {
76
76
final response = await addPetWithHttpInfo (body);
77
- if (response.statusCode >= 400 ) {
77
+ if (response.statusCode >= HttpStatus .badRequest ) {
78
78
throw ApiException (response.statusCode, _decodeBodyBytes (response));
79
79
}
80
- if (response.body != null ) {
81
- }
82
- return ;
83
80
}
84
81
85
82
/// Deletes a pet
@@ -95,10 +92,11 @@ class PetApi {
95
92
Future deletePetWithHttpInfo (int petId, { String apiKey }) async {
96
93
// Verify required params are set.
97
94
if (petId == null ) {
98
- throw ApiException (400 , 'Missing required param: petId' );
95
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: petId' );
99
96
}
100
97
101
- final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' ).replaceAll ('{' + 'petId' + '}' , petId.toString ());
98
+ final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' )
99
+ .replaceAll ('{' + 'petId' + '}' , petId.toString ());
102
100
103
101
Object postBody;
104
102
@@ -146,12 +144,9 @@ class PetApi {
146
144
/// * [String] apiKey:
147
145
Future deletePet (int petId, { String apiKey }) async {
148
146
final response = await deletePetWithHttpInfo (petId, apiKey: apiKey );
149
- if (response.statusCode >= 400 ) {
147
+ if (response.statusCode >= HttpStatus .badRequest ) {
150
148
throw ApiException (response.statusCode, _decodeBodyBytes (response));
151
149
}
152
- if (response.body != null ) {
153
- }
154
- return ;
155
150
}
156
151
157
152
/// Finds Pets by status
@@ -167,7 +162,7 @@ class PetApi {
167
162
Future <Response > findPetsByStatusWithHttpInfo (List <String > status) async {
168
163
// Verify required params are set.
169
164
if (status == null ) {
170
- throw ApiException (400 , 'Missing required param: status' );
165
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: status' );
171
166
}
172
167
173
168
final path = '/pet/findByStatus' .replaceAll ('{format}' , 'json' );
@@ -218,10 +213,13 @@ class PetApi {
218
213
/// Status values that need to be considered for filter
219
214
Future <List <Pet >> findPetsByStatus (List <String > status) async {
220
215
final response = await findPetsByStatusWithHttpInfo (status);
221
- if (response.statusCode >= 400 ) {
216
+ if (response.statusCode >= HttpStatus .badRequest ) {
222
217
throw ApiException (response.statusCode, _decodeBodyBytes (response));
223
218
}
224
- if (response.body != null ) {
219
+ // When a remote server returns no body with a status of 204, we shall not decode it.
220
+ // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
221
+ // FormatException when trying to decode an empty string.
222
+ if (response.body != null && response.statusCode != HttpStatus .noContent) {
225
223
return (apiClient.deserialize (_decodeBodyBytes (response), 'List<Pet>' ) as List )
226
224
.map ((item) => item as Pet )
227
225
.toList (growable: false );
@@ -242,7 +240,7 @@ class PetApi {
242
240
Future <Response > findPetsByTagsWithHttpInfo (List <String > tags) async {
243
241
// Verify required params are set.
244
242
if (tags == null ) {
245
- throw ApiException (400 , 'Missing required param: tags' );
243
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: tags' );
246
244
}
247
245
248
246
final path = '/pet/findByTags' .replaceAll ('{format}' , 'json' );
@@ -293,10 +291,13 @@ class PetApi {
293
291
/// Tags to filter by
294
292
Future <List <Pet >> findPetsByTags (List <String > tags) async {
295
293
final response = await findPetsByTagsWithHttpInfo (tags);
296
- if (response.statusCode >= 400 ) {
294
+ if (response.statusCode >= HttpStatus .badRequest ) {
297
295
throw ApiException (response.statusCode, _decodeBodyBytes (response));
298
296
}
299
- if (response.body != null ) {
297
+ // When a remote server returns no body with a status of 204, we shall not decode it.
298
+ // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
299
+ // FormatException when trying to decode an empty string.
300
+ if (response.body != null && response.statusCode != HttpStatus .noContent) {
300
301
return (apiClient.deserialize (_decodeBodyBytes (response), 'List<Pet>' ) as List )
301
302
.map ((item) => item as Pet )
302
303
.toList (growable: false );
@@ -317,10 +318,11 @@ class PetApi {
317
318
Future <Response > getPetByIdWithHttpInfo (int petId) async {
318
319
// Verify required params are set.
319
320
if (petId == null ) {
320
- throw ApiException (400 , 'Missing required param: petId' );
321
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: petId' );
321
322
}
322
323
323
- final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' ).replaceAll ('{' + 'petId' + '}' , petId.toString ());
324
+ final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' )
325
+ .replaceAll ('{' + 'petId' + '}' , petId.toString ());
324
326
325
327
Object postBody;
326
328
@@ -367,10 +369,13 @@ class PetApi {
367
369
/// ID of pet to return
368
370
Future <Pet > getPetById (int petId) async {
369
371
final response = await getPetByIdWithHttpInfo (petId);
370
- if (response.statusCode >= 400 ) {
372
+ if (response.statusCode >= HttpStatus .badRequest ) {
371
373
throw ApiException (response.statusCode, _decodeBodyBytes (response));
372
374
}
373
- if (response.body != null ) {
375
+ // When a remote server returns no body with a status of 204, we shall not decode it.
376
+ // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
377
+ // FormatException when trying to decode an empty string.
378
+ if (response.body != null && response.statusCode != HttpStatus .noContent) {
374
379
return apiClient.deserialize (_decodeBodyBytes (response), 'Pet' ) as Pet ;
375
380
}
376
381
return null ;
@@ -387,7 +392,7 @@ class PetApi {
387
392
Future updatePetWithHttpInfo (Pet body) async {
388
393
// Verify required params are set.
389
394
if (body == null ) {
390
- throw ApiException (400 , 'Missing required param: body' );
395
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: body' );
391
396
}
392
397
393
398
final path = '/pet' .replaceAll ('{format}' , 'json' );
@@ -435,12 +440,9 @@ class PetApi {
435
440
/// Pet object that needs to be added to the store
436
441
Future updatePet (Pet body) async {
437
442
final response = await updatePetWithHttpInfo (body);
438
- if (response.statusCode >= 400 ) {
443
+ if (response.statusCode >= HttpStatus .badRequest ) {
439
444
throw ApiException (response.statusCode, _decodeBodyBytes (response));
440
445
}
441
- if (response.body != null ) {
442
- }
443
- return ;
444
446
}
445
447
446
448
/// Updates a pet in the store with form data
@@ -460,10 +462,11 @@ class PetApi {
460
462
Future updatePetWithFormWithHttpInfo (int petId, { String name, String status }) async {
461
463
// Verify required params are set.
462
464
if (petId == null ) {
463
- throw ApiException (400 , 'Missing required param: petId' );
465
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: petId' );
464
466
}
465
467
466
- final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' ).replaceAll ('{' + 'petId' + '}' , petId.toString ());
468
+ final path = '/pet/{petId}' .replaceAll ('{format}' , 'json' )
469
+ .replaceAll ('{' + 'petId' + '}' , petId.toString ());
467
470
468
471
Object postBody;
469
472
@@ -528,12 +531,9 @@ class PetApi {
528
531
/// Updated status of the pet
529
532
Future updatePetWithForm (int petId, { String name, String status }) async {
530
533
final response = await updatePetWithFormWithHttpInfo (petId, name: name, status: status );
531
- if (response.statusCode >= 400 ) {
534
+ if (response.statusCode >= HttpStatus .badRequest ) {
532
535
throw ApiException (response.statusCode, _decodeBodyBytes (response));
533
536
}
534
- if (response.body != null ) {
535
- }
536
- return ;
537
537
}
538
538
539
539
/// uploads an image
@@ -553,10 +553,11 @@ class PetApi {
553
553
Future <Response > uploadFileWithHttpInfo (int petId, { String additionalMetadata, MultipartFile file }) async {
554
554
// Verify required params are set.
555
555
if (petId == null ) {
556
- throw ApiException (400 , 'Missing required param: petId' );
556
+ throw ApiException (HttpStatus .badRequest , 'Missing required param: petId' );
557
557
}
558
558
559
- final path = '/pet/{petId}/uploadImage' .replaceAll ('{format}' , 'json' ).replaceAll ('{' + 'petId' + '}' , petId.toString ());
559
+ final path = '/pet/{petId}/uploadImage' .replaceAll ('{format}' , 'json' )
560
+ .replaceAll ('{' + 'petId' + '}' , petId.toString ());
560
561
561
562
Object postBody;
562
563
@@ -619,10 +620,13 @@ class PetApi {
619
620
/// file to upload
620
621
Future <ApiResponse > uploadFile (int petId, { String additionalMetadata, MultipartFile file }) async {
621
622
final response = await uploadFileWithHttpInfo (petId, additionalMetadata: additionalMetadata, file: file );
622
- if (response.statusCode >= 400 ) {
623
+ if (response.statusCode >= HttpStatus .badRequest ) {
623
624
throw ApiException (response.statusCode, _decodeBodyBytes (response));
624
625
}
625
- if (response.body != null ) {
626
+ // When a remote server returns no body with a status of 204, we shall not decode it.
627
+ // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
628
+ // FormatException when trying to decode an empty string.
629
+ if (response.body != null && response.statusCode != HttpStatus .noContent) {
626
630
return apiClient.deserialize (_decodeBodyBytes (response), 'ApiResponse' ) as ApiResponse ;
627
631
}
628
632
return null ;
0 commit comments