forked from loafle/openapi-generator-original
Run bin/dart2-petstore.sh to regenerate libraries
This commit is contained in:
@@ -24,4 +24,4 @@ part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
ApiClient defaultApiClient = new ApiClient();
|
||||
ApiClient defaultApiClient = ApiClient();
|
||||
|
||||
@@ -60,7 +60,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future deletePet(int petId, { String apiKey }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -110,7 +110,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(status == null) {
|
||||
@@ -161,7 +161,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null) {
|
||||
@@ -212,7 +212,7 @@ class PetApi {
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -311,7 +311,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future updatePetWithForm(int petId, { String name, String status }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -372,7 +372,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future deleteOrder(String orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
@@ -60,7 +60,7 @@ class StoreApi {
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
@@ -108,7 +108,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
|
||||
@@ -158,7 +158,7 @@ class UserApi {
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future deleteUser(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -207,7 +207,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<User> getUserByName(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -257,7 +257,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -312,7 +312,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future logoutUser() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ class QueryParam {
|
||||
class ApiClient {
|
||||
|
||||
String basePath;
|
||||
var client = new Client();
|
||||
var client = Client();
|
||||
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
|
||||
final _regList = RegExp(r'^List<(.*)>$');
|
||||
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||
|
||||
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = new OAuth();
|
||||
_authentications['api_key'] = ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = OAuth();
|
||||
}
|
||||
|
||||
void addDefaultHeader(String key, String value) {
|
||||
@@ -40,36 +40,36 @@ class ApiClient {
|
||||
case 'double':
|
||||
return value is double ? value : double.parse('$value');
|
||||
case 'ApiResponse':
|
||||
return new ApiResponse.fromJson(value);
|
||||
return ApiResponse.fromJson(value);
|
||||
case 'Category':
|
||||
return new Category.fromJson(value);
|
||||
return Category.fromJson(value);
|
||||
case 'Order':
|
||||
return new Order.fromJson(value);
|
||||
return Order.fromJson(value);
|
||||
case 'Pet':
|
||||
return new Pet.fromJson(value);
|
||||
return Pet.fromJson(value);
|
||||
case 'Tag':
|
||||
return new Tag.fromJson(value);
|
||||
return Tag.fromJson(value);
|
||||
case 'User':
|
||||
return new User.fromJson(value);
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
{
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
(match = _regList.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
(match = _regMap.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(value.keys,
|
||||
return Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
throw ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
throw ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
|
||||
dynamic deserialize(String json, String targetType) {
|
||||
@@ -78,7 +78,7 @@ class ApiClient {
|
||||
|
||||
if (targetType == 'String') return json;
|
||||
|
||||
var decodedJson = JSON.decode(json);
|
||||
var decodedJson = jsonDecode(json);
|
||||
return _deserialize(decodedJson, targetType);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class ApiClient {
|
||||
if (obj == null) {
|
||||
serialized = '';
|
||||
} else {
|
||||
serialized = JSON.encode(obj);
|
||||
serialized = json.encode(obj);
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class ApiClient {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
|
||||
if(body is MultipartRequest) {
|
||||
var request = new MultipartRequest(method, Uri.parse(url));
|
||||
var request = MultipartRequest(method, Uri.parse(url));
|
||||
request.fields.addAll(body.fields);
|
||||
request.files.addAll(body.files);
|
||||
request.headers.addAll(body.headers);
|
||||
@@ -145,7 +145,7 @@ class ApiClient {
|
||||
void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
authNames.forEach((authName) {
|
||||
Authentication auth = _authentications[authName];
|
||||
if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
|
||||
if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ part of openapi.api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
@@ -17,7 +17,7 @@ class ApiException implements Exception {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
return "ApiException $code: $message (Inner exception: $innerException)\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, parameterToString(value)));
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, parameterToString(v)));
|
||||
return values.map((v) => QueryParam(name, parameterToString(v)));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
||||
params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(new QueryParam(paramName, value));
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class HttpBasicAuth implements Authentication {
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
|
||||
headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ part of openapi.api;
|
||||
class OAuth implements Authentication {
|
||||
String accessToken;
|
||||
|
||||
OAuth({this.accessToken}) {
|
||||
}
|
||||
OAuth({this.accessToken});
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Pet {
|
||||
id = json['id'];
|
||||
category = new Category.fromJson(json['category']);
|
||||
name = json['name'];
|
||||
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
|
||||
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
|
||||
tags = Tag.listFromJson(json['tags']);
|
||||
status = json['status'];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
environment:
|
||||
sdk: '>=2.0.0 <3.0.0'
|
||||
dependencies:
|
||||
http: '>=0.11.1 <0.12.0'
|
||||
|
||||
@@ -25,4 +25,4 @@ part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
ApiClient defaultApiClient = new ApiClient();
|
||||
ApiClient defaultApiClient = ApiClient();
|
||||
|
||||
@@ -60,7 +60,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future deletePet(int petId, { String apiKey }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -110,7 +110,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(status == null) {
|
||||
@@ -161,7 +161,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null) {
|
||||
@@ -212,7 +212,7 @@ class PetApi {
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -311,7 +311,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future updatePetWithForm(int petId, { String name, String status }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -372,7 +372,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future deleteOrder(String orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
@@ -60,7 +60,7 @@ class StoreApi {
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
@@ -108,7 +108,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
|
||||
@@ -158,7 +158,7 @@ class UserApi {
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future deleteUser(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -207,7 +207,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<User> getUserByName(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -257,7 +257,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -312,7 +312,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future logoutUser() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ class QueryParam {
|
||||
class ApiClient {
|
||||
|
||||
String basePath;
|
||||
var client = new BrowserClient();
|
||||
var client = BrowserClient();
|
||||
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
|
||||
final _regList = RegExp(r'^List<(.*)>$');
|
||||
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||
|
||||
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = new OAuth();
|
||||
_authentications['api_key'] = ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = OAuth();
|
||||
}
|
||||
|
||||
void addDefaultHeader(String key, String value) {
|
||||
@@ -40,36 +40,36 @@ class ApiClient {
|
||||
case 'double':
|
||||
return value is double ? value : double.parse('$value');
|
||||
case 'ApiResponse':
|
||||
return new ApiResponse.fromJson(value);
|
||||
return ApiResponse.fromJson(value);
|
||||
case 'Category':
|
||||
return new Category.fromJson(value);
|
||||
return Category.fromJson(value);
|
||||
case 'Order':
|
||||
return new Order.fromJson(value);
|
||||
return Order.fromJson(value);
|
||||
case 'Pet':
|
||||
return new Pet.fromJson(value);
|
||||
return Pet.fromJson(value);
|
||||
case 'Tag':
|
||||
return new Tag.fromJson(value);
|
||||
return Tag.fromJson(value);
|
||||
case 'User':
|
||||
return new User.fromJson(value);
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
{
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
(match = _regList.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
(match = _regMap.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(value.keys,
|
||||
return Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
throw ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
throw ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
|
||||
dynamic deserialize(String json, String targetType) {
|
||||
@@ -78,7 +78,7 @@ class ApiClient {
|
||||
|
||||
if (targetType == 'String') return json;
|
||||
|
||||
var decodedJson = JSON.decode(json);
|
||||
var decodedJson = jsonDecode(json);
|
||||
return _deserialize(decodedJson, targetType);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class ApiClient {
|
||||
if (obj == null) {
|
||||
serialized = '';
|
||||
} else {
|
||||
serialized = JSON.encode(obj);
|
||||
serialized = json.encode(obj);
|
||||
}
|
||||
return serialized;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ class ApiClient {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
|
||||
if(body is MultipartRequest) {
|
||||
var request = new MultipartRequest(method, Uri.parse(url));
|
||||
var request = MultipartRequest(method, Uri.parse(url));
|
||||
request.fields.addAll(body.fields);
|
||||
request.files.addAll(body.files);
|
||||
request.headers.addAll(body.headers);
|
||||
@@ -145,7 +145,7 @@ class ApiClient {
|
||||
void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
authNames.forEach((authName) {
|
||||
Authentication auth = _authentications[authName];
|
||||
if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
|
||||
if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ part of openapi.api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
@@ -17,7 +17,7 @@ class ApiException implements Exception {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
return "ApiException $code: $message (Inner exception: $innerException)\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, parameterToString(value)));
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, parameterToString(v)));
|
||||
return values.map((v) => QueryParam(name, parameterToString(v)));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
||||
params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(new QueryParam(paramName, value));
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class HttpBasicAuth implements Authentication {
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str));
|
||||
headerParams["Authorization"] = "Basic " + base64.encode(utf8.encode(str));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ part of openapi.api;
|
||||
class OAuth implements Authentication {
|
||||
String accessToken;
|
||||
|
||||
OAuth({this.accessToken}) {
|
||||
}
|
||||
OAuth({this.accessToken});
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Pet {
|
||||
id = json['id'];
|
||||
category = new Category.fromJson(json['category']);
|
||||
name = json['name'];
|
||||
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
|
||||
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
|
||||
tags = Tag.listFromJson(json['tags']);
|
||||
status = json['status'];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
environment:
|
||||
sdk: '>=2.0.0 <3.0.0'
|
||||
dependencies:
|
||||
http: '>=0.11.1 <0.12.0'
|
||||
|
||||
@@ -24,4 +24,4 @@ part 'model/tag.dart';
|
||||
part 'model/user.dart';
|
||||
|
||||
|
||||
ApiClient defaultApiClient = new ApiClient();
|
||||
ApiClient defaultApiClient = ApiClient();
|
||||
|
||||
@@ -60,7 +60,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future deletePet(int petId, { String apiKey }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -110,7 +110,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(status == null) {
|
||||
@@ -161,7 +161,7 @@ class PetApi {
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null) {
|
||||
@@ -212,7 +212,7 @@ class PetApi {
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -311,7 +311,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future updatePetWithForm(int petId, { String name, String status }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
@@ -372,7 +372,7 @@ class PetApi {
|
||||
///
|
||||
///
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
|
||||
@@ -11,7 +11,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future deleteOrder(String orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
@@ -60,7 +60,7 @@ class StoreApi {
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
@@ -108,7 +108,7 @@ class StoreApi {
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
|
||||
@@ -158,7 +158,7 @@ class UserApi {
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future deleteUser(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -207,7 +207,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<User> getUserByName(String username) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -257,7 +257,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
@@ -312,7 +312,7 @@ class UserApi {
|
||||
///
|
||||
///
|
||||
Future logoutUser() async {
|
||||
Object postBody = null;
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
|
||||
@@ -10,18 +10,18 @@ class QueryParam {
|
||||
class ApiClient {
|
||||
|
||||
String basePath;
|
||||
var client = new Client();
|
||||
var client = Client();
|
||||
|
||||
Map<String, String> _defaultHeaderMap = {};
|
||||
Map<String, Authentication> _authentications = {};
|
||||
|
||||
final _RegList = new RegExp(r'^List<(.*)>$');
|
||||
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
|
||||
final _regList = RegExp(r'^List<(.*)>$');
|
||||
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||
|
||||
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
|
||||
// Setup authentications (key: authentication name, value: authentication).
|
||||
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = new OAuth();
|
||||
_authentications['api_key'] = ApiKeyAuth("header", "api_key");
|
||||
_authentications['petstore_auth'] = OAuth();
|
||||
}
|
||||
|
||||
void addDefaultHeader(String key, String value) {
|
||||
@@ -40,36 +40,36 @@ class ApiClient {
|
||||
case 'double':
|
||||
return value is double ? value : double.parse('$value');
|
||||
case 'ApiResponse':
|
||||
return new ApiResponse.fromJson(value);
|
||||
return ApiResponse.fromJson(value);
|
||||
case 'Category':
|
||||
return new Category.fromJson(value);
|
||||
return Category.fromJson(value);
|
||||
case 'Order':
|
||||
return new Order.fromJson(value);
|
||||
return Order.fromJson(value);
|
||||
case 'Pet':
|
||||
return new Pet.fromJson(value);
|
||||
return Pet.fromJson(value);
|
||||
case 'Tag':
|
||||
return new Tag.fromJson(value);
|
||||
return Tag.fromJson(value);
|
||||
case 'User':
|
||||
return new User.fromJson(value);
|
||||
return User.fromJson(value);
|
||||
default:
|
||||
{
|
||||
Match match;
|
||||
if (value is List &&
|
||||
(match = _RegList.firstMatch(targetType)) != null) {
|
||||
(match = _regList.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return value.map((v) => _deserialize(v, newTargetType)).toList();
|
||||
} else if (value is Map &&
|
||||
(match = _RegMap.firstMatch(targetType)) != null) {
|
||||
(match = _regMap.firstMatch(targetType)) != null) {
|
||||
var newTargetType = match[1];
|
||||
return new Map.fromIterables(value.keys,
|
||||
return Map.fromIterables(value.keys,
|
||||
value.values.map((v) => _deserialize(v, newTargetType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e, stack) {
|
||||
throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
throw ApiException.withInner(500, 'Exception during deserialization.', e, stack);
|
||||
}
|
||||
throw new ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
throw ApiException(500, 'Could not find a suitable class for deserialization');
|
||||
}
|
||||
|
||||
dynamic deserialize(String json, String targetType) {
|
||||
@@ -116,7 +116,7 @@ class ApiClient {
|
||||
headerParams['Content-Type'] = contentType;
|
||||
|
||||
if(body is MultipartRequest) {
|
||||
var request = new MultipartRequest(method, Uri.parse(url));
|
||||
var request = MultipartRequest(method, Uri.parse(url));
|
||||
request.fields.addAll(body.fields);
|
||||
request.files.addAll(body.files);
|
||||
request.headers.addAll(body.headers);
|
||||
@@ -145,7 +145,7 @@ class ApiClient {
|
||||
void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
authNames.forEach((authName) {
|
||||
Authentication auth = _authentications[authName];
|
||||
if (auth == null) throw new ArgumentError("Authentication undefined: " + authName);
|
||||
if (auth == null) throw ArgumentError("Authentication undefined: " + authName);
|
||||
auth.applyToParams(queryParams, headerParams);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ part of openapi.api;
|
||||
|
||||
class ApiException implements Exception {
|
||||
int code = 0;
|
||||
String message = null;
|
||||
Exception innerException = null;
|
||||
StackTrace stackTrace = null;
|
||||
String message;
|
||||
Exception innerException;
|
||||
StackTrace stackTrace;
|
||||
|
||||
ApiException(this.code, this.message);
|
||||
|
||||
@@ -17,7 +17,7 @@ class ApiException implements Exception {
|
||||
return "ApiException $code: $message";
|
||||
}
|
||||
|
||||
return "ApiException $code: $message (Inner exception: ${innerException})\n\n" +
|
||||
return "ApiException $code: $message (Inner exception: $innerException)\n\n" +
|
||||
stackTrace.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
if (name == null || name.isEmpty || value == null) return params;
|
||||
|
||||
if (value is! List) {
|
||||
params.add(new QueryParam(name, parameterToString(value)));
|
||||
params.add(QueryParam(name, parameterToString(value)));
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
|
||||
: collectionFormat; // default: csv
|
||||
|
||||
if (collectionFormat == "multi") {
|
||||
return values.map((v) => new QueryParam(name, parameterToString(v)));
|
||||
return values.map((v) => QueryParam(name, parameterToString(v)));
|
||||
}
|
||||
|
||||
String delimiter = _delimiters[collectionFormat] ?? ",";
|
||||
|
||||
params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
|
||||
if (location == 'query' && value != null) {
|
||||
queryParams.add(new QueryParam(paramName, value));
|
||||
queryParams.add(QueryParam(paramName, value));
|
||||
} else if (location == 'header' && value != null) {
|
||||
headerParams[paramName] = value;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ part of openapi.api;
|
||||
class OAuth implements Authentication {
|
||||
String accessToken;
|
||||
|
||||
OAuth({this.accessToken}) {
|
||||
}
|
||||
OAuth({this.accessToken});
|
||||
|
||||
@override
|
||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Pet {
|
||||
id = json['id'];
|
||||
category = new Category.fromJson(json['category']);
|
||||
name = json['name'];
|
||||
photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList();
|
||||
photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList();
|
||||
tags = Tag.listFromJson(json['tags']);
|
||||
status = json['status'];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
name: openapi
|
||||
version: 1.0.0
|
||||
description: OpenAPI API client
|
||||
environment:
|
||||
sdk: '>=2.0.0 <3.0.0'
|
||||
dependencies:
|
||||
http: '>=0.11.1 <0.12.0'
|
||||
|
||||
Reference in New Issue
Block a user