forked from loafle/openapi-generator-original
Dart fix template tests (#4015)
* Clean up samples directory before fixing tests - removed from samples/client/petstore/dart2 : - purge_test.sh (doesn't seem to be used and not helpful) - openapi folder (is to be re-generated with more meaningful name) - updated dart2-petstore.sh to generate client library with new name - used updated shell script to re-generate client library - updated CI/.drone.yml to use the new client library for tests * Update petstore tests to use faked http client - skipped all of the tests that hit a live endpoint - made a fake http client that can be set to check for expected values and/or return a provided response - added some files with test data recorded from live api calls - updated the README to reflect changes to tests * Update .drone.yml so CI will run the tests
This commit is contained in:
committed by
William Cheng
parent
8383f26616
commit
41acae19e4
@@ -1,496 +0,0 @@
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
|
||||
class PetApi {
|
||||
final ApiClient apiClient;
|
||||
|
||||
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
/// Add a new pet to the store with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future addPetWithHttpInfo(Pet body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = ["application/json","application/xml"];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Add a new pet to the store
|
||||
///
|
||||
///
|
||||
Future addPet(Pet body) async {
|
||||
Response response = await addPetWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Deletes a pet with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future deletePetWithHttpInfo(int petId, { String apiKey }) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
throw ApiException(400, "Missing required param: petId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
headerParams["api_key"] = apiKey;
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Deletes a pet
|
||||
///
|
||||
///
|
||||
Future deletePet(int petId, { String apiKey }) async {
|
||||
Response response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds Pets by status with HTTP info returned
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<Response> findPetsByStatusWithHttpInfo(List<String> status) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(status == null) {
|
||||
throw ApiException(400, "Missing required param: status");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByStatus".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status));
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Finds Pets by status
|
||||
///
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
Future<List<Pet>> findPetsByStatus(List<String> status) async {
|
||||
Response response = await findPetsByStatusWithHttpInfo(status);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List).map((item) => item as Pet).toList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds Pets by tags with HTTP info returned
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<Response> findPetsByTagsWithHttpInfo(List<String> tags) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null) {
|
||||
throw ApiException(400, "Missing required param: tags");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/findByTags".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Finds Pets by tags
|
||||
///
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
Future<List<Pet>> findPetsByTags(List<String> tags) async {
|
||||
Response response = await findPetsByTagsWithHttpInfo(tags);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return (apiClient.deserialize(_decodeBodyBytes(response), 'List<Pet>') as List).map((item) => item as Pet).toList();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Find pet by ID with HTTP info returned
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Response> getPetByIdWithHttpInfo(int petId) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
throw ApiException(400, "Missing required param: petId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["api_key"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Find pet by ID
|
||||
///
|
||||
/// Returns a single pet
|
||||
Future<Pet> getPetById(int petId) async {
|
||||
Response response = await getPetByIdWithHttpInfo(petId);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Update an existing pet with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future updatePetWithHttpInfo(Pet body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = ["application/json","application/xml"];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Update an existing pet
|
||||
///
|
||||
///
|
||||
Future updatePet(Pet body) async {
|
||||
Response response = await updatePetWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
throw ApiException(400, "Missing required param: petId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = ["application/x-www-form-urlencoded"];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if (name != null) {
|
||||
hasFields = true;
|
||||
mp.fields['name'] = parameterToString(name);
|
||||
}
|
||||
if (status != null) {
|
||||
hasFields = true;
|
||||
mp.fields['status'] = parameterToString(status);
|
||||
}
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
if (name != null)
|
||||
formParams['name'] = parameterToString(name);
|
||||
if (status != null)
|
||||
formParams['status'] = parameterToString(status);
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Updates a pet in the store with form data
|
||||
///
|
||||
///
|
||||
Future updatePetWithForm(int petId, { String name, String status }) async {
|
||||
Response response = await updatePetWithFormWithHttpInfo(petId, name: name, status: status );
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// uploads an image with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future<Response> uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null) {
|
||||
throw ApiException(400, "Missing required param: petId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = ["multipart/form-data"];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["petstore_auth"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if (additionalMetadata != null) {
|
||||
hasFields = true;
|
||||
mp.fields['additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
if (file != null) {
|
||||
hasFields = true;
|
||||
mp.fields['file'] = file.field;
|
||||
mp.files.add(file);
|
||||
}
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
if (additionalMetadata != null)
|
||||
formParams['additionalMetadata'] = parameterToString(additionalMetadata);
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// uploads an image
|
||||
///
|
||||
///
|
||||
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async {
|
||||
Response response = await uploadFileWithHttpInfo(petId, additionalMetadata: additionalMetadata, file: file );
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'ApiResponse') as ApiResponse;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
|
||||
class StoreApi {
|
||||
final ApiClient apiClient;
|
||||
|
||||
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
/// Delete purchase order by ID with HTTP info returned
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future deleteOrderWithHttpInfo(String orderId) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
throw ApiException(400, "Missing required param: orderId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Delete purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
Future deleteOrder(String orderId) async {
|
||||
Response response = await deleteOrderWithHttpInfo(orderId);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status with HTTP info returned
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Response> getInventoryWithHttpInfo() async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/inventory".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = ["api_key"];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Returns pet inventories by status
|
||||
///
|
||||
/// Returns a map of status codes to quantities
|
||||
Future<Map<String, int>> getInventory() async {
|
||||
Response response = await getInventoryWithHttpInfo();
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return Map<String, int>.from(apiClient.deserialize(_decodeBodyBytes(response), 'Map<String, int>'));
|
||||
;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Find purchase order by ID with HTTP info returned
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Response> getOrderByIdWithHttpInfo(int orderId) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(orderId == null) {
|
||||
throw ApiException(400, "Missing required param: orderId");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Find purchase order by ID
|
||||
///
|
||||
/// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
Future<Order> getOrderById(int orderId) async {
|
||||
Response response = await getOrderByIdWithHttpInfo(orderId);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Place an order for a pet with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future<Response> placeOrderWithHttpInfo(Order body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/store/order".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Place an order for a pet
|
||||
///
|
||||
///
|
||||
Future<Order> placeOrder(Order body) async {
|
||||
Response response = await placeOrderWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'Order') as Order;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,473 +0,0 @@
|
||||
part of openapi.api;
|
||||
|
||||
|
||||
|
||||
class UserApi {
|
||||
final ApiClient apiClient;
|
||||
|
||||
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
||||
|
||||
/// Create user with HTTP info returned
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future createUserWithHttpInfo(User body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Create user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future createUser(User body) async {
|
||||
Response response = await createUserWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future createUsersWithArrayInputWithHttpInfo(List<User> body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithArray".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
///
|
||||
Future createUsersWithArrayInput(List<User> body) async {
|
||||
Response response = await createUsersWithArrayInputWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future createUsersWithListInputWithHttpInfo(List<User> body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/createWithList".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'POST',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Creates list of users with given input array
|
||||
///
|
||||
///
|
||||
Future createUsersWithListInput(List<User> body) async {
|
||||
Response response = await createUsersWithListInputWithHttpInfo(body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Delete user with HTTP info returned
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future deleteUserWithHttpInfo(String username) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
throw ApiException(400, "Missing required param: username");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'DELETE',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Delete user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future deleteUser(String username) async {
|
||||
Response response = await deleteUserWithHttpInfo(username);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get user by user name with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future<Response> getUserByNameWithHttpInfo(String username) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
throw ApiException(400, "Missing required param: username");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Get user by user name
|
||||
///
|
||||
///
|
||||
Future<User> getUserByName(String username) async {
|
||||
Response response = await getUserByNameWithHttpInfo(username);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'User') as User;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Logs user into the system with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future<Response> loginUserWithHttpInfo(String username, String password) async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
throw ApiException(400, "Missing required param: username");
|
||||
}
|
||||
if(password == null) {
|
||||
throw ApiException(400, "Missing required param: password");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/login".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "username", username));
|
||||
queryParams.addAll(_convertParametersForCollectionFormat("", "password", password));
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Logs user into the system
|
||||
///
|
||||
///
|
||||
Future<String> loginUser(String username, String password) async {
|
||||
Response response = await loginUserWithHttpInfo(username, password);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
return apiClient.deserialize(_decodeBodyBytes(response), 'String') as String;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session with HTTP info returned
|
||||
///
|
||||
///
|
||||
Future logoutUserWithHttpInfo() async {
|
||||
Object postBody;
|
||||
|
||||
// verify required params are set
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/logout".replaceAll("{format}","json");
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'GET',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Logs out current logged in user session
|
||||
///
|
||||
///
|
||||
Future logoutUser() async {
|
||||
Response response = await logoutUserWithHttpInfo();
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Updated user with HTTP info returned
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future updateUserWithHttpInfo(String username, User body) async {
|
||||
Object postBody = body;
|
||||
|
||||
// verify required params are set
|
||||
if(username == null) {
|
||||
throw ApiException(400, "Missing required param: username");
|
||||
}
|
||||
if(body == null) {
|
||||
throw ApiException(400, "Missing required param: body");
|
||||
}
|
||||
|
||||
// create path and map variables
|
||||
String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString());
|
||||
|
||||
// query params
|
||||
List<QueryParam> queryParams = [];
|
||||
Map<String, String> headerParams = {};
|
||||
Map<String, String> formParams = {};
|
||||
|
||||
List<String> contentTypes = [];
|
||||
|
||||
String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json";
|
||||
List<String> authNames = [];
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
bool hasFields = false;
|
||||
MultipartRequest mp = MultipartRequest(null, null);
|
||||
if(hasFields)
|
||||
postBody = mp;
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
var response = await apiClient.invokeAPI(path,
|
||||
'PUT',
|
||||
queryParams,
|
||||
postBody,
|
||||
headerParams,
|
||||
formParams,
|
||||
contentType,
|
||||
authNames);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Updated user
|
||||
///
|
||||
/// This can only be done by the logged in user.
|
||||
Future updateUser(String username, User body) async {
|
||||
Response response = await updateUserWithHttpInfo(username, body);
|
||||
if(response.statusCode >= 400) {
|
||||
throw ApiException(response.statusCode, _decodeBodyBytes(response));
|
||||
} else if(response.body != null) {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user