forked from loafle/openapi-generator-original
[Dart2] Add initial support to use an isolate to offload JSON serialization/deserialization (#9100)
* Change signature of deserialize() to be a Future. * Grammar tlc for a couple of sentences. * Make serialize() use a Future also. * Add useCompute as a parameter to ApiClient, adjust to use compute when serializing/deserializing. * Updated Pet Store client code. * Ordered imports. * Remove Flutter-specific implementation. * Rename global functions to serialize/deserialize JSON. * Fix return type for apiClientSerialize. * Updated pet store client code. * Remove remark for _deserialize. * Make _decodeBodyBytes a Future function. * Updated pet store client code. * Use await when calling serialize(). * Fix a grammatical error. * Adjust doc. * Centralize deserialization code in one function. * Updated pet store client code. * Add await to serialize() in few more tests. * Make output look better for linting and humans. * Updated pet store code. * Add an empty line. * Updated pet store code. * Call the right serializer. * Reuse same variable. * Updated pet store code. * Fix a logical error when deserializing. * Calculate growable once. * Ignore reassignment. * Adjust a test. * Regenerate petstore code. * Revert back previous test. * Use serialize() for testing. * Revert using serialize() for testing. * Add removal deprecation for serialize/deserialize. * Updated petstore code. * Updated deprecation note. * Adjust tests to wait for futures.
This commit is contained in:
parent
47e292c0e7
commit
26ca6ab27e
@ -178,7 +178,7 @@ class {{{classname}}} {
|
|||||||
Future<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
Future<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{{nickname}}}({{#allParams}}{{#required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
|
||||||
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
final response = await {{{nickname}}}WithHttpInfo({{#allParams}}{{#required}}{{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{{paramName}}}: {{{paramName}}}{{^-last}}, {{/-last}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
@ -187,16 +187,16 @@ class {{{classname}}} {
|
|||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
{{#native_serialization}}
|
{{#native_serialization}}
|
||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}') as List)
|
||||||
.cast<{{{returnBaseType}}}>()
|
.cast<{{{returnBaseType}}}>()
|
||||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
||||||
{{/isArray}}
|
{{/isArray}}
|
||||||
{{^isArray}}
|
{{^isArray}}
|
||||||
{{#isMap}}
|
{{#isMap}}
|
||||||
return {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}'));
|
return {{{returnType}}}.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}'),);
|
||||||
{{/isMap}}
|
{{/isMap}}
|
||||||
{{^isMap}}
|
{{^isMap}}
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as {{{returnType}}};
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}};
|
||||||
{{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}}
|
{{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}}
|
||||||
{{#isArray}}
|
{{#isArray}}
|
||||||
{{#uniqueItems}}
|
{{#uniqueItems}}
|
||||||
|
@ -51,17 +51,16 @@ class ApiClient {
|
|||||||
|
|
||||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||||
|
|
||||||
/// returns an unmodifiable view of the authentications, since none should be added
|
/// Returns an unmodifiable [Map] of the authentications, since none should be added
|
||||||
/// nor deleted
|
/// or deleted.
|
||||||
Map<String, Authentication> get authentications =>
|
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||||
Map.unmodifiable(_authentications);
|
|
||||||
|
|
||||||
T getAuthentication<T extends Authentication>(String name) {
|
T getAuthentication<T extends Authentication>(String name) {
|
||||||
final authentication = _authentications[name];
|
final authentication = _authentications[name];
|
||||||
return authentication is T ? authentication : null;
|
return authentication is T ? authentication : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don’t use a Map<String, String> for queryParams.
|
// We don't use a Map<String, String> for queryParams.
|
||||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||||
Future<Response> invokeAPI(
|
Future<Response> invokeAPI(
|
||||||
String path,
|
String path,
|
||||||
@ -92,7 +91,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||||
if (
|
if (
|
||||||
body is MultipartFile && (nullableContentType == null ||
|
body is MultipartFile && (nullableContentType == null ||
|
||||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||||
@ -122,7 +121,7 @@ class ApiClient {
|
|||||||
|
|
||||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||||
? formParams
|
? formParams
|
||||||
: serialize(body);
|
: await serializeAsync(body);
|
||||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||||
|
|
||||||
switch(method) {
|
switch(method) {
|
||||||
@ -147,9 +146,48 @@ class ApiClient {
|
|||||||
|
|
||||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||||
}
|
}
|
||||||
|
{{#native_serialization}}
|
||||||
|
|
||||||
|
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
deserialize(json, targetType, growable: growable);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||||
|
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? json
|
||||||
|
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||||
|
}
|
||||||
|
{{/native_serialization}}
|
||||||
|
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||||
|
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||||
|
|
||||||
|
/// Update query and header parameters based on authentication settings.
|
||||||
|
/// @param authNames The authentications to apply
|
||||||
|
void _updateParamsForAuth(
|
||||||
|
List<String> authNames,
|
||||||
|
List<QueryParam> queryParams,
|
||||||
|
Map<String, String> headerParams,
|
||||||
|
) {
|
||||||
|
authNames.forEach((authName) {
|
||||||
|
final auth = _authentications[authName];
|
||||||
|
if (auth == null) {
|
||||||
|
throw ArgumentError('Authentication undefined: $authName');
|
||||||
|
}
|
||||||
|
auth.applyToParams(queryParams, headerParams);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
{{#native_serialization}}
|
{{#native_serialization}}
|
||||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||||
try {
|
try {
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
case 'String':
|
case 'String':
|
||||||
@ -180,57 +218,68 @@ class ApiClient {
|
|||||||
default:
|
default:
|
||||||
Match match;
|
Match match;
|
||||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toList(growable: true == growable);
|
.toList(growable: growable);
|
||||||
}
|
}
|
||||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return Map.fromIterables(
|
return Map.fromIterables(
|
||||||
value.keys,
|
value.keys,
|
||||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
value.values.map((v) => _deserialize(v, targetType, growable: growable)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} on Exception catch (e, stack) {
|
} catch (error, trace) {
|
||||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
||||||
}
|
}
|
||||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||||
}
|
}
|
||||||
|
{{/native_serialization}}
|
||||||
|
}
|
||||||
|
{{#native_serialization}}
|
||||||
|
|
||||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
/// Primarily intended for use in an isolate.
|
||||||
// Remove all spaces. Necessary for reg expressions as well.
|
class DeserializationMessage {
|
||||||
targetType = targetType.replaceAll(' ', '');
|
const DeserializationMessage({
|
||||||
|
@required this.json,
|
||||||
|
@required this.targetType,
|
||||||
|
this.growable,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The JSON value to deserialize.
|
||||||
|
final String json;
|
||||||
|
|
||||||
|
/// Target type to deserialize to.
|
||||||
|
final String targetType;
|
||||||
|
|
||||||
|
/// Whether to make deserialized lists or maps growable.
|
||||||
|
final bool growable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
final targetType = message.targetType.replaceAll(' ', '');
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
return targetType == 'String'
|
return targetType == 'String'
|
||||||
? json
|
? message.json
|
||||||
: _deserialize(jsonDecode(json), targetType, growable: true == growable);
|
: ApiClient._deserialize(
|
||||||
}
|
jsonDecode(message.json),
|
||||||
|
targetType,
|
||||||
|
growable: message.growable == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
{{/native_serialization}}
|
{{/native_serialization}}
|
||||||
|
|
||||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||||
/// Update query and header parameters based on authentication settings.
|
|
||||||
/// @param authNames The authentications to apply
|
|
||||||
void _updateParamsForAuth(
|
|
||||||
List<String> authNames,
|
|
||||||
List<QueryParam> queryParams,
|
|
||||||
Map<String, String> headerParams,
|
|
||||||
) {
|
|
||||||
authNames.forEach((authName) {
|
|
||||||
final auth = _authentications[authName];
|
|
||||||
if (auth == null) {
|
|
||||||
throw ArgumentError('Authentication undefined: $authName');
|
|
||||||
}
|
|
||||||
auth.applyToParams(queryParams, headerParams);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -63,7 +63,7 @@ String parameterToString(dynamic value) {
|
|||||||
|
|
||||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||||
String _decodeBodyBytes(Response response) {
|
Future<String> _decodeBodyBytes(Response response) async {
|
||||||
final contentType = response.headers['content-type'];
|
final contentType = response.headers['content-type'];
|
||||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
|
@ -7,11 +7,10 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
{{#json_serializable}}
|
{{#json_serializable}}
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
{{/json_serializable}}
|
{{/json_serializable}}
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
part 'api_client.dart';
|
part 'api_client.dart';
|
||||||
part 'api_helper.dart';
|
part 'api_helper.dart';
|
||||||
|
@ -39,7 +39,7 @@ void main() {
|
|||||||
Future<dynamic> addPet(Pet pet) {
|
Future<dynamic> addPet(Pet pet) {
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(pet),
|
expectedPostRequestBody: await petApi.apiClient.serializeAsync(pet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
return petApi.addPet(pet);
|
return petApi.addPet(pet);
|
||||||
@ -53,7 +53,8 @@ void main() {
|
|||||||
// use the pet api to add a pet
|
// use the pet api to add a pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
@ -61,7 +62,7 @@ void main() {
|
|||||||
// retrieve the same pet by id
|
// retrieve the same pet by id
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(newPet),
|
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
);
|
);
|
||||||
final retrievedPet = await petApi.getPetById(id);
|
final retrievedPet = await petApi.getPetById(id);
|
||||||
|
|
||||||
@ -86,7 +87,8 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
@ -115,7 +117,8 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
@ -139,7 +142,7 @@ void main() {
|
|||||||
newPet.name = 'Doge';
|
newPet.name = 'Doge';
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(newPet),
|
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
);
|
);
|
||||||
final pet = await petApi.getPetById(id);
|
final pet = await petApi.getPetById(id);
|
||||||
expect(pet.name, equals('Doge'));
|
expect(pet.name, equals('Doge'));
|
||||||
@ -154,7 +157,8 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
@ -162,7 +166,8 @@ void main() {
|
|||||||
// update the same pet
|
// update the same pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPutRequestBody: petApi.apiClient.serialize(updatePet),
|
expectedPutRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(updatePet),
|
||||||
putResponseBody: '',
|
putResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.updatePet(updatePet);
|
await petApi.updatePet(updatePet);
|
||||||
@ -170,7 +175,7 @@ void main() {
|
|||||||
// check update worked
|
// check update worked
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(updatePet),
|
getResponseBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||||
);
|
);
|
||||||
final pet = await petApi.getPetById(id);
|
final pet = await petApi.getPetById(id);
|
||||||
expect(pet.name, equals(name));
|
expect(pet.name, equals(name));
|
||||||
@ -180,30 +185,31 @@ void main() {
|
|||||||
final id1 = newId();
|
final id1 = newId();
|
||||||
final id2 = newId();
|
final id2 = newId();
|
||||||
final id3 = newId();
|
final id3 = newId();
|
||||||
final status = PetStatusEnum.available.value;
|
final status = '${PetStatusEnum.available}';
|
||||||
final pet1 = makePet(id: id1, status: status);
|
final pet1 = makePet(id: id1, status: status);
|
||||||
final pet2 = makePet(id: id2, status: status);
|
final pet2 = makePet(id: id2, status: status);
|
||||||
final pet3 = makePet(id: id3, status: PetStatusEnum.sold.value);
|
final pet3 = makePet(id: id3, status: '${PetStatusEnum.sold}');
|
||||||
|
|
||||||
return Future.wait([addPet(pet1), addPet(pet2), addPet(pet3)])
|
await addPet(pet1);
|
||||||
.then((_) async {
|
await addPet(pet2);
|
||||||
// retrieve pets by status
|
await addPet(pet3);
|
||||||
petApi.apiClient.client = FakeClient(
|
|
||||||
expectedUrl:
|
|
||||||
'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
|
|
||||||
getResponseBody: petApi.apiClient.serialize([pet1, pet2]),
|
|
||||||
);
|
|
||||||
final pets = await petApi.findPetsByStatus([status]);
|
|
||||||
|
|
||||||
// tests serialisation and deserialisation of enum
|
// retrieve pets by status
|
||||||
final petsByStatus =
|
petApi.apiClient.client = FakeClient(
|
||||||
pets.where((p) => p.status == PetStatusEnum.available);
|
expectedUrl:
|
||||||
expect(petsByStatus.length, equals(2));
|
'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
|
||||||
final petIds = pets.map((pet) => pet.id).toList();
|
getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]),
|
||||||
expect(petIds, contains(id1));
|
);
|
||||||
expect(petIds, contains(id2));
|
final pets = await petApi.findPetsByStatus([status]);
|
||||||
expect(petIds, isNot(contains(id3)));
|
|
||||||
});
|
// tests serialisation and deserialisation of enum
|
||||||
|
final petsByStatus =
|
||||||
|
pets.where((p) => p.status == PetStatusEnum.available);
|
||||||
|
expect(petsByStatus.length, equals(2));
|
||||||
|
final petIds = pets.map((pet) => pet.id).toList();
|
||||||
|
expect(petIds, contains(id1));
|
||||||
|
expect(petIds, contains(id2));
|
||||||
|
expect(petIds, isNot(contains(id3)));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('uploads a pet image', () async {
|
test('uploads a pet image', () async {
|
||||||
@ -216,7 +222,8 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
postResponseBody: '',
|
postResponseBody: '',
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
@ -81,19 +81,17 @@ void main() {
|
|||||||
var id1 = newId();
|
var id1 = newId();
|
||||||
var id2 = newId();
|
var id2 = newId();
|
||||||
var id3 = newId();
|
var id3 = newId();
|
||||||
var status = PetStatusEnum.available.value;
|
var status = '${PetStatusEnum.available}';
|
||||||
|
|
||||||
return Future.wait([
|
await petApi.addPet(makePet(id: id1, status: status));
|
||||||
petApi.addPet(makePet(id: id1, status: status)),
|
await petApi.addPet(makePet(id: id2, status: status));
|
||||||
petApi.addPet(makePet(id: id2, status: status)),
|
await petApi.addPet(makePet(id: id3, status: '${PetStatusEnum.sold}'));
|
||||||
petApi.addPet(makePet(id: id3, status: PetStatusEnum.sold.value))
|
|
||||||
]).then((_) async {
|
var pets = await petApi.findPetsByStatus([status]);
|
||||||
var pets = await petApi.findPetsByStatus([status]);
|
var petIds = pets.map((pet) => pet.id).toList();
|
||||||
var petIds = pets.map((pet) => pet.id).toList();
|
expect(petIds, contains(id1));
|
||||||
expect(petIds, contains(id1));
|
expect(petIds, contains(id2));
|
||||||
expect(petIds, contains(id2));
|
expect(petIds, isNot(contains(id3)));
|
||||||
expect(petIds, isNot(contains(id3)));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('uploads a pet image', () async {
|
test('uploads a pet image', () async {
|
||||||
|
@ -28,8 +28,8 @@ void main() {
|
|||||||
// // use the store api to add an order
|
// // use the store api to add an order
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||||
// expectedPostRequestBody: storeApi.apiClient.serialize(newOrder),
|
// expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// postResponseBody: storeApi.apiClient.serialize(newOrder),
|
// postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// expectedHeaders: {"Content-Type": "application/json"}
|
// expectedHeaders: {"Content-Type": "application/json"}
|
||||||
// );
|
// );
|
||||||
// await storeApi.placeOrder(newOrder);
|
// await storeApi.placeOrder(newOrder);
|
||||||
@ -37,7 +37,7 @@ void main() {
|
|||||||
// // retrieve the same order by id
|
// // retrieve the same order by id
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
||||||
// getResponseBody: storeApi.apiClient.serialize(newOrder),
|
// getResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// );
|
// );
|
||||||
// final placedOrder = await storeApi.getOrderById(id);
|
// final placedOrder = await storeApi.getOrderById(id);
|
||||||
// expect(placedOrder.id, equals(id));
|
// expect(placedOrder.id, equals(id));
|
||||||
@ -51,8 +51,8 @@ void main() {
|
|||||||
// // use the store api to add an order
|
// // use the store api to add an order
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||||
// expectedPostRequestBody: storeApi.apiClient.serialize(newOrder),
|
// expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// postResponseBody: storeApi.apiClient.serialize(newOrder),
|
// postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// expectedHeaders: {"Content-Type": "application/json"}
|
// expectedHeaders: {"Content-Type": "application/json"}
|
||||||
// );
|
// );
|
||||||
// await storeApi.placeOrder(newOrder);
|
// await storeApi.placeOrder(newOrder);
|
||||||
|
@ -29,15 +29,16 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
// retrieve the same user
|
// retrieve the same user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/$username',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/$username',
|
||||||
getResponseBody: userApi.apiClient.serialize(newUser),
|
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
var user = await userApi.getUserByName(username);
|
var user = await userApi.getUserByName(username);
|
||||||
expect(user.id, equals(id));
|
expect(user.id, equals(id));
|
||||||
@ -58,8 +59,8 @@ void main() {
|
|||||||
// use the user api to create a list of users
|
// use the user api to create a list of users
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(users),
|
expectedPostRequestBody: await userApi.apiClient.serializeAsync(users),
|
||||||
postResponseBody: userApi.apiClient.serialize(users),
|
postResponseBody: await userApi.apiClient.serializeAsync(users),
|
||||||
);
|
);
|
||||||
await userApi.createUsersWithListInput(users);
|
await userApi.createUsersWithListInput(users);
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ void main() {
|
|||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl:
|
expectedUrl:
|
||||||
'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}',
|
'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(
|
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||||
users.elementAt(0),
|
users.elementAt(0),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -75,7 +76,7 @@ void main() {
|
|||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl:
|
expectedUrl:
|
||||||
'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}',
|
'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(
|
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||||
users.elementAt(1),
|
users.elementAt(1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -92,8 +93,9 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
newUser.email = email;
|
newUser.email = email;
|
||||||
@ -101,15 +103,15 @@ void main() {
|
|||||||
// use the user api to update the user
|
// use the user api to update the user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||||
expectedPutRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPutRequestBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
putResponseBody: userApi.apiClient.serialize(newUser),
|
putResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.updateUser(username, newUser);
|
await userApi.updateUser(username, newUser);
|
||||||
|
|
||||||
// retrieve the same user
|
// retrieve the same user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(newUser),
|
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
var foundUser = await userApi.getUserByName(username);
|
var foundUser = await userApi.getUserByName(username);
|
||||||
expect(foundUser.email, equals(email));
|
expect(foundUser.email, equals(email));
|
||||||
@ -122,8 +124,9 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
@ -152,8 +155,9 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
part 'api_client.dart';
|
part 'api_client.dart';
|
||||||
|
@ -74,7 +74,7 @@ class PetApi {
|
|||||||
Future<void> addPet(Pet body) async {
|
Future<void> addPet(Pet body) async {
|
||||||
final response = await addPetWithHttpInfo(body);
|
final response = await addPetWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class PetApi {
|
|||||||
Future<void> deletePet(int petId, { String apiKey }) async {
|
Future<void> deletePet(int petId, { String apiKey }) async {
|
||||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,13 +215,13 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||||
final response = await findPetsByStatusWithHttpInfo(status);
|
final response = await findPetsByStatusWithHttpInfo(status);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
@ -293,13 +293,13 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||||
final response = await findPetsByTagsWithHttpInfo(tags);
|
final response = await findPetsByTagsWithHttpInfo(tags);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
@ -370,13 +370,13 @@ class PetApi {
|
|||||||
Future<Pet> getPetById(int petId) async {
|
Future<Pet> getPetById(int petId) async {
|
||||||
final response = await getPetByIdWithHttpInfo(petId);
|
final response = await getPetByIdWithHttpInfo(petId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||||
}
|
}
|
||||||
return Future<Pet>.value(null);
|
return Future<Pet>.value(null);
|
||||||
}
|
}
|
||||||
@ -440,7 +440,7 @@ class PetApi {
|
|||||||
Future<void> updatePet(Pet body) async {
|
Future<void> updatePet(Pet body) async {
|
||||||
final response = await updatePetWithHttpInfo(body);
|
final response = await updatePetWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ class PetApi {
|
|||||||
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
||||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,13 +618,13 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||||
}
|
}
|
||||||
return Future<ApiResponse>.value(null);
|
return Future<ApiResponse>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class StoreApi {
|
|||||||
Future<void> deleteOrder(String orderId) async {
|
Future<void> deleteOrder(String orderId) async {
|
||||||
final response = await deleteOrderWithHttpInfo(orderId);
|
final response = await deleteOrderWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +131,13 @@ class StoreApi {
|
|||||||
Future<Map<String, int>> getInventory() async {
|
Future<Map<String, int>> getInventory() async {
|
||||||
final response = await getInventoryWithHttpInfo();
|
final response = await getInventoryWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
return Map<String, int>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, int>'),);
|
||||||
}
|
}
|
||||||
return Future<Map<String, int>>.value(null);
|
return Future<Map<String, int>>.value(null);
|
||||||
}
|
}
|
||||||
@ -206,13 +206,13 @@ class StoreApi {
|
|||||||
Future<Order> getOrderById(int orderId) async {
|
Future<Order> getOrderById(int orderId) async {
|
||||||
final response = await getOrderByIdWithHttpInfo(orderId);
|
final response = await getOrderByIdWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
@ -276,13 +276,13 @@ class StoreApi {
|
|||||||
Future<Order> placeOrder(Order body) async {
|
Future<Order> placeOrder(Order body) async {
|
||||||
final response = await placeOrderWithHttpInfo(body);
|
final response = await placeOrderWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class UserApi {
|
|||||||
Future<void> createUser(User body) async {
|
Future<void> createUser(User body) async {
|
||||||
final response = await createUserWithHttpInfo(body);
|
final response = await createUserWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithArrayInput(List<User> body) async {
|
Future<void> createUsersWithArrayInput(List<User> body) async {
|
||||||
final response = await createUsersWithArrayInputWithHttpInfo(body);
|
final response = await createUsersWithArrayInputWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithListInput(List<User> body) async {
|
Future<void> createUsersWithListInput(List<User> body) async {
|
||||||
final response = await createUsersWithListInputWithHttpInfo(body);
|
final response = await createUsersWithListInputWithHttpInfo(body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class UserApi {
|
|||||||
Future<void> deleteUser(String username) async {
|
Future<void> deleteUser(String username) async {
|
||||||
final response = await deleteUserWithHttpInfo(username);
|
final response = await deleteUserWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,13 +336,13 @@ class UserApi {
|
|||||||
Future<User> getUserByName(String username) async {
|
Future<User> getUserByName(String username) async {
|
||||||
final response = await getUserByNameWithHttpInfo(username);
|
final response = await getUserByNameWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User;
|
||||||
}
|
}
|
||||||
return Future<User>.value(null);
|
return Future<User>.value(null);
|
||||||
}
|
}
|
||||||
@ -418,13 +418,13 @@ class UserApi {
|
|||||||
Future<String> loginUser(String username, String password) async {
|
Future<String> loginUser(String username, String password) async {
|
||||||
final response = await loginUserWithHttpInfo(username, password);
|
final response = await loginUserWithHttpInfo(username, password);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||||
}
|
}
|
||||||
return Future<String>.value(null);
|
return Future<String>.value(null);
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ class UserApi {
|
|||||||
Future<void> logoutUser() async {
|
Future<void> logoutUser() async {
|
||||||
final response = await logoutUserWithHttpInfo();
|
final response = await logoutUserWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ class UserApi {
|
|||||||
Future<void> updateUser(String username, User body) async {
|
Future<void> updateUser(String username, User body) async {
|
||||||
final response = await updateUserWithHttpInfo(username, body);
|
final response = await updateUserWithHttpInfo(username, body);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,17 +44,16 @@ class ApiClient {
|
|||||||
|
|
||||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||||
|
|
||||||
/// returns an unmodifiable view of the authentications, since none should be added
|
/// Returns an unmodifiable [Map] of the authentications, since none should be added
|
||||||
/// nor deleted
|
/// or deleted.
|
||||||
Map<String, Authentication> get authentications =>
|
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||||
Map.unmodifiable(_authentications);
|
|
||||||
|
|
||||||
T getAuthentication<T extends Authentication>(String name) {
|
T getAuthentication<T extends Authentication>(String name) {
|
||||||
final authentication = _authentications[name];
|
final authentication = _authentications[name];
|
||||||
return authentication is T ? authentication : null;
|
return authentication is T ? authentication : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don’t use a Map<String, String> for queryParams.
|
// We don't use a Map<String, String> for queryParams.
|
||||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||||
Future<Response> invokeAPI(
|
Future<Response> invokeAPI(
|
||||||
String path,
|
String path,
|
||||||
@ -85,7 +84,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||||
if (
|
if (
|
||||||
body is MultipartFile && (nullableContentType == null ||
|
body is MultipartFile && (nullableContentType == null ||
|
||||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||||
@ -115,7 +114,7 @@ class ApiClient {
|
|||||||
|
|
||||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||||
? formParams
|
? formParams
|
||||||
: serialize(body);
|
: await serializeAsync(body);
|
||||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||||
|
|
||||||
switch(method) {
|
switch(method) {
|
||||||
@ -141,7 +140,44 @@ class ApiClient {
|
|||||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
deserialize(json, targetType, growable: growable);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||||
|
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? json
|
||||||
|
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||||
|
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||||
|
|
||||||
|
/// Update query and header parameters based on authentication settings.
|
||||||
|
/// @param authNames The authentications to apply
|
||||||
|
void _updateParamsForAuth(
|
||||||
|
List<String> authNames,
|
||||||
|
List<QueryParam> queryParams,
|
||||||
|
Map<String, String> headerParams,
|
||||||
|
) {
|
||||||
|
authNames.forEach((authName) {
|
||||||
|
final auth = _authentications[authName];
|
||||||
|
if (auth == null) {
|
||||||
|
throw ArgumentError('Authentication undefined: $authName');
|
||||||
|
}
|
||||||
|
auth.applyToParams(queryParams, headerParams);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||||
try {
|
try {
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
case 'String':
|
case 'String':
|
||||||
@ -172,56 +208,65 @@ class ApiClient {
|
|||||||
default:
|
default:
|
||||||
Match match;
|
Match match;
|
||||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toList(growable: true == growable);
|
.toList(growable: growable);
|
||||||
}
|
}
|
||||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return Map.fromIterables(
|
return Map.fromIterables(
|
||||||
value.keys,
|
value.keys,
|
||||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
value.values.map((v) => _deserialize(v, targetType, growable: growable)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} on Exception catch (e, stack) {
|
} catch (error, trace) {
|
||||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
||||||
}
|
}
|
||||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
|
||||||
// Remove all spaces. Necessary for reg expressions as well.
|
|
||||||
targetType = targetType.replaceAll(' ', '');
|
|
||||||
|
|
||||||
return targetType == 'String'
|
|
||||||
? json
|
|
||||||
: _deserialize(jsonDecode(json), targetType, growable: true == growable);
|
|
||||||
}
|
|
||||||
|
|
||||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
|
||||||
|
|
||||||
/// Update query and header parameters based on authentication settings.
|
|
||||||
/// @param authNames The authentications to apply
|
|
||||||
void _updateParamsForAuth(
|
|
||||||
List<String> authNames,
|
|
||||||
List<QueryParam> queryParams,
|
|
||||||
Map<String, String> headerParams,
|
|
||||||
) {
|
|
||||||
authNames.forEach((authName) {
|
|
||||||
final auth = _authentications[authName];
|
|
||||||
if (auth == null) {
|
|
||||||
throw ArgumentError('Authentication undefined: $authName');
|
|
||||||
}
|
|
||||||
auth.applyToParams(queryParams, headerParams);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
class DeserializationMessage {
|
||||||
|
const DeserializationMessage({
|
||||||
|
@required this.json,
|
||||||
|
@required this.targetType,
|
||||||
|
this.growable,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The JSON value to deserialize.
|
||||||
|
final String json;
|
||||||
|
|
||||||
|
/// Target type to deserialize to.
|
||||||
|
final String targetType;
|
||||||
|
|
||||||
|
/// Whether to make deserialized lists or maps growable.
|
||||||
|
final bool growable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
final targetType = message.targetType.replaceAll(' ', '');
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? message.json
|
||||||
|
: ApiClient._deserialize(
|
||||||
|
jsonDecode(message.json),
|
||||||
|
targetType,
|
||||||
|
growable: message.growable == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||||
|
@ -63,7 +63,7 @@ String parameterToString(dynamic value) {
|
|||||||
|
|
||||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||||
String _decodeBodyBytes(Response response) {
|
Future<String> _decodeBodyBytes(Response response) async {
|
||||||
final contentType = response.headers['content-type'];
|
final contentType = response.headers['content-type'];
|
||||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
|
@ -36,11 +36,11 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Setup the fake client then call [petApi.addPet]
|
/// Setup the fake client then call [petApi.addPet]
|
||||||
Future<dynamic> addPet(Pet pet) {
|
Future<dynamic> addPet(Pet pet) async {
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(pet),
|
expectedPostRequestBody: await petApi.apiClient.serializeAsync(pet),
|
||||||
postResponseBody: petApi.apiClient.serialize(pet),
|
postResponseBody: await petApi.apiClient.serializeAsync(pet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
return petApi.addPet(pet);
|
return petApi.addPet(pet);
|
||||||
}
|
}
|
||||||
@ -53,15 +53,16 @@ void main() {
|
|||||||
// use the pet api to add a pet
|
// use the pet api to add a pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
postResponseBody: petApi.apiClient.serialize(newPet),
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
|
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
|
||||||
// retrieve the same pet by id
|
// retrieve the same pet by id
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(newPet),
|
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
);
|
);
|
||||||
final retrievedPet = await petApi.getPetById(id);
|
final retrievedPet = await petApi.getPetById(id);
|
||||||
|
|
||||||
@ -86,8 +87,9 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
postResponseBody: petApi.apiClient.serialize(newPet),
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
|
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
|
||||||
@ -115,8 +117,9 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
postResponseBody: petApi.apiClient.serialize(newPet),
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
|
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
|
||||||
@ -139,7 +142,7 @@ void main() {
|
|||||||
newPet.name = 'Doge';
|
newPet.name = 'Doge';
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(newPet),
|
getResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
);
|
);
|
||||||
final pet = await petApi.getPetById(id);
|
final pet = await petApi.getPetById(id);
|
||||||
expect(pet.name, equals('Doge'));
|
expect(pet.name, equals('Doge'));
|
||||||
@ -154,23 +157,25 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
postResponseBody: petApi.apiClient.serialize(newPet),
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
|
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
|
||||||
// update the same pet
|
// update the same pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPutRequestBody: petApi.apiClient.serialize(updatePet),
|
expectedPutRequestBody:
|
||||||
putResponseBody: petApi.apiClient.serialize(updatePet),
|
await petApi.apiClient.serializeAsync(updatePet),
|
||||||
|
putResponseBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.updatePet(updatePet);
|
await petApi.updatePet(updatePet);
|
||||||
|
|
||||||
// check update worked
|
// check update worked
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
|
||||||
getResponseBody: petApi.apiClient.serialize(updatePet),
|
getResponseBody: await petApi.apiClient.serializeAsync(updatePet),
|
||||||
);
|
);
|
||||||
final pet = await petApi.getPetById(id);
|
final pet = await petApi.getPetById(id);
|
||||||
expect(pet.name, equals(name));
|
expect(pet.name, equals(name));
|
||||||
@ -180,30 +185,31 @@ void main() {
|
|||||||
final id1 = newId();
|
final id1 = newId();
|
||||||
final id2 = newId();
|
final id2 = newId();
|
||||||
final id3 = newId();
|
final id3 = newId();
|
||||||
final status = PetStatusEnum.available.value;
|
final status = '${PetStatusEnum.available}';
|
||||||
final pet1 = makePet(id: id1, status: status);
|
final pet1 = makePet(id: id1, status: status);
|
||||||
final pet2 = makePet(id: id2, status: status);
|
final pet2 = makePet(id: id2, status: status);
|
||||||
final pet3 = makePet(id: id3, status: PetStatusEnum.sold.value);
|
final pet3 = makePet(id: id3, status: '${PetStatusEnum.sold}');
|
||||||
|
|
||||||
return Future.wait([addPet(pet1), addPet(pet2), addPet(pet3)])
|
await addPet(pet1);
|
||||||
.then((_) async {
|
await addPet(pet2);
|
||||||
// retrieve pets by status
|
await addPet(pet3);
|
||||||
petApi.apiClient.client = FakeClient(
|
|
||||||
expectedUrl:
|
|
||||||
'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
|
|
||||||
getResponseBody: petApi.apiClient.serialize([pet1, pet2]),
|
|
||||||
);
|
|
||||||
final pets = await petApi.findPetsByStatus([status]);
|
|
||||||
|
|
||||||
// tests serialisation and deserialisation of enum
|
// retrieve pets by status
|
||||||
final petsByStatus =
|
petApi.apiClient.client = FakeClient(
|
||||||
pets.where((p) => p.status == PetStatusEnum.available);
|
expectedUrl:
|
||||||
expect(petsByStatus.length, equals(2));
|
'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
|
||||||
final petIds = pets.map((pet) => pet.id).toList();
|
getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]),
|
||||||
expect(petIds, contains(id1));
|
);
|
||||||
expect(petIds, contains(id2));
|
final pets = await petApi.findPetsByStatus([status]);
|
||||||
expect(petIds, isNot(contains(id3)));
|
|
||||||
});
|
// tests serialisation and deserialisation of enum
|
||||||
|
final petsByStatus =
|
||||||
|
pets.where((p) => p.status == PetStatusEnum.available);
|
||||||
|
expect(petsByStatus.length, equals(2));
|
||||||
|
final petIds = pets.map((pet) => pet.id).toList();
|
||||||
|
expect(petIds, contains(id1));
|
||||||
|
expect(petIds, contains(id2));
|
||||||
|
expect(petIds, isNot(contains(id3)));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('uploads a pet image', () async {
|
test('uploads a pet image', () async {
|
||||||
@ -216,8 +222,9 @@ void main() {
|
|||||||
// add a new pet
|
// add a new pet
|
||||||
petApi.apiClient.client = FakeClient(
|
petApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
expectedUrl: 'http://petstore.swagger.io/v2/pet',
|
||||||
expectedPostRequestBody: petApi.apiClient.serialize(newPet),
|
expectedPostRequestBody:
|
||||||
postResponseBody: petApi.apiClient.serialize(newPet),
|
await petApi.apiClient.serializeAsync(newPet),
|
||||||
|
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
|
||||||
expectedHeaders: {'Content-Type': 'application/json'});
|
expectedHeaders: {'Content-Type': 'application/json'});
|
||||||
await petApi.addPet(newPet);
|
await petApi.addPet(newPet);
|
||||||
|
|
||||||
|
@ -81,19 +81,17 @@ void main() {
|
|||||||
var id1 = newId();
|
var id1 = newId();
|
||||||
var id2 = newId();
|
var id2 = newId();
|
||||||
var id3 = newId();
|
var id3 = newId();
|
||||||
var status = PetStatusEnum.available.value;
|
var status = '${PetStatusEnum.available}';
|
||||||
|
|
||||||
return Future.wait([
|
await petApi.addPet(makePet(id: id1, status: status));
|
||||||
petApi.addPet(makePet(id: id1, status: status)),
|
await petApi.addPet(makePet(id: id2, status: status));
|
||||||
petApi.addPet(makePet(id: id2, status: status)),
|
await petApi.addPet(makePet(id: id3, status: '${PetStatusEnum.sold}'));
|
||||||
petApi.addPet(makePet(id: id3, status: PetStatusEnum.sold.value))
|
|
||||||
]).then((_) async {
|
var pets = await petApi.findPetsByStatus([status]);
|
||||||
var pets = await petApi.findPetsByStatus([status]);
|
var petIds = pets.map((pet) => pet.id).toList();
|
||||||
var petIds = pets.map((pet) => pet.id).toList();
|
expect(petIds, contains(id1));
|
||||||
expect(petIds, contains(id1));
|
expect(petIds, contains(id2));
|
||||||
expect(petIds, contains(id2));
|
expect(petIds, isNot(contains(id3)));
|
||||||
expect(petIds, isNot(contains(id3)));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('uploads a pet image', () async {
|
test('uploads a pet image', () async {
|
||||||
|
@ -28,8 +28,8 @@ void main() {
|
|||||||
// // use the store api to add an order
|
// // use the store api to add an order
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||||
// expectedPostRequestBody: storeApi.apiClient.serialize(newOrder),
|
// expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// postResponseBody: storeApi.apiClient.serialize(newOrder),
|
// postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// expectedHeaders: {"Content-Type": "application/json"}
|
// expectedHeaders: {"Content-Type": "application/json"}
|
||||||
// );
|
// );
|
||||||
// await storeApi.placeOrder(newOrder);
|
// await storeApi.placeOrder(newOrder);
|
||||||
@ -37,7 +37,7 @@ void main() {
|
|||||||
// // retrieve the same order by id
|
// // retrieve the same order by id
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order/$id',
|
||||||
// getResponseBody: storeApi.apiClient.serialize(newOrder),
|
// getResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// );
|
// );
|
||||||
// final placedOrder = await storeApi.getOrderById(id);
|
// final placedOrder = await storeApi.getOrderById(id);
|
||||||
// expect(placedOrder.id, equals(id));
|
// expect(placedOrder.id, equals(id));
|
||||||
@ -51,8 +51,8 @@ void main() {
|
|||||||
// // use the store api to add an order
|
// // use the store api to add an order
|
||||||
// storeApi.apiClient.client = FakeClient(
|
// storeApi.apiClient.client = FakeClient(
|
||||||
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
// expectedUrl: 'http://petstore.swagger.io/v2/store/order',
|
||||||
// expectedPostRequestBody: storeApi.apiClient.serialize(newOrder),
|
// expectedPostRequestBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// postResponseBody: storeApi.apiClient.serialize(newOrder),
|
// postResponseBody: await storeApi.apiClient.serializeAsync(newOrder),
|
||||||
// expectedHeaders: {"Content-Type": "application/json"}
|
// expectedHeaders: {"Content-Type": "application/json"}
|
||||||
// );
|
// );
|
||||||
// await storeApi.placeOrder(newOrder);
|
// await storeApi.placeOrder(newOrder);
|
||||||
|
@ -29,16 +29,17 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
// retrieve the same user
|
// retrieve the same user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/$username',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/$username',
|
||||||
getResponseBody: userApi.apiClient.serialize(newUser),
|
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
var user = await userApi.getUserByName(username);
|
var user = await userApi.getUserByName(username);
|
||||||
expect(user.id, equals(id));
|
expect(user.id, equals(id));
|
||||||
@ -59,9 +60,9 @@ void main() {
|
|||||||
// use the user api to create a list of users
|
// use the user api to create a list of users
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/createWithList',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(users),
|
expectedPostRequestBody: await userApi.apiClient.serializeAsync(users),
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
postResponseBody: userApi.apiClient.serialize(users),
|
postResponseBody: await userApi.apiClient.serializeAsync(users),
|
||||||
);
|
);
|
||||||
await userApi.createUsersWithListInput(users);
|
await userApi.createUsersWithListInput(users);
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ void main() {
|
|||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl:
|
expectedUrl:
|
||||||
'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}',
|
'http://petstore.swagger.io/v2/user/${users.elementAt(0).username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(
|
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||||
users.elementAt(0),
|
users.elementAt(0),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -77,7 +78,7 @@ void main() {
|
|||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl:
|
expectedUrl:
|
||||||
'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}',
|
'http://petstore.swagger.io/v2/user/${users.elementAt(1).username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(
|
getResponseBody: await userApi.apiClient.serializeAsync(
|
||||||
users.elementAt(1),
|
users.elementAt(1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -94,9 +95,10 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
newUser.email = email;
|
newUser.email = email;
|
||||||
@ -104,16 +106,16 @@ void main() {
|
|||||||
// use the user api to update the user
|
// use the user api to update the user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||||
expectedPutRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPutRequestBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
putResponseBody: userApi.apiClient.serialize(newUser),
|
putResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.updateUser(username, newUser);
|
await userApi.updateUser(username, newUser);
|
||||||
|
|
||||||
// retrieve the same user
|
// retrieve the same user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
expectedUrl: 'http://petstore.swagger.io/v2/user/${newUser.username}',
|
||||||
getResponseBody: userApi.apiClient.serialize(newUser),
|
getResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
var foundUser = await userApi.getUserByName(username);
|
var foundUser = await userApi.getUserByName(username);
|
||||||
expect(foundUser.email, equals(email));
|
expect(foundUser.email, equals(email));
|
||||||
@ -126,9 +128,10 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
@ -157,9 +160,10 @@ void main() {
|
|||||||
// use the user api to create a user
|
// use the user api to create a user
|
||||||
userApi.apiClient.client = FakeClient(
|
userApi.apiClient.client = FakeClient(
|
||||||
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
expectedUrl: 'http://petstore.swagger.io/v2/user',
|
||||||
expectedPostRequestBody: userApi.apiClient.serialize(newUser),
|
expectedPostRequestBody:
|
||||||
expectedHeaders: { 'Content-Type': 'application/json' },
|
await userApi.apiClient.serializeAsync(newUser),
|
||||||
postResponseBody: userApi.apiClient.serialize(newUser),
|
expectedHeaders: {'Content-Type': 'application/json'},
|
||||||
|
postResponseBody: await userApi.apiClient.serializeAsync(newUser),
|
||||||
);
|
);
|
||||||
await userApi.createUser(newUser);
|
await userApi.createUser(newUser);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
part 'api_client.dart';
|
part 'api_client.dart';
|
||||||
|
@ -74,13 +74,13 @@ class PetApi {
|
|||||||
Future<Pet> addPet(Pet pet) async {
|
Future<Pet> addPet(Pet pet) async {
|
||||||
final response = await addPetWithHttpInfo(pet);
|
final response = await addPetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||||
}
|
}
|
||||||
return Future<Pet>.value(null);
|
return Future<Pet>.value(null);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ class PetApi {
|
|||||||
Future<void> deletePet(int petId, { String apiKey }) async {
|
Future<void> deletePet(int petId, { String apiKey }) async {
|
||||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,13 +222,13 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||||
final response = await findPetsByStatusWithHttpInfo(status);
|
final response = await findPetsByStatusWithHttpInfo(status);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
@ -300,13 +300,13 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||||
final response = await findPetsByTagsWithHttpInfo(tags);
|
final response = await findPetsByTagsWithHttpInfo(tags);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
@ -377,13 +377,13 @@ class PetApi {
|
|||||||
Future<Pet> getPetById(int petId) async {
|
Future<Pet> getPetById(int petId) async {
|
||||||
final response = await getPetByIdWithHttpInfo(petId);
|
final response = await getPetByIdWithHttpInfo(petId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||||
}
|
}
|
||||||
return Future<Pet>.value(null);
|
return Future<Pet>.value(null);
|
||||||
}
|
}
|
||||||
@ -447,13 +447,13 @@ class PetApi {
|
|||||||
Future<Pet> updatePet(Pet pet) async {
|
Future<Pet> updatePet(Pet pet) async {
|
||||||
final response = await updatePetWithHttpInfo(pet);
|
final response = await updatePetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||||
}
|
}
|
||||||
return Future<Pet>.value(null);
|
return Future<Pet>.value(null);
|
||||||
}
|
}
|
||||||
@ -544,7 +544,7 @@ class PetApi {
|
|||||||
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
||||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,13 +632,13 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||||
}
|
}
|
||||||
return Future<ApiResponse>.value(null);
|
return Future<ApiResponse>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class StoreApi {
|
|||||||
Future<void> deleteOrder(String orderId) async {
|
Future<void> deleteOrder(String orderId) async {
|
||||||
final response = await deleteOrderWithHttpInfo(orderId);
|
final response = await deleteOrderWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +131,13 @@ class StoreApi {
|
|||||||
Future<Map<String, int>> getInventory() async {
|
Future<Map<String, int>> getInventory() async {
|
||||||
final response = await getInventoryWithHttpInfo();
|
final response = await getInventoryWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
return Map<String, int>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, int>'),);
|
||||||
}
|
}
|
||||||
return Future<Map<String, int>>.value(null);
|
return Future<Map<String, int>>.value(null);
|
||||||
}
|
}
|
||||||
@ -206,13 +206,13 @@ class StoreApi {
|
|||||||
Future<Order> getOrderById(int orderId) async {
|
Future<Order> getOrderById(int orderId) async {
|
||||||
final response = await getOrderByIdWithHttpInfo(orderId);
|
final response = await getOrderByIdWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
@ -276,13 +276,13 @@ class StoreApi {
|
|||||||
Future<Order> placeOrder(Order order) async {
|
Future<Order> placeOrder(Order order) async {
|
||||||
final response = await placeOrderWithHttpInfo(order);
|
final response = await placeOrderWithHttpInfo(order);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class UserApi {
|
|||||||
Future<void> createUser(User user) async {
|
Future<void> createUser(User user) async {
|
||||||
final response = await createUserWithHttpInfo(user);
|
final response = await createUserWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||||
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithListInput(List<User> user) async {
|
Future<void> createUsersWithListInput(List<User> user) async {
|
||||||
final response = await createUsersWithListInputWithHttpInfo(user);
|
final response = await createUsersWithListInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class UserApi {
|
|||||||
Future<void> deleteUser(String username) async {
|
Future<void> deleteUser(String username) async {
|
||||||
final response = await deleteUserWithHttpInfo(username);
|
final response = await deleteUserWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,13 +336,13 @@ class UserApi {
|
|||||||
Future<User> getUserByName(String username) async {
|
Future<User> getUserByName(String username) async {
|
||||||
final response = await getUserByNameWithHttpInfo(username);
|
final response = await getUserByNameWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User;
|
||||||
}
|
}
|
||||||
return Future<User>.value(null);
|
return Future<User>.value(null);
|
||||||
}
|
}
|
||||||
@ -418,13 +418,13 @@ class UserApi {
|
|||||||
Future<String> loginUser(String username, String password) async {
|
Future<String> loginUser(String username, String password) async {
|
||||||
final response = await loginUserWithHttpInfo(username, password);
|
final response = await loginUserWithHttpInfo(username, password);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||||
}
|
}
|
||||||
return Future<String>.value(null);
|
return Future<String>.value(null);
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ class UserApi {
|
|||||||
Future<void> logoutUser() async {
|
Future<void> logoutUser() async {
|
||||||
final response = await logoutUserWithHttpInfo();
|
final response = await logoutUserWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ class UserApi {
|
|||||||
Future<void> updateUser(String username, User user) async {
|
Future<void> updateUser(String username, User user) async {
|
||||||
final response = await updateUserWithHttpInfo(username, user);
|
final response = await updateUserWithHttpInfo(username, user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,17 +44,16 @@ class ApiClient {
|
|||||||
|
|
||||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||||
|
|
||||||
/// returns an unmodifiable view of the authentications, since none should be added
|
/// Returns an unmodifiable [Map] of the authentications, since none should be added
|
||||||
/// nor deleted
|
/// or deleted.
|
||||||
Map<String, Authentication> get authentications =>
|
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||||
Map.unmodifiable(_authentications);
|
|
||||||
|
|
||||||
T getAuthentication<T extends Authentication>(String name) {
|
T getAuthentication<T extends Authentication>(String name) {
|
||||||
final authentication = _authentications[name];
|
final authentication = _authentications[name];
|
||||||
return authentication is T ? authentication : null;
|
return authentication is T ? authentication : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don’t use a Map<String, String> for queryParams.
|
// We don't use a Map<String, String> for queryParams.
|
||||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||||
Future<Response> invokeAPI(
|
Future<Response> invokeAPI(
|
||||||
String path,
|
String path,
|
||||||
@ -85,7 +84,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||||
if (
|
if (
|
||||||
body is MultipartFile && (nullableContentType == null ||
|
body is MultipartFile && (nullableContentType == null ||
|
||||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||||
@ -115,7 +114,7 @@ class ApiClient {
|
|||||||
|
|
||||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||||
? formParams
|
? formParams
|
||||||
: serialize(body);
|
: await serializeAsync(body);
|
||||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||||
|
|
||||||
switch(method) {
|
switch(method) {
|
||||||
@ -141,7 +140,44 @@ class ApiClient {
|
|||||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
deserialize(json, targetType, growable: growable);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||||
|
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? json
|
||||||
|
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||||
|
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||||
|
|
||||||
|
/// Update query and header parameters based on authentication settings.
|
||||||
|
/// @param authNames The authentications to apply
|
||||||
|
void _updateParamsForAuth(
|
||||||
|
List<String> authNames,
|
||||||
|
List<QueryParam> queryParams,
|
||||||
|
Map<String, String> headerParams,
|
||||||
|
) {
|
||||||
|
authNames.forEach((authName) {
|
||||||
|
final auth = _authentications[authName];
|
||||||
|
if (auth == null) {
|
||||||
|
throw ArgumentError('Authentication undefined: $authName');
|
||||||
|
}
|
||||||
|
auth.applyToParams(queryParams, headerParams);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||||
try {
|
try {
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
case 'String':
|
case 'String':
|
||||||
@ -172,56 +208,65 @@ class ApiClient {
|
|||||||
default:
|
default:
|
||||||
Match match;
|
Match match;
|
||||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toList(growable: true == growable);
|
.toList(growable: growable);
|
||||||
}
|
}
|
||||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return Map.fromIterables(
|
return Map.fromIterables(
|
||||||
value.keys,
|
value.keys,
|
||||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
value.values.map((v) => _deserialize(v, targetType, growable: growable)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} on Exception catch (e, stack) {
|
} catch (error, trace) {
|
||||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
||||||
}
|
}
|
||||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
|
||||||
// Remove all spaces. Necessary for reg expressions as well.
|
|
||||||
targetType = targetType.replaceAll(' ', '');
|
|
||||||
|
|
||||||
return targetType == 'String'
|
|
||||||
? json
|
|
||||||
: _deserialize(jsonDecode(json), targetType, growable: true == growable);
|
|
||||||
}
|
|
||||||
|
|
||||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
|
||||||
|
|
||||||
/// Update query and header parameters based on authentication settings.
|
|
||||||
/// @param authNames The authentications to apply
|
|
||||||
void _updateParamsForAuth(
|
|
||||||
List<String> authNames,
|
|
||||||
List<QueryParam> queryParams,
|
|
||||||
Map<String, String> headerParams,
|
|
||||||
) {
|
|
||||||
authNames.forEach((authName) {
|
|
||||||
final auth = _authentications[authName];
|
|
||||||
if (auth == null) {
|
|
||||||
throw ArgumentError('Authentication undefined: $authName');
|
|
||||||
}
|
|
||||||
auth.applyToParams(queryParams, headerParams);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
class DeserializationMessage {
|
||||||
|
const DeserializationMessage({
|
||||||
|
@required this.json,
|
||||||
|
@required this.targetType,
|
||||||
|
this.growable,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The JSON value to deserialize.
|
||||||
|
final String json;
|
||||||
|
|
||||||
|
/// Target type to deserialize to.
|
||||||
|
final String targetType;
|
||||||
|
|
||||||
|
/// Whether to make deserialized lists or maps growable.
|
||||||
|
final bool growable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
final targetType = message.targetType.replaceAll(' ', '');
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? message.json
|
||||||
|
: ApiClient._deserialize(
|
||||||
|
jsonDecode(message.json),
|
||||||
|
targetType,
|
||||||
|
growable: message.growable == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||||
|
@ -63,7 +63,7 @@ String parameterToString(dynamic value) {
|
|||||||
|
|
||||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||||
String _decodeBodyBytes(Response response) {
|
Future<String> _decodeBodyBytes(Response response) async {
|
||||||
final contentType = response.headers['content-type'];
|
final contentType = response.headers['content-type'];
|
||||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
|
@ -15,7 +15,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
part 'api_client.dart';
|
part 'api_client.dart';
|
||||||
|
@ -78,13 +78,13 @@ class AnotherFakeApi {
|
|||||||
Future<ModelClient> call123testSpecialTags(ModelClient modelClient) async {
|
Future<ModelClient> call123testSpecialTags(ModelClient modelClient) async {
|
||||||
final response = await call123testSpecialTagsWithHttpInfo(modelClient);
|
final response = await call123testSpecialTagsWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||||
}
|
}
|
||||||
return Future<ModelClient>.value(null);
|
return Future<ModelClient>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,13 @@ class DefaultApi {
|
|||||||
Future<InlineResponseDefault> fooGet() async {
|
Future<InlineResponseDefault> fooGet() async {
|
||||||
final response = await fooGetWithHttpInfo();
|
final response = await fooGetWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'InlineResponseDefault') as InlineResponseDefault;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'InlineResponseDefault',) as InlineResponseDefault;
|
||||||
}
|
}
|
||||||
return Future<InlineResponseDefault>.value(null);
|
return Future<InlineResponseDefault>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,13 @@ class FakeApi {
|
|||||||
Future<HealthCheckResult> fakeHealthGet() async {
|
Future<HealthCheckResult> fakeHealthGet() async {
|
||||||
final response = await fakeHealthGetWithHttpInfo();
|
final response = await fakeHealthGetWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'HealthCheckResult') as HealthCheckResult;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'HealthCheckResult',) as HealthCheckResult;
|
||||||
}
|
}
|
||||||
return Future<HealthCheckResult>.value(null);
|
return Future<HealthCheckResult>.value(null);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ class FakeApi {
|
|||||||
Future<void> fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async {
|
Future<void> fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async {
|
||||||
final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 );
|
final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,13 +209,13 @@ class FakeApi {
|
|||||||
Future<bool> fakeOuterBooleanSerialize({ bool body }) async {
|
Future<bool> fakeOuterBooleanSerialize({ bool body }) async {
|
||||||
final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'bool') as bool;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'bool',) as bool;
|
||||||
}
|
}
|
||||||
return Future<bool>.value(null);
|
return Future<bool>.value(null);
|
||||||
}
|
}
|
||||||
@ -276,13 +276,13 @@ class FakeApi {
|
|||||||
Future<OuterComposite> fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async {
|
Future<OuterComposite> fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async {
|
||||||
final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite );
|
final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterComposite') as OuterComposite;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterComposite',) as OuterComposite;
|
||||||
}
|
}
|
||||||
return Future<OuterComposite>.value(null);
|
return Future<OuterComposite>.value(null);
|
||||||
}
|
}
|
||||||
@ -343,13 +343,13 @@ class FakeApi {
|
|||||||
Future<num> fakeOuterNumberSerialize({ num body }) async {
|
Future<num> fakeOuterNumberSerialize({ num body }) async {
|
||||||
final response = await fakeOuterNumberSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterNumberSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'num') as num;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'num',) as num;
|
||||||
}
|
}
|
||||||
return Future<num>.value(null);
|
return Future<num>.value(null);
|
||||||
}
|
}
|
||||||
@ -410,13 +410,13 @@ class FakeApi {
|
|||||||
Future<String> fakeOuterStringSerialize({ String body }) async {
|
Future<String> fakeOuterStringSerialize({ String body }) async {
|
||||||
final response = await fakeOuterStringSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterStringSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||||
}
|
}
|
||||||
return Future<String>.value(null);
|
return Future<String>.value(null);
|
||||||
}
|
}
|
||||||
@ -480,13 +480,13 @@ class FakeApi {
|
|||||||
Future<OuterObjectWithEnumProperty> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async {
|
Future<OuterObjectWithEnumProperty> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async {
|
||||||
final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty);
|
final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterObjectWithEnumProperty') as OuterObjectWithEnumProperty;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'OuterObjectWithEnumProperty',) as OuterObjectWithEnumProperty;
|
||||||
}
|
}
|
||||||
return Future<OuterObjectWithEnumProperty>.value(null);
|
return Future<OuterObjectWithEnumProperty>.value(null);
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ class FakeApi {
|
|||||||
Future<void> testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async {
|
Future<void> testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async {
|
||||||
final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass);
|
final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ class FakeApi {
|
|||||||
Future<void> testBodyWithQueryParams(String query, User user) async {
|
Future<void> testBodyWithQueryParams(String query, User user) async {
|
||||||
final response = await testBodyWithQueryParamsWithHttpInfo(query, user);
|
final response = await testBodyWithQueryParamsWithHttpInfo(query, user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,13 +680,13 @@ class FakeApi {
|
|||||||
Future<ModelClient> testClientModel(ModelClient modelClient) async {
|
Future<ModelClient> testClientModel(ModelClient modelClient) async {
|
||||||
final response = await testClientModelWithHttpInfo(modelClient);
|
final response = await testClientModelWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||||
}
|
}
|
||||||
return Future<ModelClient>.value(null);
|
return Future<ModelClient>.value(null);
|
||||||
}
|
}
|
||||||
@ -937,7 +937,7 @@ class FakeApi {
|
|||||||
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async {
|
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async {
|
||||||
final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback );
|
final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1077,7 @@ class FakeApi {
|
|||||||
Future<void> testEnumParameters({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
Future<void> testEnumParameters({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
||||||
final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString );
|
final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,7 +1194,7 @@ class FakeApi {
|
|||||||
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async {
|
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async {
|
||||||
final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group );
|
final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,7 +1257,7 @@ class FakeApi {
|
|||||||
Future<void> testInlineAdditionalProperties(Map<String, String> requestBody) async {
|
Future<void> testInlineAdditionalProperties(Map<String, String> requestBody) async {
|
||||||
final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody);
|
final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,7 +1343,7 @@ class FakeApi {
|
|||||||
Future<void> testJsonFormData(String param, String param2) async {
|
Future<void> testJsonFormData(String param, String param2) async {
|
||||||
final response = await testJsonFormDataWithHttpInfo(param, param2);
|
final response = await testJsonFormDataWithHttpInfo(param, param2);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1438,7 +1438,7 @@ class FakeApi {
|
|||||||
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context) async {
|
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context) async {
|
||||||
final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context);
|
final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,13 +78,13 @@ class FakeClassnameTags123Api {
|
|||||||
Future<ModelClient> testClassname(ModelClient modelClient) async {
|
Future<ModelClient> testClassname(ModelClient modelClient) async {
|
||||||
final response = await testClassnameWithHttpInfo(modelClient);
|
final response = await testClassnameWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ModelClient',) as ModelClient;
|
||||||
}
|
}
|
||||||
return Future<ModelClient>.value(null);
|
return Future<ModelClient>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ class PetApi {
|
|||||||
Future<void> addPet(Pet pet) async {
|
Future<void> addPet(Pet pet) async {
|
||||||
final response = await addPetWithHttpInfo(pet);
|
final response = await addPetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class PetApi {
|
|||||||
Future<void> deletePet(int petId, { String apiKey }) async {
|
Future<void> deletePet(int petId, { String apiKey }) async {
|
||||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,13 +215,13 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||||
final response = await findPetsByStatusWithHttpInfo(status);
|
final response = await findPetsByStatusWithHttpInfo(status);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'List<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toList(growable: false);
|
.toList(growable: false);
|
||||||
}
|
}
|
||||||
@ -293,13 +293,13 @@ class PetApi {
|
|||||||
Future<Set<Pet>> findPetsByTags(Set<String> tags) async {
|
Future<Set<Pet>> findPetsByTags(Set<String> tags) async {
|
||||||
final response = await findPetsByTagsWithHttpInfo(tags);
|
final response = await findPetsByTagsWithHttpInfo(tags);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'Set<Pet>') as List)
|
return (await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Set<Pet>') as List)
|
||||||
.cast<Pet>()
|
.cast<Pet>()
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
@ -370,13 +370,13 @@ class PetApi {
|
|||||||
Future<Pet> getPetById(int petId) async {
|
Future<Pet> getPetById(int petId) async {
|
||||||
final response = await getPetByIdWithHttpInfo(petId);
|
final response = await getPetByIdWithHttpInfo(petId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
|
||||||
}
|
}
|
||||||
return Future<Pet>.value(null);
|
return Future<Pet>.value(null);
|
||||||
}
|
}
|
||||||
@ -440,7 +440,7 @@ class PetApi {
|
|||||||
Future<void> updatePet(Pet pet) async {
|
Future<void> updatePet(Pet pet) async {
|
||||||
final response = await updatePetWithHttpInfo(pet);
|
final response = await updatePetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ class PetApi {
|
|||||||
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
||||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,13 +618,13 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||||
}
|
}
|
||||||
return Future<ApiResponse>.value(null);
|
return Future<ApiResponse>.value(null);
|
||||||
}
|
}
|
||||||
@ -716,13 +716,13 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
||||||
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata );
|
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
|
||||||
}
|
}
|
||||||
return Future<ApiResponse>.value(null);
|
return Future<ApiResponse>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class StoreApi {
|
|||||||
Future<void> deleteOrder(String orderId) async {
|
Future<void> deleteOrder(String orderId) async {
|
||||||
final response = await deleteOrderWithHttpInfo(orderId);
|
final response = await deleteOrderWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,13 +131,13 @@ class StoreApi {
|
|||||||
Future<Map<String, int>> getInventory() async {
|
Future<Map<String, int>> getInventory() async {
|
||||||
final response = await getInventoryWithHttpInfo();
|
final response = await getInventoryWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
return Map<String, int>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, int>'),);
|
||||||
}
|
}
|
||||||
return Future<Map<String, int>>.value(null);
|
return Future<Map<String, int>>.value(null);
|
||||||
}
|
}
|
||||||
@ -206,13 +206,13 @@ class StoreApi {
|
|||||||
Future<Order> getOrderById(int orderId) async {
|
Future<Order> getOrderById(int orderId) async {
|
||||||
final response = await getOrderByIdWithHttpInfo(orderId);
|
final response = await getOrderByIdWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
@ -276,13 +276,13 @@ class StoreApi {
|
|||||||
Future<Order> placeOrder(Order order) async {
|
Future<Order> placeOrder(Order order) async {
|
||||||
final response = await placeOrderWithHttpInfo(order);
|
final response = await placeOrderWithHttpInfo(order);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Order',) as Order;
|
||||||
}
|
}
|
||||||
return Future<Order>.value(null);
|
return Future<Order>.value(null);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class UserApi {
|
|||||||
Future<void> createUser(User user) async {
|
Future<void> createUser(User user) async {
|
||||||
final response = await createUserWithHttpInfo(user);
|
final response = await createUserWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||||
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithListInput(List<User> user) async {
|
Future<void> createUsersWithListInput(List<User> user) async {
|
||||||
final response = await createUsersWithListInputWithHttpInfo(user);
|
final response = await createUsersWithListInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class UserApi {
|
|||||||
Future<void> deleteUser(String username) async {
|
Future<void> deleteUser(String username) async {
|
||||||
final response = await deleteUserWithHttpInfo(username);
|
final response = await deleteUserWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,13 +336,13 @@ class UserApi {
|
|||||||
Future<User> getUserByName(String username) async {
|
Future<User> getUserByName(String username) async {
|
||||||
final response = await getUserByNameWithHttpInfo(username);
|
final response = await getUserByNameWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'User',) as User;
|
||||||
}
|
}
|
||||||
return Future<User>.value(null);
|
return Future<User>.value(null);
|
||||||
}
|
}
|
||||||
@ -418,13 +418,13 @@ class UserApi {
|
|||||||
Future<String> loginUser(String username, String password) async {
|
Future<String> loginUser(String username, String password) async {
|
||||||
final response = await loginUserWithHttpInfo(username, password);
|
final response = await loginUserWithHttpInfo(username, password);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
// FormatException when trying to decode an empty string.
|
// FormatException when trying to decode an empty string.
|
||||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;
|
||||||
}
|
}
|
||||||
return Future<String>.value(null);
|
return Future<String>.value(null);
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ class UserApi {
|
|||||||
Future<void> logoutUser() async {
|
Future<void> logoutUser() async {
|
||||||
final response = await logoutUserWithHttpInfo();
|
final response = await logoutUserWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ class UserApi {
|
|||||||
Future<void> updateUser(String username, User user) async {
|
Future<void> updateUser(String username, User user) async {
|
||||||
final response = await updateUserWithHttpInfo(username, user);
|
final response = await updateUserWithHttpInfo(username, user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,16 @@ class ApiClient {
|
|||||||
|
|
||||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||||
|
|
||||||
/// returns an unmodifiable view of the authentications, since none should be added
|
/// Returns an unmodifiable [Map] of the authentications, since none should be added
|
||||||
/// nor deleted
|
/// or deleted.
|
||||||
Map<String, Authentication> get authentications =>
|
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||||
Map.unmodifiable(_authentications);
|
|
||||||
|
|
||||||
T getAuthentication<T extends Authentication>(String name) {
|
T getAuthentication<T extends Authentication>(String name) {
|
||||||
final authentication = _authentications[name];
|
final authentication = _authentications[name];
|
||||||
return authentication is T ? authentication : null;
|
return authentication is T ? authentication : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don’t use a Map<String, String> for queryParams.
|
// We don't use a Map<String, String> for queryParams.
|
||||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||||
Future<Response> invokeAPI(
|
Future<Response> invokeAPI(
|
||||||
String path,
|
String path,
|
||||||
@ -88,7 +87,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||||
if (
|
if (
|
||||||
body is MultipartFile && (nullableContentType == null ||
|
body is MultipartFile && (nullableContentType == null ||
|
||||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||||
@ -118,7 +117,7 @@ class ApiClient {
|
|||||||
|
|
||||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||||
? formParams
|
? formParams
|
||||||
: serialize(body);
|
: await serializeAsync(body);
|
||||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||||
|
|
||||||
switch(method) {
|
switch(method) {
|
||||||
@ -144,7 +143,44 @@ class ApiClient {
|
|||||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
Future<dynamic> deserializeAsync(String json, String targetType, {bool growable}) async =>
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
deserialize(json, targetType, growable: growable);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
|
||||||
|
dynamic deserialize(String json, String targetType, {bool growable}) {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? json
|
||||||
|
: _deserialize(jsonDecode(json), targetType, growable: growable == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||||
|
|
||||||
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||||
|
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||||
|
|
||||||
|
/// Update query and header parameters based on authentication settings.
|
||||||
|
/// @param authNames The authentications to apply
|
||||||
|
void _updateParamsForAuth(
|
||||||
|
List<String> authNames,
|
||||||
|
List<QueryParam> queryParams,
|
||||||
|
Map<String, String> headerParams,
|
||||||
|
) {
|
||||||
|
authNames.forEach((authName) {
|
||||||
|
final auth = _authentications[authName];
|
||||||
|
if (auth == null) {
|
||||||
|
throw ArgumentError('Authentication undefined: $authName');
|
||||||
|
}
|
||||||
|
auth.applyToParams(queryParams, headerParams);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||||
try {
|
try {
|
||||||
switch (targetType) {
|
switch (targetType) {
|
||||||
case 'String':
|
case 'String':
|
||||||
@ -256,56 +292,65 @@ class ApiClient {
|
|||||||
default:
|
default:
|
||||||
Match match;
|
Match match;
|
||||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toList(growable: true == growable);
|
.toList(growable: growable);
|
||||||
}
|
}
|
||||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return value
|
return value
|
||||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
.map((v) => _deserialize(v, targetType, growable: growable))
|
||||||
.toSet();
|
.toSet();
|
||||||
}
|
}
|
||||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||||
final newTargetType = match[1];
|
targetType = match[1]; // ignore: parameter_assignments
|
||||||
return Map.fromIterables(
|
return Map.fromIterables(
|
||||||
value.keys,
|
value.keys,
|
||||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
value.values.map((v) => _deserialize(v, targetType, growable: growable)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} on Exception catch (e, stack) {
|
} catch (error, trace) {
|
||||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
|
||||||
}
|
}
|
||||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic deserialize(String json, String targetType, {bool growable}) {
|
|
||||||
// Remove all spaces. Necessary for reg expressions as well.
|
|
||||||
targetType = targetType.replaceAll(' ', '');
|
|
||||||
|
|
||||||
return targetType == 'String'
|
|
||||||
? json
|
|
||||||
: _deserialize(jsonDecode(json), targetType, growable: true == growable);
|
|
||||||
}
|
|
||||||
|
|
||||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
|
||||||
|
|
||||||
/// Update query and header parameters based on authentication settings.
|
|
||||||
/// @param authNames The authentications to apply
|
|
||||||
void _updateParamsForAuth(
|
|
||||||
List<String> authNames,
|
|
||||||
List<QueryParam> queryParams,
|
|
||||||
Map<String, String> headerParams,
|
|
||||||
) {
|
|
||||||
authNames.forEach((authName) {
|
|
||||||
final auth = _authentications[authName];
|
|
||||||
if (auth == null) {
|
|
||||||
throw ArgumentError('Authentication undefined: $authName');
|
|
||||||
}
|
|
||||||
auth.applyToParams(queryParams, headerParams);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
class DeserializationMessage {
|
||||||
|
const DeserializationMessage({
|
||||||
|
@required this.json,
|
||||||
|
@required this.targetType,
|
||||||
|
this.growable,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The JSON value to deserialize.
|
||||||
|
final String json;
|
||||||
|
|
||||||
|
/// Target type to deserialize to.
|
||||||
|
final String targetType;
|
||||||
|
|
||||||
|
/// Whether to make deserialized lists or maps growable.
|
||||||
|
final bool growable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<dynamic> deserializeAsync(DeserializationMessage message) async {
|
||||||
|
// Remove all spaces. Necessary for regular expressions as well.
|
||||||
|
final targetType = message.targetType.replaceAll(' ', '');
|
||||||
|
|
||||||
|
// If the expected target type is String, nothing to do...
|
||||||
|
return targetType == 'String'
|
||||||
|
? message.json
|
||||||
|
: ApiClient._deserialize(
|
||||||
|
jsonDecode(message.json),
|
||||||
|
targetType,
|
||||||
|
growable: message.growable == true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||||
|
@ -78,7 +78,7 @@ String parameterToString(dynamic value) {
|
|||||||
|
|
||||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||||
String _decodeBodyBytes(Response response) {
|
Future<String> _decodeBodyBytes(Response response) async {
|
||||||
final contentType = response.headers['content-type'];
|
final contentType = response.headers['content-type'];
|
||||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
|
@ -15,9 +15,8 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:http/http.dart';
|
import 'package:http/http.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
import 'package:json_annotation/json_annotation.dart';
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
part 'api_client.dart';
|
part 'api_client.dart';
|
||||||
part 'api_helper.dart';
|
part 'api_helper.dart';
|
||||||
|
@ -78,7 +78,7 @@ class AnotherFakeApi {
|
|||||||
Future<ModelClient> call123testSpecialTags(ModelClient modelClient) async {
|
Future<ModelClient> call123testSpecialTags(ModelClient modelClient) async {
|
||||||
final response = await call123testSpecialTagsWithHttpInfo(modelClient);
|
final response = await call123testSpecialTagsWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
@ -56,7 +56,7 @@ class DefaultApi {
|
|||||||
Future<InlineResponseDefault> fooGet() async {
|
Future<InlineResponseDefault> fooGet() async {
|
||||||
final response = await fooGetWithHttpInfo();
|
final response = await fooGetWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
@ -59,7 +59,7 @@ class FakeApi {
|
|||||||
Future<HealthCheckResult> fakeHealthGet() async {
|
Future<HealthCheckResult> fakeHealthGet() async {
|
||||||
final response = await fakeHealthGetWithHttpInfo();
|
final response = await fakeHealthGetWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -150,7 +150,7 @@ class FakeApi {
|
|||||||
Future<void> fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async {
|
Future<void> fakeHttpSignatureTest(Pet pet, { String query1, String header1 }) async {
|
||||||
final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 );
|
final response = await fakeHttpSignatureTestWithHttpInfo(pet, query1: query1, header1: header1 );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class FakeApi {
|
|||||||
Future<bool> fakeOuterBooleanSerialize({ bool body }) async {
|
Future<bool> fakeOuterBooleanSerialize({ bool body }) async {
|
||||||
final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterBooleanSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -278,7 +278,7 @@ class FakeApi {
|
|||||||
Future<OuterComposite> fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async {
|
Future<OuterComposite> fakeOuterCompositeSerialize({ OuterComposite outerComposite }) async {
|
||||||
final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite );
|
final response = await fakeOuterCompositeSerializeWithHttpInfo( outerComposite: outerComposite );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -346,7 +346,7 @@ class FakeApi {
|
|||||||
Future<num> fakeOuterNumberSerialize({ num body }) async {
|
Future<num> fakeOuterNumberSerialize({ num body }) async {
|
||||||
final response = await fakeOuterNumberSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterNumberSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -414,7 +414,7 @@ class FakeApi {
|
|||||||
Future<String> fakeOuterStringSerialize({ String body }) async {
|
Future<String> fakeOuterStringSerialize({ String body }) async {
|
||||||
final response = await fakeOuterStringSerializeWithHttpInfo( body: body );
|
final response = await fakeOuterStringSerializeWithHttpInfo( body: body );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -485,7 +485,7 @@ class FakeApi {
|
|||||||
Future<OuterObjectWithEnumProperty> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async {
|
Future<OuterObjectWithEnumProperty> fakePropertyEnumIntegerSerialize(OuterObjectWithEnumProperty outerObjectWithEnumProperty) async {
|
||||||
final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty);
|
final response = await fakePropertyEnumIntegerSerializeWithHttpInfo(outerObjectWithEnumProperty);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -554,7 +554,7 @@ class FakeApi {
|
|||||||
Future<void> testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async {
|
Future<void> testBodyWithFileSchema(FileSchemaTestClass fileSchemaTestClass) async {
|
||||||
final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass);
|
final response = await testBodyWithFileSchemaWithHttpInfo(fileSchemaTestClass);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +619,7 @@ class FakeApi {
|
|||||||
Future<void> testBodyWithQueryParams(String query, User user) async {
|
Future<void> testBodyWithQueryParams(String query, User user) async {
|
||||||
final response = await testBodyWithQueryParamsWithHttpInfo(query, user);
|
final response = await testBodyWithQueryParamsWithHttpInfo(query, user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,7 +686,7 @@ class FakeApi {
|
|||||||
Future<ModelClient> testClientModel(ModelClient modelClient) async {
|
Future<ModelClient> testClientModel(ModelClient modelClient) async {
|
||||||
final response = await testClientModelWithHttpInfo(modelClient);
|
final response = await testClientModelWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -944,7 +944,7 @@ class FakeApi {
|
|||||||
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async {
|
Future<void> testEndpointParameters(num number, double double_, String patternWithoutDelimiter, String byte, { int integer, int int32, int int64, double float, String string, MultipartFile binary, DateTime date, DateTime dateTime, String password, String callback }) async {
|
||||||
final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback );
|
final response = await testEndpointParametersWithHttpInfo(number, double_, patternWithoutDelimiter, byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1084,7 +1084,7 @@ class FakeApi {
|
|||||||
Future<void> testEnumParameters({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
Future<void> testEnumParameters({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
||||||
final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString );
|
final response = await testEnumParametersWithHttpInfo( enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,7 +1201,7 @@ class FakeApi {
|
|||||||
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async {
|
Future<void> testGroupParameters(int requiredStringGroup, bool requiredBooleanGroup, int requiredInt64Group, { int stringGroup, bool booleanGroup, int int64Group }) async {
|
||||||
final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group );
|
final response = await testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,7 +1264,7 @@ class FakeApi {
|
|||||||
Future<void> testInlineAdditionalProperties(Map<String, String> requestBody) async {
|
Future<void> testInlineAdditionalProperties(Map<String, String> requestBody) async {
|
||||||
final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody);
|
final response = await testInlineAdditionalPropertiesWithHttpInfo(requestBody);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,7 +1350,7 @@ class FakeApi {
|
|||||||
Future<void> testJsonFormData(String param, String param2) async {
|
Future<void> testJsonFormData(String param, String param2) async {
|
||||||
final response = await testJsonFormDataWithHttpInfo(param, param2);
|
final response = await testJsonFormDataWithHttpInfo(param, param2);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1445,7 +1445,7 @@ class FakeApi {
|
|||||||
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context) async {
|
Future<void> testQueryParameterCollectionFormat(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context) async {
|
||||||
final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context);
|
final response = await testQueryParameterCollectionFormatWithHttpInfo(pipe, ioutil, http, url, context);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class FakeClassnameTags123Api {
|
|||||||
Future<ModelClient> testClassname(ModelClient modelClient) async {
|
Future<ModelClient> testClassname(ModelClient modelClient) async {
|
||||||
final response = await testClassnameWithHttpInfo(modelClient);
|
final response = await testClassnameWithHttpInfo(modelClient);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
@ -74,7 +74,7 @@ class PetApi {
|
|||||||
Future<void> addPet(Pet pet) async {
|
Future<void> addPet(Pet pet) async {
|
||||||
final response = await addPetWithHttpInfo(pet);
|
final response = await addPetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ class PetApi {
|
|||||||
Future<void> deletePet(int petId, { String apiKey }) async {
|
Future<void> deletePet(int petId, { String apiKey }) async {
|
||||||
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
final response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class PetApi {
|
|||||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||||
final response = await findPetsByStatusWithHttpInfo(status);
|
final response = await findPetsByStatusWithHttpInfo(status);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -294,7 +294,7 @@ class PetApi {
|
|||||||
Future<Set<Pet>> findPetsByTags(Set<String> tags) async {
|
Future<Set<Pet>> findPetsByTags(Set<String> tags) async {
|
||||||
final response = await findPetsByTagsWithHttpInfo(tags);
|
final response = await findPetsByTagsWithHttpInfo(tags);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -372,7 +372,7 @@ class PetApi {
|
|||||||
Future<Pet> getPetById(int petId) async {
|
Future<Pet> getPetById(int petId) async {
|
||||||
final response = await getPetByIdWithHttpInfo(petId);
|
final response = await getPetByIdWithHttpInfo(petId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -443,7 +443,7 @@ class PetApi {
|
|||||||
Future<void> updatePet(Pet pet) async {
|
Future<void> updatePet(Pet pet) async {
|
||||||
final response = await updatePetWithHttpInfo(pet);
|
final response = await updatePetWithHttpInfo(pet);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ class PetApi {
|
|||||||
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
Future<void> updatePetWithForm(int petId, { String name, String status }) async {
|
||||||
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
final response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||||
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
final response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -720,7 +720,7 @@ class PetApi {
|
|||||||
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
Future<ApiResponse> uploadFileWithRequiredFile(int petId, MultipartFile requiredFile, { String additionalMetadata }) async {
|
||||||
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata );
|
final response = await uploadFileWithRequiredFileWithHttpInfo(petId, requiredFile, additionalMetadata: additionalMetadata );
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
@ -79,7 +79,7 @@ class StoreApi {
|
|||||||
Future<void> deleteOrder(String orderId) async {
|
Future<void> deleteOrder(String orderId) async {
|
||||||
final response = await deleteOrderWithHttpInfo(orderId);
|
final response = await deleteOrderWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class StoreApi {
|
|||||||
Future<Map<String, int>> getInventory() async {
|
Future<Map<String, int>> getInventory() async {
|
||||||
final response = await getInventoryWithHttpInfo();
|
final response = await getInventoryWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -207,7 +207,7 @@ class StoreApi {
|
|||||||
Future<Order> getOrderById(int orderId) async {
|
Future<Order> getOrderById(int orderId) async {
|
||||||
final response = await getOrderByIdWithHttpInfo(orderId);
|
final response = await getOrderByIdWithHttpInfo(orderId);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -278,7 +278,7 @@ class StoreApi {
|
|||||||
Future<Order> placeOrder(Order order) async {
|
Future<Order> placeOrder(Order order) async {
|
||||||
final response = await placeOrderWithHttpInfo(order);
|
final response = await placeOrderWithHttpInfo(order);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
@ -78,7 +78,7 @@ class UserApi {
|
|||||||
Future<void> createUser(User user) async {
|
Future<void> createUser(User user) async {
|
||||||
final response = await createUserWithHttpInfo(user);
|
final response = await createUserWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithArrayInput(List<User> user) async {
|
Future<void> createUsersWithArrayInput(List<User> user) async {
|
||||||
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
final response = await createUsersWithArrayInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class UserApi {
|
|||||||
Future<void> createUsersWithListInput(List<User> user) async {
|
Future<void> createUsersWithListInput(List<User> user) async {
|
||||||
final response = await createUsersWithListInputWithHttpInfo(user);
|
final response = await createUsersWithListInputWithHttpInfo(user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ class UserApi {
|
|||||||
Future<void> deleteUser(String username) async {
|
Future<void> deleteUser(String username) async {
|
||||||
final response = await deleteUserWithHttpInfo(username);
|
final response = await deleteUserWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ class UserApi {
|
|||||||
Future<User> getUserByName(String username) async {
|
Future<User> getUserByName(String username) async {
|
||||||
final response = await getUserByNameWithHttpInfo(username);
|
final response = await getUserByNameWithHttpInfo(username);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -419,7 +419,7 @@ class UserApi {
|
|||||||
Future<String> loginUser(String username, String password) async {
|
Future<String> loginUser(String username, String password) async {
|
||||||
final response = await loginUserWithHttpInfo(username, password);
|
final response = await loginUserWithHttpInfo(username, password);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
// When a remote server returns no body with a status of 204, we shall not decode it.
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
@ -475,7 +475,7 @@ class UserApi {
|
|||||||
Future<void> logoutUser() async {
|
Future<void> logoutUser() async {
|
||||||
final response = await logoutUserWithHttpInfo();
|
final response = await logoutUserWithHttpInfo();
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ class UserApi {
|
|||||||
Future<void> updateUser(String username, User user) async {
|
Future<void> updateUser(String username, User user) async {
|
||||||
final response = await updateUserWithHttpInfo(username, user);
|
final response = await updateUserWithHttpInfo(username, user);
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,16 @@ class ApiClient {
|
|||||||
|
|
||||||
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
Map<String,String> get defaultHeaderMap => _defaultHeaderMap;
|
||||||
|
|
||||||
/// returns an unmodifiable view of the authentications, since none should be added
|
/// Returns an unmodifiable [Map] of the authentications, since none should be added
|
||||||
/// nor deleted
|
/// or deleted.
|
||||||
Map<String, Authentication> get authentications =>
|
Map<String, Authentication> get authentications => Map.unmodifiable(_authentications);
|
||||||
Map.unmodifiable(_authentications);
|
|
||||||
|
|
||||||
T getAuthentication<T extends Authentication>(String name) {
|
T getAuthentication<T extends Authentication>(String name) {
|
||||||
final authentication = _authentications[name];
|
final authentication = _authentications[name];
|
||||||
return authentication is T ? authentication : null;
|
return authentication is T ? authentication : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don’t use a Map<String, String> for queryParams.
|
// We don't use a Map<String, String> for queryParams.
|
||||||
// If collectionFormat is 'multi', a key might appear multiple times.
|
// If collectionFormat is 'multi', a key might appear multiple times.
|
||||||
Future<Response> invokeAPI(
|
Future<Response> invokeAPI(
|
||||||
String path,
|
String path,
|
||||||
@ -88,7 +87,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Special case for uploading a single file which isn’t a 'multipart/form-data'.
|
// Special case for uploading a single file which isn't a 'multipart/form-data'.
|
||||||
if (
|
if (
|
||||||
body is MultipartFile && (nullableContentType == null ||
|
body is MultipartFile && (nullableContentType == null ||
|
||||||
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
!nullableContentType.toLowerCase().startsWith('multipart/form-data'))
|
||||||
@ -118,7 +117,7 @@ class ApiClient {
|
|||||||
|
|
||||||
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
final msgBody = nullableContentType == 'application/x-www-form-urlencoded'
|
||||||
? formParams
|
? formParams
|
||||||
: serialize(body);
|
: await serializeAsync(body);
|
||||||
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
|
||||||
|
|
||||||
switch(method) {
|
switch(method) {
|
||||||
@ -144,8 +143,11 @@ class ApiClient {
|
|||||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: deprecated_member_use_from_same_package
|
||||||
|
Future<String> serializeAsync(Object value) async => serialize(value);
|
||||||
|
|
||||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
|
||||||
|
String serialize(Object value) => value == null ? '' : json.encode(value);
|
||||||
|
|
||||||
/// Update query and header parameters based on authentication settings.
|
/// Update query and header parameters based on authentication settings.
|
||||||
/// @param authNames The authentications to apply
|
/// @param authNames The authentications to apply
|
||||||
@ -162,4 +164,8 @@ class ApiClient {
|
|||||||
auth.applyToParams(queryParams, headerParams);
|
auth.applyToParams(queryParams, headerParams);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Primarily intended for use in an isolate.
|
||||||
|
Future<String> serializeAsync(Object value) async => value == null ? '' : json.encode(value);
|
||||||
|
@ -78,7 +78,7 @@ String parameterToString(dynamic value) {
|
|||||||
|
|
||||||
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
/// Returns the decoded body as UTF-8 if the given headers indicate an 'application/json'
|
||||||
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
/// content type. Otherwise, returns the decoded body as decoded by dart:http package.
|
||||||
String _decodeBodyBytes(Response response) {
|
Future<String> _decodeBodyBytes(Response response) async {
|
||||||
final contentType = response.headers['content-type'];
|
final contentType = response.headers['content-type'];
|
||||||
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
return contentType != null && contentType.toLowerCase().startsWith('application/json')
|
||||||
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
? response.bodyBytes == null ? null : utf8.decode(response.bodyBytes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user