Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adds Http Info To Dart Api #3851

Merged
merged 1 commit into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions modules/openapi-generator/src/main/resources/dart2/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class {{classname}} {
{{classname}}([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient;

{{#operation}}
/// {{summary}}
/// {{summary}} with HTTP info returned
///
/// {{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}};

// verify required params are set
Expand Down Expand Up @@ -87,7 +87,14 @@ class {{classname}} {
formParams,
contentType,
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) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) {
Expand All @@ -112,6 +119,7 @@ class {{classname}} {
return{{#returnType}} null{{/returnType}};
}
}

{{/operation}}
}
{{/operations}}
96 changes: 80 additions & 16 deletions samples/client/petstore/dart2/openapi/lib/api/pet_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class PetApi {

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;

// verify required params are set
Expand Down Expand Up @@ -48,18 +48,26 @@ class PetApi {
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

/// Deletes a pet with HTTP info returned
///
///
Future deletePet(int petId, { String apiKey }) async {
Future deletePetWithHttpInfo(int petId, { String apiKey }) async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -98,18 +106,26 @@ class PetApi {
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

/// Finds Pets by status with HTTP info returned
///
/// 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;

// verify required params are set
Expand Down Expand Up @@ -148,7 +164,14 @@ class PetApi {
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) {
Expand All @@ -157,10 +180,11 @@ class PetApi {
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.
Future<List<Pet>> findPetsByTags(List<String> tags) async {
Future<Response> findPetsByTagsWithHttpInfo(List<String> tags) async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -199,7 +223,14 @@ class PetApi {
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) {
Expand All @@ -208,10 +239,11 @@ class PetApi {
return null;
}
}
/// Find pet by ID

/// Find pet by ID with HTTP info returned
///
/// Returns a single pet
Future<Pet> getPetById(int petId) async {
Future<Response> getPetByIdWithHttpInfo(int petId) async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -249,7 +281,14 @@ class PetApi {
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) {
Expand All @@ -258,10 +297,11 @@ class PetApi {
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;

// verify required params are set
Expand Down Expand Up @@ -299,18 +339,26 @@ class PetApi {
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

/// 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;

// verify required params are set
Expand Down Expand Up @@ -360,18 +408,26 @@ class PetApi {
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

/// 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;

// verify required params are set
Expand Down Expand Up @@ -420,7 +476,14 @@ class PetApi {
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) {
Expand All @@ -429,4 +492,5 @@ class PetApi {
return null;
}
}

}
48 changes: 40 additions & 8 deletions samples/client/petstore/dart2/openapi/lib/api/store_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class StoreApi {

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
Future deleteOrder(String orderId) async {
Future deleteOrderWithHttpInfo(String orderId) async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -48,18 +48,26 @@ class StoreApi {
formParams,
contentType,
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) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) {
} else {
return;
}
}
/// Returns pet inventories by status

/// Returns pet inventories by status with HTTP info returned
///
/// Returns a map of status codes to quantities
Future<Map<String, int>> getInventory() async {
Future<Response> getInventoryWithHttpInfo() async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -94,7 +102,14 @@ class StoreApi {
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) {
Expand All @@ -104,10 +119,11 @@ class StoreApi {
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
Future<Order> getOrderById(int orderId) async {
Future<Response> getOrderByIdWithHttpInfo(int orderId) async {
Object postBody;

// verify required params are set
Expand Down Expand Up @@ -145,7 +161,14 @@ class StoreApi {
formParams,
contentType,
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) {
throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) {
Expand All @@ -154,10 +177,11 @@ class StoreApi {
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;

// verify required params are set
Expand Down Expand Up @@ -195,7 +219,14 @@ class StoreApi {
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) {
Expand All @@ -204,4 +235,5 @@ class StoreApi {
return null;
}
}

}
Loading