Adds Http Info To Dart Api (#3851)

This commit is contained in:
Austin Adams 2019-09-07 03:31:52 -05:00 committed by William Cheng
parent 239d68df36
commit 096f2d0fc8
4 changed files with 210 additions and 42 deletions

View File

@ -9,10 +9,10 @@ class {{classname}} {
{{classname}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; {{classname}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
{{#operation}} {{#operation}}
/// {{summary}} /// {{summary}} with HTTP info returned
/// ///
/// {{notes}} /// {{notes}}
{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async { {{#returnType}}Future<Response> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}WithHttpInfo({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
Object postBody{{#bodyParam}} = {{paramName}}{{/bodyParam}}; Object postBody{{#bodyParam}} = {{paramName}}{{/bodyParam}};
// verify required params are set // verify required params are set
@ -87,7 +87,14 @@ class {{classname}} {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// {{summary}}
///
/// {{notes}}
{{#returnType}}Future<{{{returnType}}}> {{/returnType}}{{^returnType}}Future {{/returnType}}{{nickname}}({{#allParams}}{{#required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}{ {{#allParams}}{{^required}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} }{{/hasOptionalParams}}) async {
Response response = await {{nickname}}WithHttpInfo({{#allParams}}{{#required}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}} {{#allParams}}{{^required}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} {{/hasOptionalParams}});
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -112,6 +119,7 @@ class {{classname}} {
return{{#returnType}} null{{/returnType}}; return{{#returnType}} null{{/returnType}};
} }
} }
{{/operation}} {{/operation}}
} }
{{/operations}} {{/operations}}

View File

@ -7,10 +7,10 @@ class PetApi {
PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
/// Add a new pet to the store /// Add a new pet to the store with HTTP info returned
/// ///
/// ///
Future addPet(Pet body) async { Future addPetWithHttpInfo(Pet body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -48,7 +48,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Add a new pet to the store
///
///
Future addPet(Pet body) async {
Response response = await addPetWithHttpInfo(body);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -56,10 +63,11 @@ class PetApi {
return; return;
} }
} }
/// Deletes a pet
/// Deletes a pet with HTTP info returned
/// ///
/// ///
Future deletePet(int petId, { String apiKey }) async { Future deletePetWithHttpInfo(int petId, { String apiKey }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -98,7 +106,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Deletes a pet
///
///
Future deletePet(int petId, { String apiKey }) async {
Response response = await deletePetWithHttpInfo(petId, apiKey: apiKey );
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -106,10 +121,11 @@ class PetApi {
return; return;
} }
} }
/// Finds Pets by status
/// Finds Pets by status with HTTP info returned
/// ///
/// Multiple status values can be provided with comma separated strings /// Multiple status values can be provided with comma separated strings
Future<List<Pet>> findPetsByStatus(List<String> status) async { Future<Response> findPetsByStatusWithHttpInfo(List<String> status) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -148,7 +164,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -157,10 +180,11 @@ class PetApi {
return null; return null;
} }
} }
/// Finds Pets by tags
/// Finds Pets by tags with HTTP info returned
/// ///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
Future<List<Pet>> findPetsByTags(List<String> tags) async { Future<Response> findPetsByTagsWithHttpInfo(List<String> tags) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -199,7 +223,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -208,10 +239,11 @@ class PetApi {
return null; return null;
} }
} }
/// Find pet by ID
/// Find pet by ID with HTTP info returned
/// ///
/// Returns a single pet /// Returns a single pet
Future<Pet> getPetById(int petId) async { Future<Response> getPetByIdWithHttpInfo(int petId) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -249,7 +281,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -258,10 +297,11 @@ class PetApi {
return null; return null;
} }
} }
/// Update an existing pet
/// Update an existing pet with HTTP info returned
/// ///
/// ///
Future updatePet(Pet body) async { Future updatePetWithHttpInfo(Pet body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -299,7 +339,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Update an existing pet
///
///
Future updatePet(Pet body) async {
Response response = await updatePetWithHttpInfo(body);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -307,10 +354,11 @@ class PetApi {
return; return;
} }
} }
/// Updates a pet in the store with form data
/// Updates a pet in the store with form data with HTTP info returned
/// ///
/// ///
Future updatePetWithForm(int petId, { String name, String status }) async { Future updatePetWithFormWithHttpInfo(int petId, { String name, String status }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -360,7 +408,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -368,10 +423,11 @@ class PetApi {
return; return;
} }
} }
/// uploads an image
/// uploads an image with HTTP info returned
/// ///
/// ///
Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Future<Response> uploadFileWithHttpInfo(int petId, { String additionalMetadata, MultipartFile file }) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -420,7 +476,14 @@ class PetApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -429,4 +492,5 @@ class PetApi {
return null; return null;
} }
} }
} }

View File

@ -7,10 +7,10 @@ class StoreApi {
StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
/// Delete purchase order by ID /// Delete purchase order by ID with HTTP info returned
/// ///
/// For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors /// For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
Future deleteOrder(String orderId) async { Future deleteOrderWithHttpInfo(String orderId) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -48,7 +48,14 @@ class StoreApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Delete purchase order by ID
///
/// For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
Future deleteOrder(String orderId) async {
Response response = await deleteOrderWithHttpInfo(orderId);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -56,10 +63,11 @@ class StoreApi {
return; return;
} }
} }
/// Returns pet inventories by status
/// Returns pet inventories by status with HTTP info returned
/// ///
/// Returns a map of status codes to quantities /// Returns a map of status codes to quantities
Future<Map<String, int>> getInventory() async { Future<Response> getInventoryWithHttpInfo() async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -94,7 +102,14 @@ class StoreApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -104,10 +119,11 @@ class StoreApi {
return null; return null;
} }
} }
/// Find purchase order by ID
/// Find purchase order by ID with HTTP info returned
/// ///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions /// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
Future<Order> getOrderById(int orderId) async { Future<Response> getOrderByIdWithHttpInfo(int orderId) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -145,7 +161,14 @@ class StoreApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Find purchase order by ID
///
/// For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
Future<Order> getOrderById(int orderId) async {
Response response = await getOrderByIdWithHttpInfo(orderId);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -154,10 +177,11 @@ class StoreApi {
return null; return null;
} }
} }
/// Place an order for a pet
/// Place an order for a pet with HTTP info returned
/// ///
/// ///
Future<Order> placeOrder(Order body) async { Future<Response> placeOrderWithHttpInfo(Order body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -195,7 +219,14 @@ class StoreApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Place an order for a pet
///
///
Future<Order> placeOrder(Order body) async {
Response response = await placeOrderWithHttpInfo(body);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -204,4 +235,5 @@ class StoreApi {
return null; return null;
} }
} }
} }

