forked from loafle/openapi-generator-original
[dart] Fix api client deserialization for json_serializable (#8882)
* Fix api-client deserialization for json_serializable * Use raw string for url path * Use Set/List.of * Use returnTypeIsPrimitive in template * Regenerate all templates * Fix casting map to Iterable of things * Add json_serializable to maven modules * Run build_runner before pub run test * Return future of type for strong linter mode
This commit is contained in:
@@ -61,7 +61,7 @@ class {{{classname}}} {
|
||||
{{/allParams}}
|
||||
|
||||
{{/hasParams}}
|
||||
final path = '{{{path}}}'{{#pathParams}}
|
||||
final path = r'{{{path}}}'{{#pathParams}}
|
||||
.replaceAll('{' + '{{{baseName}}}' + '}', {{{paramName}}}.toString()){{/pathParams}};
|
||||
|
||||
Object postBody{{#bodyParam}} = {{{paramName}}}{{/bodyParam}};
|
||||
@@ -185,21 +185,47 @@ class {{{classname}}} {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
{{#isArray}}
|
||||
{{#native_serialization}}
|
||||
{{#isArray}}
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as List)
|
||||
.cast<{{{returnBaseType}}}>()
|
||||
.{{#uniqueItems}}toSet(){{/uniqueItems}}{{^uniqueItems}}toList(growable: false){{/uniqueItems}};
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
return {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}'));
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}') as {{{returnType}}};
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}}
|
||||
{{#isArray}}
|
||||
{{#uniqueItems}}
|
||||
return (json.decode(response.body) as List)
|
||||
.map((i) => {{{returnBaseType}}}.fromJson(i))
|
||||
.toSet();
|
||||
{{/uniqueItems}}
|
||||
{{^uniqueItems}}
|
||||
return (json.decode(response.body) as List)
|
||||
.map((i) => {{{returnBaseType}}}.fromJson(i))
|
||||
.toList();
|
||||
{{/uniqueItems}}
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
return {{{returnType}}}.from(json.decode(response.body));
|
||||
{{/isMap}}
|
||||
{{^isMap}}
|
||||
{{#returnTypeIsPrimitive}}
|
||||
return response.body as {{{returnBaseType}}};
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{^returnTypeIsPrimitive}}
|
||||
return {{{returnType}}}.fromJson(json.decode(response.body));
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{/json_serializable}}
|
||||
}
|
||||
return null;
|
||||
return Future<{{{returnType}}}>.value(null);
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
|
||||
@@ -56,17 +56,6 @@ class ApiClient {
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
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);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
@@ -159,6 +148,7 @@ class ApiClient {
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
}
|
||||
|
||||
{{#native_serialization}}
|
||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
@@ -216,6 +206,18 @@ class ApiClient {
|
||||
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);
|
||||
}
|
||||
{{/native_serialization}}
|
||||
|
||||
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(
|
||||
|
||||
@@ -53,8 +53,7 @@ String parameterToString(dynamic value) {
|
||||
{{#model}}
|
||||
{{#isEnum}}
|
||||
if (value is {{{classname}}}) {
|
||||
{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}
|
||||
{{#json_serializable}} return _${{{classname}}}EnumMap[value];{{/json_serializable}}
|
||||
{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}{{#json_serializable}} return value.toString();{{/json_serializable}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -1353,6 +1353,7 @@
|
||||
<module>samples/client/petstore/dart2/petstore</module>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore</module>
|
||||
<module>samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake</module>
|
||||
<module>samples/client/petstore/dart-dio/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib</module>
|
||||
<module>samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake</module>
|
||||
|
||||
@@ -29,7 +29,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -94,7 +94,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -166,7 +166,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
final path = '/pet/findByStatus';
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -225,7 +225,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@@ -244,7 +244,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
final path = '/pet/findByTags';
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -303,7 +303,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@@ -322,7 +322,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -377,8 +377,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -395,7 +395,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -464,7 +464,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -554,7 +554,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}/uploadImage'
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -625,7 +625,7 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{orderId}'
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{' + 'orderId' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -89,7 +89,7 @@ class StoreApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
final path = '/store/inventory';
|
||||
final path = r'/store/inventory';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -139,7 +139,7 @@ class StoreApi {
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
||||
}
|
||||
return null;
|
||||
return Future<Map<String, int>>.value(null);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@@ -158,7 +158,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{orderId}'
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{' + 'orderId' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -213,8 +213,8 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@@ -231,7 +231,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/store/order';
|
||||
final path = r'/store/order';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -283,7 +283,7 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/user';
|
||||
final path = r'/user';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -96,7 +96,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/user/createWithArray';
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -159,7 +159,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/user/createWithList';
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -224,7 +224,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -290,7 +290,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -343,8 +343,8 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<User>.value(null);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -367,7 +367,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
final path = '/user/login';
|
||||
final path = r'/user/login';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -425,15 +425,15 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> logoutUserWithHttpInfo() async {
|
||||
final path = '/user/logout';
|
||||
final path = r'/user/logout';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -499,7 +499,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: body');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -49,17 +49,6 @@ class ApiClient {
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
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);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
@@ -209,6 +198,17 @@ class ApiClient {
|
||||
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(
|
||||
|
||||
@@ -29,7 +29,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -81,8 +81,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
@@ -101,7 +101,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -173,7 +173,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
final path = '/pet/findByStatus';
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -232,7 +232,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@@ -251,7 +251,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
final path = '/pet/findByTags';
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -310,7 +310,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@@ -329,7 +329,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -384,8 +384,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -402,7 +402,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -454,8 +454,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
@@ -478,7 +478,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -568,7 +568,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}/uploadImage'
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -639,7 +639,7 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{orderId}'
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{' + 'orderId' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -89,7 +89,7 @@ class StoreApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
final path = '/store/inventory';
|
||||
final path = r'/store/inventory';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -139,7 +139,7 @@ class StoreApi {
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
||||
}
|
||||
return null;
|
||||
return Future<Map<String, int>>.value(null);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@@ -158,7 +158,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{orderId}'
|
||||
final path = r'/store/order/{orderId}'
|
||||
.replaceAll('{' + 'orderId' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -213,8 +213,8 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@@ -231,7 +231,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
final path = '/store/order';
|
||||
final path = r'/store/order';
|
||||
|
||||
Object postBody = order;
|
||||
|
||||
@@ -283,7 +283,7 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user';
|
||||
final path = r'/user';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -96,7 +96,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithArray';
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -159,7 +159,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithList';
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -224,7 +224,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -290,7 +290,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -343,8 +343,8 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<User>.value(null);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -367,7 +367,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
final path = '/user/login';
|
||||
final path = r'/user/login';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -425,15 +425,15 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> logoutUserWithHttpInfo() async {
|
||||
final path = '/user/logout';
|
||||
final path = r'/user/logout';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -499,7 +499,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -49,17 +49,6 @@ class ApiClient {
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
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);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
@@ -209,6 +198,17 @@ class ApiClient {
|
||||
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(
|
||||
|
||||
@@ -31,7 +31,7 @@ class AnotherFakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/another-fake/dummy';
|
||||
final path = r'/another-fake/dummy';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -85,7 +85,7 @@ class AnotherFakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class DefaultApi {
|
||||
|
||||
/// Performs an HTTP 'GET /foo' operation and returns the [Response].
|
||||
Future<Response> fooGetWithHttpInfo() async {
|
||||
final path = '/foo';
|
||||
final path = r'/foo';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -63,7 +63,7 @@ class DefaultApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'InlineResponseDefault') as InlineResponseDefault;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<InlineResponseDefault>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class FakeApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> fakeHealthGetWithHttpInfo() async {
|
||||
final path = '/fake/health';
|
||||
final path = r'/fake/health';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -66,8 +66,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'HealthCheckResult') as HealthCheckResult;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<HealthCheckResult>.value(null);
|
||||
}
|
||||
|
||||
/// test http signature authentication
|
||||
@@ -90,7 +90,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/fake/http-signature-test';
|
||||
final path = r'/fake/http-signature-test';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -164,7 +164,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterBooleanSerializeWithHttpInfo({ bool body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/boolean';
|
||||
final path = r'/fake/outer/boolean';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -216,8 +216,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'bool') as bool;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<bool>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of object with outer number type
|
||||
@@ -231,7 +231,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/composite';
|
||||
final path = r'/fake/outer/composite';
|
||||
|
||||
Object postBody = outerComposite;
|
||||
|
||||
@@ -283,8 +283,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterComposite') as OuterComposite;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<OuterComposite>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of outer number types
|
||||
@@ -298,7 +298,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterNumberSerializeWithHttpInfo({ num body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/number';
|
||||
final path = r'/fake/outer/number';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -350,8 +350,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'num') as num;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<num>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of outer string types
|
||||
@@ -365,7 +365,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterStringSerializeWithHttpInfo({ String body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/string';
|
||||
final path = r'/fake/outer/string';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -417,8 +417,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of enum (int) properties with examples
|
||||
@@ -435,7 +435,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: outerObjectWithEnumProperty');
|
||||
}
|
||||
|
||||
final path = '/fake/property/enum-int';
|
||||
final path = r'/fake/property/enum-int';
|
||||
|
||||
Object postBody = outerObjectWithEnumProperty;
|
||||
|
||||
@@ -487,8 +487,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterObjectWithEnumProperty') as OuterObjectWithEnumProperty;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<OuterObjectWithEnumProperty>.value(null);
|
||||
}
|
||||
|
||||
/// For this test, the body for this request much reference a schema named `File`.
|
||||
@@ -504,7 +504,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: fileSchemaTestClass');
|
||||
}
|
||||
|
||||
final path = '/fake/body-with-file-schema';
|
||||
final path = r'/fake/body-with-file-schema';
|
||||
|
||||
Object postBody = fileSchemaTestClass;
|
||||
|
||||
@@ -567,7 +567,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/fake/body-with-query-params';
|
||||
final path = r'/fake/body-with-query-params';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -633,7 +633,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -687,8 +687,8 @@ class FakeApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@@ -755,7 +755,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: byte');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -975,7 +975,7 @@ class FakeApi {
|
||||
Future<Response> testEnumParametersWithHttpInfo({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1118,7 +1118,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredInt64Group');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1212,7 +1212,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requestBody');
|
||||
}
|
||||
|
||||
final path = '/fake/inline-additionalProperties';
|
||||
final path = r'/fake/inline-additionalProperties';
|
||||
|
||||
Object postBody = requestBody;
|
||||
|
||||
@@ -1281,7 +1281,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: param2');
|
||||
}
|
||||
|
||||
final path = '/fake/jsonFormData';
|
||||
final path = r'/fake/jsonFormData';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1380,7 +1380,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: context');
|
||||
}
|
||||
|
||||
final path = '/fake/test-query-paramters';
|
||||
final path = r'/fake/test-query-paramters';
|
||||
|
||||
Object postBody;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class FakeClassnameTags123Api {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/fake_classname_test';
|
||||
final path = r'/fake_classname_test';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -85,7 +85,7 @@ class FakeClassnameTags123Api {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -94,7 +94,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -166,7 +166,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
final path = '/pet/findByStatus';
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -225,7 +225,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@@ -244,7 +244,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
final path = '/pet/findByTags';
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -303,7 +303,7 @@ class PetApi {
|
||||
.cast<Pet>()
|
||||
.toSet();
|
||||
}
|
||||
return null;
|
||||
return Future<Set<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@@ -322,7 +322,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -377,8 +377,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -395,7 +395,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -464,7 +464,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -554,7 +554,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}/uploadImage'
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -625,8 +625,8 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
|
||||
/// uploads an image (required)
|
||||
@@ -652,7 +652,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile');
|
||||
}
|
||||
|
||||
final path = '/fake/{petId}/uploadImageWithRequiredFile'
|
||||
final path = r'/fake/{petId}/uploadImageWithRequiredFile'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -723,7 +723,7 @@ class PetApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -89,7 +89,7 @@ class StoreApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
final path = '/store/inventory';
|
||||
final path = r'/store/inventory';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -139,7 +139,7 @@ class StoreApi {
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
||||
}
|
||||
return null;
|
||||
return Future<Map<String, int>>.value(null);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@@ -158,7 +158,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -213,8 +213,8 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@@ -231,7 +231,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
final path = '/store/order';
|
||||
final path = r'/store/order';
|
||||
|
||||
Object postBody = order;
|
||||
|
||||
@@ -283,7 +283,7 @@ class StoreApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user';
|
||||
final path = r'/user';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -96,7 +96,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithArray';
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -159,7 +159,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithList';
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -224,7 +224,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -290,7 +290,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -343,8 +343,8 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<User>.value(null);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -367,7 +367,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
final path = '/user/login';
|
||||
final path = r'/user/login';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -425,15 +425,15 @@ class UserApi {
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> logoutUserWithHttpInfo() async {
|
||||
final path = '/user/logout';
|
||||
final path = r'/user/logout';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -499,7 +499,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -52,17 +52,6 @@ class ApiClient {
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
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);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
@@ -293,6 +282,17 @@ class ApiClient {
|
||||
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(
|
||||
|
||||
@@ -60,23 +60,18 @@ String parameterToString(dynamic value) {
|
||||
}
|
||||
if (value is EnumClass) {
|
||||
return EnumClassTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnum) {
|
||||
return OuterEnumTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumDefaultValue) {
|
||||
return OuterEnumDefaultValueTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumInteger) {
|
||||
return OuterEnumIntegerTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
if (value is OuterEnumIntegerDefaultValue) {
|
||||
return OuterEnumIntegerDefaultValueTypeTransformer().encode(value).toString();
|
||||
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class AnotherFakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/another-fake/dummy';
|
||||
final path = r'/another-fake/dummy';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -84,8 +84,9 @@ class AnotherFakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
|
||||
return ModelClient.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class DefaultApi {
|
||||
|
||||
/// Performs an HTTP 'GET /foo' operation and returns the [Response].
|
||||
Future<Response> fooGetWithHttpInfo() async {
|
||||
final path = '/foo';
|
||||
final path = r'/foo';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -62,8 +62,9 @@ class DefaultApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'InlineResponseDefault') as InlineResponseDefault;
|
||||
|
||||
return InlineResponseDefault.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<InlineResponseDefault>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class FakeApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> fakeHealthGetWithHttpInfo() async {
|
||||
final path = '/fake/health';
|
||||
final path = r'/fake/health';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -65,9 +65,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'HealthCheckResult') as HealthCheckResult;
|
||||
|
||||
return HealthCheckResult.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<HealthCheckResult>.value(null);
|
||||
}
|
||||
|
||||
/// test http signature authentication
|
||||
@@ -90,7 +91,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/fake/http-signature-test';
|
||||
final path = r'/fake/http-signature-test';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -164,7 +165,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterBooleanSerializeWithHttpInfo({ bool body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/boolean';
|
||||
final path = r'/fake/outer/boolean';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -215,9 +216,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'bool') as bool;
|
||||
|
||||
return response.body as bool;
|
||||
}
|
||||
return null;
|
||||
return Future<bool>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of object with outer number type
|
||||
@@ -231,7 +233,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterCompositeSerializeWithHttpInfo({ OuterComposite outerComposite }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/composite';
|
||||
final path = r'/fake/outer/composite';
|
||||
|
||||
Object postBody = outerComposite;
|
||||
|
||||
@@ -282,9 +284,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterComposite') as OuterComposite;
|
||||
|
||||
return OuterComposite.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<OuterComposite>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of outer number types
|
||||
@@ -298,7 +301,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterNumberSerializeWithHttpInfo({ num body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/number';
|
||||
final path = r'/fake/outer/number';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -349,9 +352,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'num') as num;
|
||||
|
||||
return response.body as num;
|
||||
}
|
||||
return null;
|
||||
return Future<num>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of outer string types
|
||||
@@ -365,7 +369,7 @@ class FakeApi {
|
||||
Future<Response> fakeOuterStringSerializeWithHttpInfo({ String body }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake/outer/string';
|
||||
final path = r'/fake/outer/string';
|
||||
|
||||
Object postBody = body;
|
||||
|
||||
@@ -416,9 +420,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
|
||||
return response.body as String;
|
||||
}
|
||||
return null;
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Test serialization of enum (int) properties with examples
|
||||
@@ -435,7 +440,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: outerObjectWithEnumProperty');
|
||||
}
|
||||
|
||||
final path = '/fake/property/enum-int';
|
||||
final path = r'/fake/property/enum-int';
|
||||
|
||||
Object postBody = outerObjectWithEnumProperty;
|
||||
|
||||
@@ -486,9 +491,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'OuterObjectWithEnumProperty') as OuterObjectWithEnumProperty;
|
||||
|
||||
return OuterObjectWithEnumProperty.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<OuterObjectWithEnumProperty>.value(null);
|
||||
}
|
||||
|
||||
/// For this test, the body for this request much reference a schema named `File`.
|
||||
@@ -504,7 +510,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: fileSchemaTestClass');
|
||||
}
|
||||
|
||||
final path = '/fake/body-with-file-schema';
|
||||
final path = r'/fake/body-with-file-schema';
|
||||
|
||||
Object postBody = fileSchemaTestClass;
|
||||
|
||||
@@ -567,7 +573,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/fake/body-with-query-params';
|
||||
final path = r'/fake/body-with-query-params';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -633,7 +639,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -686,9 +692,10 @@ class FakeApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
|
||||
return ModelClient.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
|
||||
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@@ -755,7 +762,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: byte');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -975,7 +982,7 @@ class FakeApi {
|
||||
Future<Response> testEnumParametersWithHttpInfo({ List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, int enumQueryInteger, double enumQueryDouble, List<String> enumFormStringArray, String enumFormString }) async {
|
||||
// Verify required params are set.
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1118,7 +1125,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredInt64Group');
|
||||
}
|
||||
|
||||
final path = '/fake';
|
||||
final path = r'/fake';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1212,7 +1219,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requestBody');
|
||||
}
|
||||
|
||||
final path = '/fake/inline-additionalProperties';
|
||||
final path = r'/fake/inline-additionalProperties';
|
||||
|
||||
Object postBody = requestBody;
|
||||
|
||||
@@ -1281,7 +1288,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: param2');
|
||||
}
|
||||
|
||||
final path = '/fake/jsonFormData';
|
||||
final path = r'/fake/jsonFormData';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -1380,7 +1387,7 @@ class FakeApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: context');
|
||||
}
|
||||
|
||||
final path = '/fake/test-query-paramters';
|
||||
final path = r'/fake/test-query-paramters';
|
||||
|
||||
Object postBody;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class FakeClassnameTags123Api {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: modelClient');
|
||||
}
|
||||
|
||||
final path = '/fake_classname_test';
|
||||
final path = r'/fake_classname_test';
|
||||
|
||||
Object postBody = modelClient;
|
||||
|
||||
@@ -84,8 +84,9 @@ class FakeClassnameTags123Api {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ModelClient') as ModelClient;
|
||||
|
||||
return ModelClient.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<ModelClient>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -94,7 +94,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -166,7 +166,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: status');
|
||||
}
|
||||
|
||||
final path = '/pet/findByStatus';
|
||||
final path = r'/pet/findByStatus';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -221,11 +221,12 @@ class PetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
.toList(growable: false);
|
||||
|
||||
return (json.decode(response.body) as List)
|
||||
.map((i) => Pet.fromJson(i))
|
||||
.toList();
|
||||
}
|
||||
return null;
|
||||
return Future<List<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
@@ -244,7 +245,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: tags');
|
||||
}
|
||||
|
||||
final path = '/pet/findByTags';
|
||||
final path = r'/pet/findByTags';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -299,11 +300,12 @@ class PetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'Set<Pet>') as List)
|
||||
.cast<Pet>()
|
||||
|
||||
return (json.decode(response.body) as List)
|
||||
.map((i) => Pet.fromJson(i))
|
||||
.toSet();
|
||||
}
|
||||
return null;
|
||||
return Future<Set<Pet>>.value(null);
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
@@ -322,7 +324,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -376,9 +378,10 @@ class PetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
|
||||
return Pet.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<Pet>.value(null);
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
@@ -395,7 +398,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: pet');
|
||||
}
|
||||
|
||||
final path = '/pet';
|
||||
final path = r'/pet';
|
||||
|
||||
Object postBody = pet;
|
||||
|
||||
@@ -464,7 +467,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}'
|
||||
final path = r'/pet/{petId}'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -554,7 +557,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: petId');
|
||||
}
|
||||
|
||||
final path = '/pet/{petId}/uploadImage'
|
||||
final path = r'/pet/{petId}/uploadImage'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -624,9 +627,10 @@ class PetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
|
||||
return ApiResponse.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
|
||||
/// uploads an image (required)
|
||||
@@ -652,7 +656,7 @@ class PetApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: requiredFile');
|
||||
}
|
||||
|
||||
final path = '/fake/{petId}/uploadImageWithRequiredFile'
|
||||
final path = r'/fake/{petId}/uploadImageWithRequiredFile'
|
||||
.replaceAll('{' + 'petId' + '}', petId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -722,8 +726,9 @@ class PetApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
|
||||
return ApiResponse.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<ApiResponse>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -89,7 +89,7 @@ class StoreApi {
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
final path = '/store/inventory';
|
||||
final path = r'/store/inventory';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -137,9 +137,10 @@ class StoreApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
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(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<Map<String, int>>.value(null);
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
@@ -158,7 +159,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: orderId');
|
||||
}
|
||||
|
||||
final path = '/store/order/{order_id}'
|
||||
final path = r'/store/order/{order_id}'
|
||||
.replaceAll('{' + 'order_id' + '}', orderId.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -212,9 +213,10 @@ class StoreApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
|
||||
return Order.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
@@ -231,7 +233,7 @@ class StoreApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: order');
|
||||
}
|
||||
|
||||
final path = '/store/order';
|
||||
final path = r'/store/order';
|
||||
|
||||
Object postBody = order;
|
||||
|
||||
@@ -282,8 +284,9 @@ class StoreApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
|
||||
return Order.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<Order>.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user';
|
||||
final path = r'/user';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -96,7 +96,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithArray';
|
||||
final path = r'/user/createWithArray';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -159,7 +159,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/createWithList';
|
||||
final path = r'/user/createWithList';
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -224,7 +224,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -290,7 +290,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: username');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody;
|
||||
@@ -342,9 +342,10 @@ class UserApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
|
||||
return User.fromJson(json.decode(response.body));
|
||||
}
|
||||
return null;
|
||||
return Future<User>.value(null);
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
@@ -367,7 +368,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: password');
|
||||
}
|
||||
|
||||
final path = '/user/login';
|
||||
final path = r'/user/login';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -424,16 +425,17 @@ class UserApi {
|
||||
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||
// FormatException when trying to decode an empty string.
|
||||
if (response.body != null && response.statusCode != HttpStatus.noContent) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
|
||||
return response.body as String;
|
||||
}
|
||||
return null;
|
||||
return Future<String>.value(null);
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
/// Note: This method returns the HTTP [Response].
|
||||
Future<Response> logoutUserWithHttpInfo() async {
|
||||
final path = '/user/logout';
|
||||
final path = r'/user/logout';
|
||||
|
||||
Object postBody;
|
||||
|
||||
@@ -499,7 +501,7 @@ class UserApi {
|
||||
throw ApiException(HttpStatus.badRequest, 'Missing required param: user');
|
||||
}
|
||||
|
||||
final path = '/user/{username}'
|
||||
final path = r'/user/{username}'
|
||||
.replaceAll('{' + 'username' + '}', username.toString());
|
||||
|
||||
Object postBody = user;
|
||||
|
||||
@@ -52,17 +52,6 @@ class ApiClient {
|
||||
Map<String, Authentication> get authentications =>
|
||||
Map.unmodifiable(_authentications);
|
||||
|
||||
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);
|
||||
|
||||
T getAuthentication<T extends Authentication>(String name) {
|
||||
final authentication = _authentications[name];
|
||||
return authentication is T ? authentication : null;
|
||||
@@ -155,143 +144,8 @@ class ApiClient {
|
||||
throw ApiException(HttpStatus.badRequest, 'Invalid HTTP operation: $method $path',);
|
||||
}
|
||||
|
||||
dynamic _deserialize(dynamic value, String targetType, {bool growable}) {
|
||||
try {
|
||||
switch (targetType) {
|
||||
case 'String':
|
||||
return '$value';
|
||||
case 'int':
|
||||
return value is int ? value : int.parse('$value');
|
||||
case 'bool':
|
||||
if (value is bool) {
|
||||
return value;
|
||||
}
|
||||
final valueString = '$value'.toLowerCase();
|
||||
return valueString == 'true' || valueString == '1';
|
||||
break;
|
||||
case 'double':
|
||||
return value is double ? value : double.parse('$value');
|
||||
case 'AdditionalPropertiesClass':
|
||||
return AdditionalPropertiesClass.fromJson(value);
|
||||
case 'Animal':
|
||||
return Animal.fromJson(value);
|
||||
case 'ApiResponse':
|
||||
return ApiResponse.fromJson(value);
|
||||
case 'ArrayOfArrayOfNumberOnly':
|
||||
return ArrayOfArrayOfNumberOnly.fromJson(value);
|
||||
case 'ArrayOfNumberOnly':
|
||||
return ArrayOfNumberOnly.fromJson(value);
|
||||
case 'ArrayTest':
|
||||
return ArrayTest.fromJson(value);
|
||||
case 'Capitalization':
|
||||
return Capitalization.fromJson(value);
|
||||
case 'Cat':
|
||||
return Cat.fromJson(value);
|
||||
case 'CatAllOf':
|
||||
return CatAllOf.fromJson(value);
|
||||
case 'Category':
|
||||
return Category.fromJson(value);
|
||||
case 'ClassModel':
|
||||
return ClassModel.fromJson(value);
|
||||
case 'Dog':
|
||||
return Dog.fromJson(value);
|
||||
case 'DogAllOf':
|
||||
return DogAllOf.fromJson(value);
|
||||
case 'EnumArrays':
|
||||
return EnumArrays.fromJson(value);
|
||||
case 'EnumClass':
|
||||
|
||||
return _$enumDecode(_$EnumClassEnumMap, value);
|
||||
case 'EnumTest':
|
||||
return EnumTest.fromJson(value);
|
||||
case 'FileSchemaTestClass':
|
||||
return FileSchemaTestClass.fromJson(value);
|
||||
case 'Foo':
|
||||
return Foo.fromJson(value);
|
||||
case 'FormatTest':
|
||||
return FormatTest.fromJson(value);
|
||||
case 'HasOnlyReadOnly':
|
||||
return HasOnlyReadOnly.fromJson(value);
|
||||
case 'HealthCheckResult':
|
||||
return HealthCheckResult.fromJson(value);
|
||||
case 'InlineResponseDefault':
|
||||
return InlineResponseDefault.fromJson(value);
|
||||
case 'MapTest':
|
||||
return MapTest.fromJson(value);
|
||||
case 'MixedPropertiesAndAdditionalPropertiesClass':
|
||||
return MixedPropertiesAndAdditionalPropertiesClass.fromJson(value);
|
||||
case 'Model200Response':
|
||||
return Model200Response.fromJson(value);
|
||||
case 'ModelClient':
|
||||
return ModelClient.fromJson(value);
|
||||
case 'ModelFile':
|
||||
return ModelFile.fromJson(value);
|
||||
case 'ModelList':
|
||||
return ModelList.fromJson(value);
|
||||
case 'ModelReturn':
|
||||
return ModelReturn.fromJson(value);
|
||||
case 'Name':
|
||||
return Name.fromJson(value);
|
||||
case 'NullableClass':
|
||||
return NullableClass.fromJson(value);
|
||||
case 'NumberOnly':
|
||||
return NumberOnly.fromJson(value);
|
||||
case 'Order':
|
||||
return Order.fromJson(value);
|
||||
case 'OuterComposite':
|
||||
return OuterComposite.fromJson(value);
|
||||
case 'OuterEnum':
|
||||
|
||||
return _$enumDecode(_$OuterEnumEnumMap, value);
|
||||
case 'OuterEnumDefaultValue':
|
||||
|
||||
return _$enumDecode(_$OuterEnumDefaultValueEnumMap, value);
|
||||
case 'OuterEnumInteger':
|
||||
|
||||
return _$enumDecode(_$OuterEnumIntegerEnumMap, value);
|
||||
case 'OuterEnumIntegerDefaultValue':
|
||||
|
||||
return _$enumDecode(_$OuterEnumIntegerDefaultValueEnumMap, value);
|
||||
case 'OuterObjectWithEnumProperty':
|
||||
return OuterObjectWithEnumProperty.fromJson(value);
|
||||
case 'Pet':
|
||||
return Pet.fromJson(value);
|
||||
case 'ReadOnlyFirst':
|
||||
return ReadOnlyFirst.fromJson(value);
|
||||
case 'SpecialModelName':
|
||||
return SpecialModelName.fromJson(value);
|
||||
case 'Tag':
|
||||
return Tag.fromJson(value);
|
||||
case 'User':
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
Match match;
|
||||
if (value is List && (match = _regList.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return value
|
||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
||||
.toList(growable: true == growable);
|
||||
}
|
||||
if (value is Set && (match = _regSet.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return value
|
||||
.map((v) => _deserialize(v, newTargetType, growable: growable))
|
||||
.toSet();
|
||||
}
|
||||
if (value is Map && (match = _regMap.firstMatch(targetType)) != null) {
|
||||
final newTargetType = match[1];
|
||||
return Map.fromIterables(
|
||||
value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType, growable: growable)),
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} on Exception catch (e, stack) {
|
||||
throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', e, stack,);
|
||||
}
|
||||
throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
|
||||
}
|
||||
|
||||
String serialize(Object obj) => obj == null ? '' : json.encode(obj);
|
||||
|
||||
/// Update query and header parameters based on authentication settings.
|
||||
/// @param authNames The authentications to apply
|
||||
|
||||
@@ -59,24 +59,19 @@ String parameterToString(dynamic value) {
|
||||
return value.toUtc().toIso8601String();
|
||||
}
|
||||
if (value is EnumClass) {
|
||||
|
||||
return _$EnumClassEnumMap[value];
|
||||
return value.toString();
|
||||
}
|
||||
if (value is OuterEnum) {
|
||||
|
||||
return _$OuterEnumEnumMap[value];
|
||||
return value.toString();
|
||||
}
|
||||
if (value is OuterEnumDefaultValue) {
|
||||
|
||||
return _$OuterEnumDefaultValueEnumMap[value];
|
||||
return value.toString();
|
||||
}
|
||||
if (value is OuterEnumInteger) {
|
||||
|
||||
return _$OuterEnumIntegerEnumMap[value];
|
||||
return value.toString();
|
||||
}
|
||||
if (value is OuterEnumIntegerDefaultValue) {
|
||||
|
||||
return _$OuterEnumIntegerDefaultValueEnumMap[value];
|
||||
return value.toString();
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>Dart2PetstoreClientJsonSerializableLibTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>Dart2 Petstore Client with json_serializable Lib</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>export-dartfmt</id>
|
||||
<phase>pre-install-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>export</executable>
|
||||
<arguments>
|
||||
<argument>DART_FMT_PATH=/usr/local/bin/dartfmt</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-get</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>get</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-build-runner</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>build_runner</argument>
|
||||
<argument>build</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>pub-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>pub</executable>
|
||||
<arguments>
|
||||
<argument>run</argument>
|
||||
<argument>test</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
Reference in New Issue
Block a user