View File

@ -7,10 +7,10 @@ class UserApi {
UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;
/// Create user /// Create user with HTTP info returned
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future createUser(User body) async { Future createUserWithHttpInfo(User body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -48,7 +48,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -56,10 +63,11 @@ class UserApi {
return; return;
} }
} }
/// Creates list of users with given input array
/// Creates list of users with given input array with HTTP info returned
/// ///
/// ///
Future createUsersWithArrayInput(List<User> body) async { Future createUsersWithArrayInputWithHttpInfo(List<User> body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -97,7 +105,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -105,10 +120,11 @@ class UserApi {
return; return;
} }
} }
/// Creates list of users with given input array
/// Creates list of users with given input array with HTTP info returned
/// ///
/// ///
Future createUsersWithListInput(List<User> body) async { Future createUsersWithListInputWithHttpInfo(List<User> body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -146,7 +162,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -154,10 +177,11 @@ class UserApi {
return; return;
} }
} }
/// Delete user
/// Delete user with HTTP info returned
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future deleteUser(String username) async { Future deleteUserWithHttpInfo(String username) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -195,7 +219,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -203,10 +234,11 @@ class UserApi {
return; return;
} }
} }
/// Get user by user name
/// Get user by user name with HTTP info returned
/// ///
/// ///
Future<User> getUserByName(String username) async { Future<Response> getUserByNameWithHttpInfo(String username) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -244,7 +276,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Get user by user name
///
///
Future<User> getUserByName(String username) async {
Response response = await getUserByNameWithHttpInfo(username);
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -253,10 +292,11 @@ class UserApi {
return null; return null;
} }
} }
/// Logs user into the system
/// Logs user into the system with HTTP info returned
/// ///
/// ///
Future<String> loginUser(String username, String password) async { Future<Response> loginUserWithHttpInfo(String username, String password) async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -299,7 +339,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -308,10 +355,11 @@ class UserApi {
return null; return null;
} }
} }
/// Logs out current logged in user session
/// Logs out current logged in user session with HTTP info returned
/// ///
/// ///
Future logoutUser() async { Future logoutUserWithHttpInfo() async {
Object postBody; Object postBody;
// verify required params are set // verify required params are set
@ -346,7 +394,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); authNames);
return response;
}
/// Logs out current logged in user session
///
///
Future logoutUser() async {
Response response = await logoutUserWithHttpInfo();
if(response.statusCode >= 400) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -354,10 +409,11 @@ class UserApi {
return; return;
} }
} }
/// Updated user
/// Updated user with HTTP info returned
/// ///
/// This can only be done by the logged in user. /// This can only be done by the logged in user.
Future updateUser(String username, User body) async { Future updateUserWithHttpInfo(String username, User body) async {
Object postBody = body; Object postBody = body;
// verify required params are set // verify required params are set
@ -398,7 +454,14 @@ class UserApi {
formParams, formParams,
contentType, contentType,
authNames); 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) { if(response.statusCode >= 400) {
throw ApiException(response.statusCode, _decodeBodyBytes(response)); throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) { } else if(response.body != null) {
@ -406,4 +469,5 @@ class UserApi {
return; return;
} }
} }
} }