From 50b62bbda5c82fa0c0c8fd2b8ad1db2831b4fa57 Mon Sep 17 00:00:00 2001 From: Christian Loitsch <christian.loitsch@d3v.space> Date: Wed, 2 Jan 2019 17:13:10 +0100 Subject: [PATCH 1/5] fix: set fields to null if json value is null. --- .../src/main/resources/dart2/class.mustache | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache index b25f3d98a0a..ad8090823e0 100644 --- a/modules/openapi-generator/src/main/resources/dart2/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache @@ -16,37 +16,41 @@ class {{classname}} { {{classname}}.fromJson(Map<String, dynamic> json) { if (json == null) return; {{#vars}} + if (json['{{baseName}}'] == null) { + {{name}} = null; + } else { {{#isDateTime}} - {{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); + {{name}} = DateTime.parse(json['{{baseName}}']); {{/isDateTime}} {{#isDate}} - {{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); + {{name}} = DateTime.parse(json['{{baseName}}']); {{/isDate}} {{^isDateTime}} {{^isDate}} {{#complexType}} {{#isListContainer}} - {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); + {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); {{/isListContainer}} {{^isListContainer}} {{#isMapContainer}} - {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); + {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); {{/isMapContainer}} {{^isMapContainer}} - {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); + {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); {{/isMapContainer}} {{/isListContainer}} {{/complexType}} {{^complexType}} {{#isListContainer}} - {{name}} = ((json['{{baseName}}'] ?? []) as List).map((item) => item as {{items.datatype}}).toList(); + {{name}} = ((json['{{baseName}}'] ?? []) as List).map((item) => item as {{items.datatype}}).toList(); {{/isListContainer}} {{^isListContainer}} - {{name}} = json['{{baseName}}']; + {{name}} = json['{{baseName}}']; {{/isListContainer}} {{/complexType}} {{/isDate}} {{/isDateTime}} + } {{/vars}} } -- GitLab From f2f442e8172453a15f9fd800fc4acd6f7c21c75f Mon Sep 17 00:00:00 2001 From: Christian Loitsch <christian.loitsch@d3v.space> Date: Wed, 2 Jan 2019 18:15:47 +0100 Subject: [PATCH 2/5] rebuild dart2 petstore --- .../openapi/.openapi-generator/VERSION | 2 +- .../dart2/flutter_petstore/openapi/README.md | 4 +- .../flutter_petstore/openapi/docs/PetApi.md | 16 +- .../flutter_petstore/openapi/docs/StoreApi.md | 8 +- .../flutter_petstore/openapi/docs/UserApi.md | 32 +- .../flutter_petstore/openapi/lib/api.dart | 1 + .../openapi/lib/api/pet_api.dart | 327 ++++++++++-------- .../openapi/lib/api/store_api.dart | 145 ++++---- .../openapi/lib/api/user_api.dart | 313 ++++++++++------- .../openapi/lib/api_client.dart | 49 ++- .../openapi/lib/api_exception.dart | 3 +- .../openapi/lib/api_helper.dart | 9 +- .../openapi/lib/auth/api_key_auth.dart | 4 +- .../openapi/lib/auth/authentication.dart | 6 +- .../openapi/lib/auth/http_basic_auth.dart | 9 +- .../openapi/lib/auth/oauth.dart | 3 +- .../openapi/lib/model/api_response.dart | 37 +- .../openapi/lib/model/category.dart | 28 +- .../openapi/lib/model/order.dart | 54 ++- .../openapi/lib/model/pet.dart | 55 ++- .../openapi/lib/model/tag.dart | 28 +- .../openapi/lib/model/user.dart | 69 +++- .../.openapi-generator/VERSION | 2 +- .../dart2/openapi-browser-client/README.md | 4 +- .../openapi-browser-client/docs/PetApi.md | 16 +- .../openapi-browser-client/docs/StoreApi.md | 8 +- .../openapi-browser-client/docs/UserApi.md | 32 +- .../dart2/openapi-browser-client/lib/api.dart | 1 + .../lib/api/pet_api.dart | 327 ++++++++++-------- .../lib/api/store_api.dart | 145 ++++---- .../lib/api/user_api.dart | 313 ++++++++++------- .../lib/api_client.dart | 49 ++- .../lib/api_exception.dart | 3 +- .../lib/api_helper.dart | 9 +- .../lib/auth/api_key_auth.dart | 4 +- .../lib/auth/authentication.dart | 6 +- .../lib/auth/http_basic_auth.dart | 9 +- .../lib/auth/oauth.dart | 3 +- .../lib/model/api_response.dart | 37 +- .../lib/model/category.dart | 28 +- .../lib/model/order.dart | 54 ++- .../openapi-browser-client/lib/model/pet.dart | 55 ++- .../openapi-browser-client/lib/model/tag.dart | 28 +- .../lib/model/user.dart | 69 +++- .../dart2/openapi/.openapi-generator/VERSION | 2 +- .../client/petstore/dart2/openapi/README.md | 4 +- .../petstore/dart2/openapi/docs/PetApi.md | 16 +- .../petstore/dart2/openapi/docs/StoreApi.md | 8 +- .../petstore/dart2/openapi/docs/UserApi.md | 32 +- .../petstore/dart2/openapi/lib/api.dart | 1 + .../dart2/openapi/lib/api/pet_api.dart | 327 ++++++++++-------- .../dart2/openapi/lib/api/store_api.dart | 145 ++++---- .../dart2/openapi/lib/api/user_api.dart | 313 ++++++++++------- .../dart2/openapi/lib/api_client.dart | 49 ++- .../dart2/openapi/lib/api_exception.dart | 3 +- .../dart2/openapi/lib/api_helper.dart | 9 +- .../dart2/openapi/lib/auth/api_key_auth.dart | 4 +- .../openapi/lib/auth/authentication.dart | 6 +- .../openapi/lib/auth/http_basic_auth.dart | 9 +- .../dart2/openapi/lib/auth/oauth.dart | 3 +- .../dart2/openapi/lib/model/api_response.dart | 37 +- .../dart2/openapi/lib/model/category.dart | 28 +- .../dart2/openapi/lib/model/order.dart | 54 ++- .../petstore/dart2/openapi/lib/model/pet.dart | 55 ++- .../petstore/dart2/openapi/lib/model/tag.dart | 28 +- .../dart2/openapi/lib/model/user.dart | 69 +++- 66 files changed, 2151 insertions(+), 1455 deletions(-) diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart2/flutter_petstore/openapi/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/README.md b/samples/client/petstore/dart2/flutter_petstore/openapi/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/README.md +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/PetApi.md b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/PetApi.md +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/StoreApi.md b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/StoreApi.md +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/UserApi.md b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/docs/UserApi.md +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart index 08fe92eb031..69c3ecd2e15 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api.dart @@ -23,4 +23,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart index 0c625c2b04a..2ded9e38bf9 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart index 5f88bf5ac99..0d05ff39bc9 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart index 94b245a5609..91d35801e43 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart index d0db1fd65ec..bfc05fe6ee8 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = Client(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } on Exception catch (e, stack) { - throw ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw 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) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) - throw ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart index a702da723eb..668abe2c96b 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart index 9f7ccc8df90..a516a68d264 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart index b5a7a8248c0..8caf6ab5eba 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/authentication.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/authentication.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart index e141c062ae0..6342d886689 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } + } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart index 73e2ae07ea3..aa08e5cdb4d 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/auth/oauth.dart @@ -6,8 +6,7 @@ class OAuth implements Authentication { OAuth({this.accessToken}); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart index 7265f7138d0..37c961b7320 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -15,27 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart index ac6c55b2e37..862b2c5b385 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -13,26 +14,35 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } static Map<String, Category> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart index d4aa944967f..42dc28f0fa3 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { @@ -43,17 +67,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } static Map<String, Order> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Order.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart index e9af61831d9..f7747b01cf1 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = ((json['photoUrls'] ?? []) as List) - .map((item) => item as String) - .toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { @@ -44,17 +67,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Pet.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart index 4a93785d104..964fa48e0e2 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Tag.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart index 55f62cc9198..067ce8f5c81 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -25,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { @@ -49,17 +82,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new User.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new User.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/.openapi-generator/VERSION b/samples/client/petstore/dart2/openapi-browser-client/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/.openapi-generator/VERSION +++ b/samples/client/petstore/dart2/openapi-browser-client/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart2/openapi-browser-client/README.md b/samples/client/petstore/dart2/openapi-browser-client/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/README.md +++ b/samples/client/petstore/dart2/openapi-browser-client/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart2/openapi-browser-client/docs/PetApi.md b/samples/client/petstore/dart2/openapi-browser-client/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/docs/PetApi.md +++ b/samples/client/petstore/dart2/openapi-browser-client/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart2/openapi-browser-client/docs/StoreApi.md b/samples/client/petstore/dart2/openapi-browser-client/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/docs/StoreApi.md +++ b/samples/client/petstore/dart2/openapi-browser-client/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart2/openapi-browser-client/docs/UserApi.md b/samples/client/petstore/dart2/openapi-browser-client/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/docs/UserApi.md +++ b/samples/client/petstore/dart2/openapi-browser-client/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart index a8a3dd1fa25..4e43a1c2083 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api.dart @@ -24,4 +24,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart index 0c625c2b04a..2ded9e38bf9 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart index 5f88bf5ac99..0d05ff39bc9 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart index 94b245a5609..91d35801e43 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart index acf873a63b2..dcdbd3769d8 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = BrowserClient(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } on Exception catch (e, stack) { - throw ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw 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) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) - throw ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart index a702da723eb..668abe2c96b 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart index 9f7ccc8df90..a516a68d264 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart index b5a7a8248c0..8caf6ab5eba 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/authentication.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/authentication.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart index e141c062ae0..6342d886689 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } + } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart index 73e2ae07ea3..aa08e5cdb4d 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/auth/oauth.dart @@ -6,8 +6,7 @@ class OAuth implements Authentication { OAuth({this.accessToken}); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart index 7265f7138d0..37c961b7320 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -15,27 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart index ac6c55b2e37..862b2c5b385 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -13,26 +14,35 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } static Map<String, Category> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart index d4aa944967f..42dc28f0fa3 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { @@ -43,17 +67,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } static Map<String, Order> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Order.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart index e9af61831d9..f7747b01cf1 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = ((json['photoUrls'] ?? []) as List) - .map((item) => item as String) - .toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { @@ -44,17 +67,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Pet.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart index 4a93785d104..964fa48e0e2 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Tag.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart index 55f62cc9198..067ce8f5c81 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -25,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { @@ -49,17 +82,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new User.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new User.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart2/openapi/README.md b/samples/client/petstore/dart2/openapi/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart2/openapi/README.md +++ b/samples/client/petstore/dart2/openapi/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart2/openapi/docs/PetApi.md b/samples/client/petstore/dart2/openapi/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart2/openapi/docs/PetApi.md +++ b/samples/client/petstore/dart2/openapi/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart2/openapi/docs/StoreApi.md b/samples/client/petstore/dart2/openapi/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart2/openapi/docs/StoreApi.md +++ b/samples/client/petstore/dart2/openapi/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart2/openapi/docs/UserApi.md b/samples/client/petstore/dart2/openapi/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart2/openapi/docs/UserApi.md +++ b/samples/client/petstore/dart2/openapi/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart2/openapi/lib/api.dart b/samples/client/petstore/dart2/openapi/lib/api.dart index 08fe92eb031..69c3ecd2e15 100644 --- a/samples/client/petstore/dart2/openapi/lib/api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api.dart @@ -23,4 +23,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = ApiClient(); diff --git a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart index 0c625c2b04a..2ded9e38bf9 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart index 5f88bf5ac99..0d05ff39bc9 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart index 94b245a5609..91d35801e43 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi/lib/api_client.dart b/samples/client/petstore/dart2/openapi/lib/api_client.dart index d0db1fd65ec..bfc05fe6ee8 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = Client(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } on Exception catch (e, stack) { - throw ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw 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) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + void _updateParamsForAuth(List<String> authNames, List<QueryParam> queryParams, Map<String, String> headerParams) { authNames.forEach((authName) { Authentication auth = _authentications[authName]; - if (auth == null) - throw ArgumentError("Authentication undefined: " + authName); + if (auth == null) throw ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart2/openapi/lib/api_exception.dart b/samples/client/petstore/dart2/openapi/lib/api_exception.dart index a702da723eb..668abe2c96b 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart2/openapi/lib/api_helper.dart b/samples/client/petstore/dart2/openapi/lib/api_helper.dart index 9f7ccc8df90..a516a68d264 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart index b5a7a8248c0..8caf6ab5eba 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart2/openapi/lib/auth/authentication.dart b/samples/client/petstore/dart2/openapi/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/authentication.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart2/openapi/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart2/openapi/lib/auth/http_basic_auth.dart index e141c062ae0..6342d886689 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } + } diff --git a/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart index 73e2ae07ea3..aa08e5cdb4d 100644 --- a/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart2/openapi/lib/auth/oauth.dart @@ -6,8 +6,7 @@ class OAuth implements Authentication { OAuth({this.accessToken}); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart2/openapi/lib/model/api_response.dart b/samples/client/petstore/dart2/openapi/lib/model/api_response.dart index 7265f7138d0..37c961b7320 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -15,27 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map<String, ApiResponse> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/lib/model/category.dart b/samples/client/petstore/dart2/openapi/lib/model/category.dart index ac6c55b2e37..862b2c5b385 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -13,26 +14,35 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } static Map<String, Category> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, dynamic value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/lib/model/order.dart b/samples/client/petstore/dart2/openapi/lib/model/order.dart index d4aa944967f..42dc28f0fa3 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { @@ -43,17 +67,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } static Map<String, Order> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Order.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/lib/model/pet.dart b/samples/client/petstore/dart2/openapi/lib/model/pet.dart index e9af61831d9..f7747b01cf1 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = ((json['photoUrls'] ?? []) as List) - .map((item) => item as String) - .toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = ((json['photoUrls'] ?? []) as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { @@ -44,17 +67,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Pet.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/lib/model/tag.dart b/samples/client/petstore/dart2/openapi/lib/model/tag.dart index 4a93785d104..964fa48e0e2 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new Tag.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart2/openapi/lib/model/user.dart b/samples/client/petstore/dart2/openapi/lib/model/user.dart index 55f62cc9198..067ce8f5c81 100644 --- a/samples/client/petstore/dart2/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart2/openapi/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -25,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { @@ -49,17 +82,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, dynamic> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach( - (String key, dynamic value) => map[key] = new User.fromJson(value)); + json.forEach((String key, dynamic value) => map[key] = new User.fromJson(value)); } return map; } } + -- GitLab From 51178079eb44a369ef83beaa529d90e521b00115 Mon Sep 17 00:00:00 2001 From: Christian Loitsch <christian.loitsch@d3v.space> Date: Wed, 2 Jan 2019 18:24:01 +0100 Subject: [PATCH 3/5] rebuild dart petstore --- .../openapi/.openapi-generator/VERSION | 2 +- .../dart/flutter_petstore/openapi/README.md | 4 +- .../flutter_petstore/openapi/docs/PetApi.md | 16 +- .../flutter_petstore/openapi/docs/StoreApi.md | 8 +- .../flutter_petstore/openapi/docs/UserApi.md | 32 +- .../flutter_petstore/openapi/lib/api.dart | 1 + .../openapi/lib/api/pet_api.dart | 327 ++++++++++-------- .../openapi/lib/api/store_api.dart | 145 ++++---- .../openapi/lib/api/user_api.dart | 313 ++++++++++------- .../openapi/lib/api_client.dart | 49 ++- .../openapi/lib/api_exception.dart | 3 +- .../openapi/lib/api_helper.dart | 9 +- .../openapi/lib/auth/api_key_auth.dart | 4 +- .../openapi/lib/auth/authentication.dart | 6 +- .../openapi/lib/auth/http_basic_auth.dart | 11 +- .../openapi/lib/auth/oauth.dart | 6 +- .../openapi/lib/model/api_response.dart | 22 +- .../openapi/lib/model/category.dart | 19 +- .../openapi/lib/model/order.dart | 23 +- .../openapi/lib/model/pet.dart | 20 +- .../openapi/lib/model/tag.dart | 16 +- .../openapi/lib/model/user.dart | 21 +- .../.openapi-generator/VERSION | 2 +- .../dart/openapi-browser-client/README.md | 4 +- .../openapi-browser-client/docs/PetApi.md | 16 +- .../openapi-browser-client/docs/StoreApi.md | 8 +- .../openapi-browser-client/docs/UserApi.md | 32 +- .../dart/openapi-browser-client/lib/api.dart | 1 + .../lib/api/pet_api.dart | 327 ++++++++++-------- .../lib/api/store_api.dart | 145 ++++---- .../lib/api/user_api.dart | 313 ++++++++++------- .../lib/api_client.dart | 49 ++- .../lib/api_exception.dart | 3 +- .../lib/api_helper.dart | 9 +- .../lib/auth/api_key_auth.dart | 4 +- .../lib/auth/authentication.dart | 6 +- .../lib/auth/http_basic_auth.dart | 11 +- .../lib/auth/oauth.dart | 6 +- .../lib/model/api_response.dart | 22 +- .../lib/model/category.dart | 19 +- .../lib/model/order.dart | 23 +- .../openapi-browser-client/lib/model/pet.dart | 20 +- .../openapi-browser-client/lib/model/tag.dart | 16 +- .../lib/model/user.dart | 21 +- .../dart/openapi/.openapi-generator/VERSION | 2 +- .../client/petstore/dart/openapi/README.md | 4 +- .../petstore/dart/openapi/docs/PetApi.md | 16 +- .../petstore/dart/openapi/docs/StoreApi.md | 8 +- .../petstore/dart/openapi/docs/UserApi.md | 32 +- .../client/petstore/dart/openapi/lib/api.dart | 1 + .../dart/openapi/lib/api/pet_api.dart | 327 ++++++++++-------- .../dart/openapi/lib/api/store_api.dart | 145 ++++---- .../dart/openapi/lib/api/user_api.dart | 313 ++++++++++------- .../petstore/dart/openapi/lib/api_client.dart | 49 ++- .../dart/openapi/lib/api_exception.dart | 3 +- .../petstore/dart/openapi/lib/api_helper.dart | 9 +- .../dart/openapi/lib/auth/api_key_auth.dart | 4 +- .../dart/openapi/lib/auth/authentication.dart | 6 +- .../openapi/lib/auth/http_basic_auth.dart | 11 +- .../petstore/dart/openapi/lib/auth/oauth.dart | 6 +- .../dart/openapi/lib/model/api_response.dart | 22 +- .../dart/openapi/lib/model/category.dart | 19 +- .../dart/openapi/lib/model/order.dart | 23 +- .../petstore/dart/openapi/lib/model/pet.dart | 20 +- .../petstore/dart/openapi/lib/model/tag.dart | 16 +- .../petstore/dart/openapi/lib/model/user.dart | 21 +- 66 files changed, 1770 insertions(+), 1401 deletions(-) diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/README.md b/samples/client/petstore/dart/flutter_petstore/openapi/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/README.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/docs/PetApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/docs/PetApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/docs/StoreApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/docs/StoreApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/docs/UserApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/docs/UserApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart index 756e554c43f..9a64a5342b4 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart @@ -23,4 +23,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/pet_api.dart index 81b5ad0c880..2c1cacc0d75 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/store_api.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/store_api.dart index a3f62747d50..61bf444e4de 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/user_api.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/user_api.dart index 62e8759ede8..a1639b2a234 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody = null; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_client.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_client.dart index c99c6d8c492..db4116dd96d 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = new Client(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } catch (e, stack) { - throw new ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException( - 500, 'Could not find a suitable class for deserialization'); + throw new ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = new MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + 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 new ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_exception.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_exception.dart index e485b6c3226..f188fd125a4 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_helper.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_helper.dart index e6f87d96bfb..79af4521d5b 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => new QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/api_key_auth.dart index 69b407fd90e..f9617f7ae4d 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/authentication.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/authentication.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/http_basic_auth.dart index e26ec8a005a..4e77ddcf6e6 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } -} + +} \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/oauth.dart index 829677d6c9c..13bfd799743 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/auth/oauth.dart @@ -3,11 +3,11 @@ 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) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart index 5599d392539..a39d9500b29 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -21,22 +22,23 @@ class ApiResponse { } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map<String, ApiResponse> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart index bcc59c0e893..b9b2481dd29 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -18,22 +19,22 @@ class Category { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map<String, Category> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart index 8fa9908b07e..4e264a183ef 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -25,8 +26,7 @@ class Order { id = json['id']; petId = json['petId']; quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); status = json['status']; complete = json['complete']; } @@ -43,18 +43,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map<String, Order> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart index b80a0491345..4d2f77a1a5a 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -25,8 +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']; } @@ -43,17 +43,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart index ce683e031c4..315a326adb7 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -18,21 +19,22 @@ class Tag { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart index faa02b1ad13..0e4cc2104c7 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -49,17 +50,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/.openapi-generator/VERSION b/samples/client/petstore/dart/openapi-browser-client/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart/openapi-browser-client/.openapi-generator/VERSION +++ b/samples/client/petstore/dart/openapi-browser-client/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart/openapi-browser-client/README.md b/samples/client/petstore/dart/openapi-browser-client/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart/openapi-browser-client/README.md +++ b/samples/client/petstore/dart/openapi-browser-client/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart/openapi-browser-client/docs/PetApi.md b/samples/client/petstore/dart/openapi-browser-client/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart/openapi-browser-client/docs/PetApi.md +++ b/samples/client/petstore/dart/openapi-browser-client/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart/openapi-browser-client/docs/StoreApi.md b/samples/client/petstore/dart/openapi-browser-client/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart/openapi-browser-client/docs/StoreApi.md +++ b/samples/client/petstore/dart/openapi-browser-client/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart/openapi-browser-client/docs/UserApi.md b/samples/client/petstore/dart/openapi-browser-client/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart/openapi-browser-client/docs/UserApi.md +++ b/samples/client/petstore/dart/openapi-browser-client/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api.dart index e62b959a456..84476e0626a 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api.dart @@ -24,4 +24,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api/pet_api.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api/pet_api.dart index 81b5ad0c880..2c1cacc0d75 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api/pet_api.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api/store_api.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api/store_api.dart index a3f62747d50..61bf444e4de 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api/store_api.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api/user_api.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api/user_api.dart index 62e8759ede8..a1639b2a234 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api/user_api.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody = null; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api_client.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api_client.dart index bdc0ebf698d..7cca5bef5f2 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api_client.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = new BrowserClient(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } catch (e, stack) { - throw new ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException( - 500, 'Could not find a suitable class for deserialization'); + throw new ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = new MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + 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 new ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api_exception.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api_exception.dart index e485b6c3226..f188fd125a4 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api_exception.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/api_helper.dart b/samples/client/petstore/dart/openapi-browser-client/lib/api_helper.dart index e6f87d96bfb..79af4521d5b 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/api_helper.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => new QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/openapi-browser-client/lib/auth/api_key_auth.dart index 69b407fd90e..f9617f7ae4d 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/auth/authentication.dart b/samples/client/petstore/dart/openapi-browser-client/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/auth/authentication.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart/openapi-browser-client/lib/auth/http_basic_auth.dart index e26ec8a005a..4e77ddcf6e6 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } -} + +} \ No newline at end of file diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/auth/oauth.dart b/samples/client/petstore/dart/openapi-browser-client/lib/auth/oauth.dart index 829677d6c9c..13bfd799743 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/auth/oauth.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/auth/oauth.dart @@ -3,11 +3,11 @@ 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) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart index 5599d392539..a39d9500b29 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -21,22 +22,23 @@ class ApiResponse { } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map<String, ApiResponse> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart index bcc59c0e893..b9b2481dd29 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -18,22 +19,22 @@ class Category { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map<String, Category> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart index 8fa9908b07e..4e264a183ef 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -25,8 +26,7 @@ class Order { id = json['id']; petId = json['petId']; quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); status = json['status']; complete = json['complete']; } @@ -43,18 +43,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map<String, Order> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart index b80a0491345..4d2f77a1a5a 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -25,8 +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']; } @@ -43,17 +43,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart index ce683e031c4..315a326adb7 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -18,21 +19,22 @@ class Tag { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart index faa02b1ad13..0e4cc2104c7 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -49,17 +50,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart/openapi/.openapi-generator/VERSION index f4cb97d56ce..afa63656064 100644 --- a/samples/client/petstore/dart/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.1-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart/openapi/README.md b/samples/client/petstore/dart/openapi/README.md index 5f3fe054784..8520a219f88 100644 --- a/samples/client/petstore/dart/openapi/README.md +++ b/samples/client/petstore/dart/openapi/README.md @@ -47,10 +47,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } diff --git a/samples/client/petstore/dart/openapi/docs/PetApi.md b/samples/client/petstore/dart/openapi/docs/PetApi.md index cb39b3f22d3..5780e7f3802 100644 --- a/samples/client/petstore/dart/openapi/docs/PetApi.md +++ b/samples/client/petstore/dart/openapi/docs/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(pet) +> addPet(body) Add a new pet to the store @@ -31,10 +31,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(pet); + api_instance.addPet(body); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -243,7 +243,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updatePet** -> updatePet(pet) +> updatePet(body) Update an existing pet @@ -254,10 +254,10 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var pet = new Pet(); // Pet | Pet object that needs to be added to the store +var body = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(pet); + api_instance.updatePet(body); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,7 +267,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/dart/openapi/docs/StoreApi.md b/samples/client/petstore/dart/openapi/docs/StoreApi.md index 0cbbd758efd..df76647f11a 100644 --- a/samples/client/petstore/dart/openapi/docs/StoreApi.md +++ b/samples/client/petstore/dart/openapi/docs/StoreApi.md @@ -144,7 +144,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **placeOrder** -> Order placeOrder(order) +> Order placeOrder(body) Place an order for a pet @@ -153,10 +153,10 @@ Place an order for a pet import 'package:openapi/api.dart'; var api_instance = new StoreApi(); -var order = new Order(); // Order | order placed for purchasing the pet +var body = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(order); + var result = api_instance.placeOrder(body); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/dart/openapi/docs/UserApi.md b/samples/client/petstore/dart/openapi/docs/UserApi.md index 9abe3cc83e2..5e0605c6ea0 100644 --- a/samples/client/petstore/dart/openapi/docs/UserApi.md +++ b/samples/client/petstore/dart/openapi/docs/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(user) +> createUser(body) Create user @@ -31,10 +31,10 @@ This can only be done by the logged in user. import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = new User(); // User | Created user object +var body = new User(); // User | Created user object try { - api_instance.createUser(user); + api_instance.createUser(body); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**User**](User.md)| Created user object | + **body** | [**User**](User.md)| Created user object | ### Return type @@ -62,7 +62,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithArrayInput** -> createUsersWithArrayInput(user) +> createUsersWithArrayInput(body) Creates list of users with given input array @@ -71,10 +71,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithArrayInput(user); + api_instance.createUsersWithArrayInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +84,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -102,7 +102,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **createUsersWithListInput** -> createUsersWithListInput(user) +> createUsersWithListInput(body) Creates list of users with given input array @@ -111,10 +111,10 @@ Creates list of users with given input array import 'package:openapi/api.dart'; var api_instance = new UserApi(); -var user = [new List<User>()]; // List<User> | List of user object +var body = [new List<User>()]; // List<User> | List of user object try { - api_instance.createUsersWithListInput(user); + api_instance.createUsersWithListInput(body); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +124,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **user** | [**List<User>**](List.md)| List of user object | + **body** | [**List<User>**](List.md)| List of user object | ### Return type @@ -304,7 +304,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **updateUser** -> updateUser(username, user) +> updateUser(username, body) Updated user @@ -316,10 +316,10 @@ import 'package:openapi/api.dart'; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var user = new User(); // User | Updated user object +var body = new User(); // User | Updated user object try { - api_instance.updateUser(username, user); + api_instance.updateUser(username, body); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +330,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **user** | [**User**](User.md)| Updated user object | + **body** | [**User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/dart/openapi/lib/api.dart b/samples/client/petstore/dart/openapi/lib/api.dart index 756e554c43f..9a64a5342b4 100644 --- a/samples/client/petstore/dart/openapi/lib/api.dart +++ b/samples/client/petstore/dart/openapi/lib/api.dart @@ -23,4 +23,5 @@ part 'model/pet.dart'; part 'model/tag.dart'; part 'model/user.dart'; + ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/dart/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart/openapi/lib/api/pet_api.dart index 81b5ad0c880..2c1cacc0d75 100644 --- a/samples/client/petstore/dart/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart/openapi/lib/api/pet_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class PetApi { final ApiClient apiClient; @@ -7,60 +9,66 @@ class PetApi { /// Add a new pet to the store /// - /// - Future addPet(Pet pet) async { - Object postBody = pet; + /// + Future addPet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Deletes a pet /// - /// - Future deletePet(int petId, {String apiKey}) async { + /// + Future deletePet(int petId, { String apiKey }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Finds Pets by status /// /// Multiple status values can be provided with comma separated strings @@ -97,46 +113,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (status == null) { - throw new ApiException(400, "Missing required param: status"); + if(status == null) { + throw new ApiException(400, "Missing required param: status"); } // create path and map variables - String path = "/pet/findByStatus".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Finds Pets by tags /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -144,46 +164,50 @@ class PetApi { Object postBody = null; // verify required params are set - if (tags == null) { - throw new ApiException(400, "Missing required param: tags"); + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); } // create path and map variables - String path = "/pet/findByTags".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return (apiClient.deserialize(response.body, 'List<Pet>') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List<Pet>') as List).map((item) => item as Pet).toList(); } else { return null; } } - /// Find pet by ID /// /// Returns a single pet @@ -191,14 +215,12 @@ class PetApi { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Pet') as Pet; } else { return null; } } - /// Update an existing pet /// - /// - Future updatePet(Pet pet) async { - Object postBody = pet; + /// + Future updatePet(Pet body) async { + Object postBody = body; // verify required params are set - if (pet == null) { - throw new ApiException(400, "Missing required param: pet"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/pet".replaceAll("{format}", "json"); + 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"]; + List<String> contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updates a pet in the store with form data /// - /// - Future updatePetWithForm(int petId, {String name, String status}) async { + /// + Future updatePetWithForm(int petId, { String name, String status }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List<String> contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (name != null) { @@ -308,38 +342,45 @@ class PetApi { 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); + 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); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// uploads an image /// - /// - Future<ApiResponse> uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future<ApiResponse> uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { Object postBody = null; // verify required params are set - if (petId == null) { - throw new ApiException(400, "Missing required param: petId"); + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); } // create path and map variables - String path = "/pet/{petId}/uploadImage" - .replaceAll("{format}", "json") - .replaceAll("{" + "petId" + "}", petId.toString()); + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); // query params List<QueryParam> queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List<String> contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["petstore_auth"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); if (additionalMetadata != null) { @@ -364,19 +404,26 @@ class PetApi { mp.fields['file'] = file.field; mp.files.add(file); } - if (hasFields) postBody = mp; - } else { + if(hasFields) + postBody = mp; + } + else { if (additionalMetadata != null) - formParams['additionalMetadata'] = - parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse; } else { return null; diff --git a/samples/client/petstore/dart/openapi/lib/api/store_api.dart b/samples/client/petstore/dart/openapi/lib/api/store_api.dart index a3f62747d50..61bf444e4de 100644 --- a/samples/client/petstore/dart/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart/openapi/lib/api/store_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class StoreApi { final ApiClient apiClient; @@ -12,14 +14,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Returns pet inventories by status /// /// Returns a map of status codes to quantities @@ -57,7 +65,7 @@ class StoreApi { // verify required params are set // create path and map variables - String path = "/store/inventory".replaceAll("{format}", "json"); + String path = "/store/inventory".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = ["api_key"]; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { - return new Map<String, int>.from( - apiClient.deserialize(response.body, 'Map<String, int>')); - ; + } else if(response.body != null) { + return new Map<String, int>.from(apiClient.deserialize(response.body, 'Map<String, int>')); + ; } else { return null; } } - /// Find purchase order by ID /// /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -97,14 +111,12 @@ class StoreApi { Object postBody = null; // verify required params are set - if (orderId == null) { - throw new ApiException(400, "Missing required param: orderId"); + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); } // create path and map variables - String path = "/store/order/{orderId}" - .replaceAll("{format}", "json") - .replaceAll("{" + "orderId" + "}", orderId.toString()); + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); // query params List<QueryParam> queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; } } - /// Place an order for a pet /// - /// - Future<Order> placeOrder(Order order) async { - Object postBody = order; + /// + Future<Order> placeOrder(Order body) async { + Object postBody = body; // verify required params are set - if (order == null) { - throw new ApiException(400, "Missing required param: order"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/store/order".replaceAll("{format}", "json"); + String path = "/store/order".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'Order') as Order; } else { return null; diff --git a/samples/client/petstore/dart/openapi/lib/api/user_api.dart b/samples/client/petstore/dart/openapi/lib/api/user_api.dart index 62e8759ede8..a1639b2a234 100644 --- a/samples/client/petstore/dart/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart/openapi/lib/api/user_api.dart @@ -1,5 +1,7 @@ part of openapi.api; + + class UserApi { final ApiClient apiClient; @@ -8,16 +10,16 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User user) async { - Object postBody = user; + Future createUser(User body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user".replaceAll("{format}", "json"); + String path = "/user".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithArrayInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithArray".replaceAll("{format}", "json"); + String path = "/user/createWithArray".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Creates list of users with given input array /// - /// - Future createUsersWithListInput(List<User> user) async { - Object postBody = user; + /// + Future createUsersWithListInput(List<User> body) async { + Object postBody = body; // verify required params are set - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/createWithList".replaceAll("{format}", "json"); + String path = "/user/createWithList".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'POST', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Delete user /// /// This can only be done by the logged in user. @@ -135,14 +161,12 @@ class UserApi { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'DELETE', queryParams, - postBody, headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Get user by user name /// - /// + /// Future<User> getUserByName(String username) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'User') as User; } else { return null; } } - /// Logs user into the system /// - /// + /// Future<String> loginUser(String username, String password) async { Object postBody = null; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (password == null) { - throw new ApiException(400, "Missing required param: password"); + if(password == null) { + throw new ApiException(400, "Missing required param: password"); } // create path and map variables - String path = "/user/login".replaceAll("{format}", "json"); + 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)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) { + } else if(response.body != null) { return apiClient.deserialize(response.body, 'String') as String; } else { return null; } } - /// Logs out current logged in user session /// - /// + /// Future logoutUser() async { Object postBody = null; // verify required params are set // create path and map variables - String path = "/user/logout".replaceAll("{format}", "json"); + String path = "/user/logout".replaceAll("{format}","json"); // query params List<QueryParam> queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'GET', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } - /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User user) async { - Object postBody = user; + Future updateUser(String username, User body) async { + Object postBody = body; // verify required params are set - if (username == null) { - throw new ApiException(400, "Missing required param: username"); + if(username == null) { + throw new ApiException(400, "Missing required param: username"); } - if (user == null) { - throw new ApiException(400, "Missing required param: user"); + if(body == null) { + throw new ApiException(400, "Missing required param: body"); } // create path and map variables - String path = "/user/{username}" - .replaceAll("{format}", "json") - .replaceAll("{" + "username" + "}", username.toString()); + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); // query params List<QueryParam> queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List<String> contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List<String> authNames = []; - if (contentType.startsWith("multipart/form-data")) { + if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = new MultipartRequest(null, null); - if (hasFields) postBody = mp; - } else {} + if(hasFields) + postBody = mp; + } + else { + } - var response = await apiClient.invokeAPI(path, 'PUT', queryParams, postBody, - headerParams, formParams, contentType, authNames); + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); - if (response.statusCode >= 400) { + if(response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if(response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart/openapi/lib/api_client.dart b/samples/client/petstore/dart/openapi/lib/api_client.dart index c99c6d8c492..db4116dd96d 100644 --- a/samples/client/petstore/dart/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart/openapi/lib/api_client.dart @@ -8,6 +8,7 @@ class QueryParam { } class ApiClient { + String basePath; var client = new Client(); @@ -24,7 +25,7 @@ class ApiClient { } void addDefaultHeader(String key, String value) { - _defaultHeaderMap[key] = value; + _defaultHeaderMap[key] = value; } dynamic _deserialize(dynamic value, String targetType) { @@ -66,11 +67,9 @@ class ApiClient { } } } catch (e, stack) { - throw new ApiException.withInner( - 500, 'Exception during deserialization.', e, stack); + throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); } - throw new ApiException( - 500, 'Could not find a suitable class for deserialization'); + throw new ApiException(500, 'Could not find a suitable class for deserialization'); } dynamic deserialize(String json, String targetType) { @@ -95,28 +94,28 @@ class ApiClient { // We don't use a Map<String, String> for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future<Response> invokeAPI( - String path, - String method, - Iterable<QueryParam> queryParams, - Object body, - Map<String, String> headerParams, - Map<String, String> formParams, - String contentType, - List<String> authNames) async { + Future<Response> invokeAPI(String path, + String method, + Iterable<QueryParam> queryParams, + Object body, + Map<String, String> headerParams, + Map<String, String> formParams, + String contentType, + List<String> authNames) async { + _updateParamsForAuth(authNames, queryParams, headerParams); - var ps = queryParams - .where((p) => p.value != null) - .map((p) => '${p.name}=${p.value}'); - String queryString = ps.isNotEmpty ? '?' + ps.join('&') : ''; + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); headerParams['Content-Type'] = contentType; - if (body is MultipartRequest) { + if(body is MultipartRequest) { var request = new MultipartRequest(method, Uri.parse(url)); request.fields.addAll(body.fields); request.files.addAll(body.files); @@ -125,10 +124,8 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" - ? formParams - : serialize(body); - switch (method) { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { case "POST": return client.post(url, headers: headerParams, body: msgBody); case "PUT": @@ -145,12 +142,10 @@ class ApiClient { /// Update query and header parameters based on authentication settings. /// @param authNames The authentications to apply - void _updateParamsForAuth(List<String> authNames, - List<QueryParam> queryParams, Map<String, String> headerParams) { + 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 new ArgumentError("Authentication undefined: " + authName); auth.applyToParams(queryParams, headerParams); }); } diff --git a/samples/client/petstore/dart/openapi/lib/api_exception.dart b/samples/client/petstore/dart/openapi/lib/api_exception.dart index e485b6c3226..f188fd125a4 100644 --- a/samples/client/petstore/dart/openapi/lib/api_exception.dart +++ b/samples/client/petstore/dart/openapi/lib/api_exception.dart @@ -8,8 +8,7 @@ class ApiException implements Exception { ApiException(this.code, this.message); - ApiException.withInner( - this.code, this.message, this.innerException, this.stackTrace); + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); String toString() { if (message == null) return "ApiException"; diff --git a/samples/client/petstore/dart/openapi/lib/api_helper.dart b/samples/client/petstore/dart/openapi/lib/api_helper.dart index e6f87d96bfb..79af4521d5b 100644 --- a/samples/client/petstore/dart/openapi/lib/api_helper.dart +++ b/samples/client/petstore/dart/openapi/lib/api_helper.dart @@ -4,7 +4,7 @@ const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; // port from Java version Iterable<QueryParam> _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = <QueryParam>[]; // preconditions @@ -19,8 +19,8 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( // get the collection format collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) - ? "csv" - : collectionFormat; // default: csv + ? "csv" + : collectionFormat; // default: csv if (collectionFormat == "multi") { return values.map((v) => new QueryParam(name, parameterToString(v))); @@ -28,8 +28,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat( String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam( - name, values.map((v) => parameterToString(v)).join(delimiter))); + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } diff --git a/samples/client/petstore/dart/openapi/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/openapi/lib/auth/api_key_auth.dart index 69b407fd90e..f9617f7ae4d 100644 --- a/samples/client/petstore/dart/openapi/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart/openapi/lib/auth/api_key_auth.dart @@ -1,6 +1,7 @@ part of openapi.api; class ApiKeyAuth implements Authentication { + final String location; final String paramName; String apiKey; @@ -9,8 +10,7 @@ class ApiKeyAuth implements Authentication { ApiKeyAuth(this.location, this.paramName); @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { String value; if (apiKeyPrefix != null) { value = '$apiKeyPrefix $apiKey'; diff --git a/samples/client/petstore/dart/openapi/lib/auth/authentication.dart b/samples/client/petstore/dart/openapi/lib/auth/authentication.dart index 2c4d5f301fa..abd5e2fe68a 100644 --- a/samples/client/petstore/dart/openapi/lib/auth/authentication.dart +++ b/samples/client/petstore/dart/openapi/lib/auth/authentication.dart @@ -1,7 +1,7 @@ part of openapi.api; abstract class Authentication { - /// Apply authentication settings to header and query params. - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams); } diff --git a/samples/client/petstore/dart/openapi/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart/openapi/lib/auth/http_basic_auth.dart index e26ec8a005a..4e77ddcf6e6 100644 --- a/samples/client/petstore/dart/openapi/lib/auth/http_basic_auth.dart +++ b/samples/client/petstore/dart/openapi/lib/auth/http_basic_auth.dart @@ -1,15 +1,14 @@ part of openapi.api; class HttpBasicAuth implements Authentication { + String username; String password; @override - void applyToParams( - List<QueryParam> queryParams, Map<String, String> headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + 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)); } -} + +} \ No newline at end of file diff --git a/samples/client/petstore/dart/openapi/lib/auth/oauth.dart b/samples/client/petstore/dart/openapi/lib/auth/oauth.dart index 829677d6c9c..13bfd799743 100644 --- a/samples/client/petstore/dart/openapi/lib/auth/oauth.dart +++ b/samples/client/petstore/dart/openapi/lib/auth/oauth.dart @@ -3,11 +3,11 @@ 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) { + void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) { if (accessToken != null) { headerParams["Authorization"] = "Bearer " + accessToken; } diff --git a/samples/client/petstore/dart/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/openapi/lib/model/api_response.dart index 5599d392539..a39d9500b29 100644 --- a/samples/client/petstore/dart/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi/lib/model/api_response.dart @@ -1,10 +1,11 @@ part of openapi.api; class ApiResponse { + int code = null; - + String type = null; - + String message = null; ApiResponse(); @@ -21,22 +22,23 @@ class ApiResponse { } Map<String, dynamic> toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List<ApiResponse> listFromJson(List<dynamic> json) { - return json == null - ? new List<ApiResponse>() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List<ApiResponse>() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map<String, ApiResponse> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, ApiResponse> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, ApiResponse>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new ApiResponse.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/lib/model/category.dart b/samples/client/petstore/dart/openapi/lib/model/category.dart index bcc59c0e893..b9b2481dd29 100644 --- a/samples/client/petstore/dart/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi/lib/model/category.dart @@ -1,8 +1,9 @@ part of openapi.api; class Category { + int id = null; - + String name = null; Category(); @@ -18,22 +19,22 @@ class Category { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Category> listFromJson(List<dynamic> json) { - return json == null - ? new List<Category>() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List<Category>() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map<String, Category> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Category> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Category>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Category.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/lib/model/order.dart b/samples/client/petstore/dart/openapi/lib/model/order.dart index 8fa9908b07e..4e264a183ef 100644 --- a/samples/client/petstore/dart/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi/lib/model/order.dart @@ -1,17 +1,18 @@ part of openapi.api; class Order { + int id = null; - + int petId = null; - + int quantity = null; - + DateTime shipDate = null; /* Order Status */ String status = null; //enum statusEnum { placed, approved, delivered, };{ - + bool complete = false; Order(); @@ -25,8 +26,7 @@ class Order { id = json['id']; petId = json['petId']; quantity = json['quantity']; - shipDate = - json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); status = json['status']; complete = json['complete']; } @@ -43,18 +43,15 @@ class Order { } static List<Order> listFromJson(List<dynamic> json) { - return json == null - ? new List<Order>() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List<Order>() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map<String, Order> mapFromJson( - Map<String, Map<String, dynamic>> json) { + static Map<String, Order> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Order>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Order.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/lib/model/pet.dart b/samples/client/petstore/dart/openapi/lib/model/pet.dart index b80a0491345..4d2f77a1a5a 100644 --- a/samples/client/petstore/dart/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi/lib/model/pet.dart @@ -1,14 +1,15 @@ part of openapi.api; class Pet { + int id = null; - + Category category = null; - + String name = null; - + List<String> photoUrls = []; - + List<Tag> tags = []; /* pet status in the store */ String status = null; @@ -25,8 +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']; } @@ -43,17 +43,15 @@ class Pet { } static List<Pet> listFromJson(List<dynamic> json) { - return json == null - ? new List<Pet>() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List<Pet>() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map<String, Pet> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Pet>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Pet.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/lib/model/tag.dart b/samples/client/petstore/dart/openapi/lib/model/tag.dart index ce683e031c4..315a326adb7 100644 --- a/samples/client/petstore/dart/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi/lib/model/tag.dart @@ -1,8 +1,9 @@ part of openapi.api; class Tag { + int id = null; - + String name = null; Tag(); @@ -18,21 +19,22 @@ class Tag { } Map<String, dynamic> toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List<Tag> listFromJson(List<dynamic> json) { - return json == null - ? new List<Tag>() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List<Tag>() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map<String, Tag> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, Tag>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new Tag.fromJson(value)); } return map; } } + diff --git a/samples/client/petstore/dart/openapi/lib/model/user.dart b/samples/client/petstore/dart/openapi/lib/model/user.dart index faa02b1ad13..0e4cc2104c7 100644 --- a/samples/client/petstore/dart/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi/lib/model/user.dart @@ -1,18 +1,19 @@ part of openapi.api; class User { + int id = null; - + String username = null; - + String firstName = null; - + String lastName = null; - + String email = null; - + String password = null; - + String phone = null; /* User Status */ int userStatus = null; @@ -49,17 +50,15 @@ class User { } static List<User> listFromJson(List<dynamic> json) { - return json == null - ? new List<User>() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List<User>() : json.map((value) => new User.fromJson(value)).toList(); } static Map<String, User> mapFromJson(Map<String, Map<String, dynamic>> json) { var map = new Map<String, User>(); if (json != null && json.length > 0) { - json.forEach((String key, Map<String, dynamic> value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map<String, dynamic> value) => map[key] = new User.fromJson(value)); } return map; } } + -- GitLab From fdf6d1fb09d71e6c8ff26a26cfe3aca89b9e807b Mon Sep 17 00:00:00 2001 From: Christian Loitsch <christian.loitsch@d3v.space> Date: Wed, 2 Jan 2019 18:25:36 +0100 Subject: [PATCH 4/5] rebuild petstore --- .../openapi/lib/model/api_response.dart | 18 +++++-- .../openapi/lib/model/category.dart | 12 ++++- .../openapi/lib/model/order.dart | 36 +++++++++++--- .../openapi/lib/model/pet.dart | 36 +++++++++++--- .../openapi/lib/model/tag.dart | 12 ++++- .../openapi/lib/model/user.dart | 48 +++++++++++++++---- .../lib/model/api_response.dart | 18 +++++-- .../lib/model/category.dart | 12 ++++- .../lib/model/order.dart | 36 +++++++++++--- .../openapi-browser-client/lib/model/pet.dart | 36 +++++++++++--- .../openapi-browser-client/lib/model/tag.dart | 12 ++++- .../lib/model/user.dart | 48 +++++++++++++++---- .../dart/openapi/lib/model/api_response.dart | 18 +++++-- .../dart/openapi/lib/model/category.dart | 12 ++++- .../dart/openapi/lib/model/order.dart | 36 +++++++++++--- .../petstore/dart/openapi/lib/model/pet.dart | 36 +++++++++++--- .../petstore/dart/openapi/lib/model/tag.dart | 12 ++++- .../petstore/dart/openapi/lib/model/user.dart | 48 +++++++++++++++---- 18 files changed, 405 insertions(+), 81 deletions(-) diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart index a39d9500b29..f2fddde347a 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/api_response.dart @@ -16,9 +16,21 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart index b9b2481dd29..1750c6a0acb 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/category.dart @@ -14,8 +14,16 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart index 4e264a183ef..51d15f73041 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/order.dart @@ -23,12 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart index 4d2f77a1a5a..c64406368d8 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/pet.dart @@ -23,12 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart index 315a326adb7..980c6e01630 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/tag.dart @@ -14,8 +14,16 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart index 0e4cc2104c7..1555eb0a3ef 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/user.dart @@ -26,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart index a39d9500b29..f2fddde347a 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/api_response.dart @@ -16,9 +16,21 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart index b9b2481dd29..1750c6a0acb 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/category.dart @@ -14,8 +14,16 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart index 4e264a183ef..51d15f73041 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/order.dart @@ -23,12 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart index 4d2f77a1a5a..c64406368d8 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/pet.dart @@ -23,12 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart index 315a326adb7..980c6e01630 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/tag.dart @@ -14,8 +14,16 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart index 0e4cc2104c7..1555eb0a3ef 100644 --- a/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi-browser-client/lib/model/user.dart @@ -26,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/api_response.dart b/samples/client/petstore/dart/openapi/lib/model/api_response.dart index a39d9500b29..f2fddde347a 100644 --- a/samples/client/petstore/dart/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi/lib/model/api_response.dart @@ -16,9 +16,21 @@ class ApiResponse { ApiResponse.fromJson(Map<String, dynamic> json) { if (json == null) return; - code = json['code']; - type = json['type']; - message = json['message']; + if (json['code'] == null) { + code = null; + } else { + code = json['code']; + } + if (json['type'] == null) { + type = null; + } else { + type = json['type']; + } + if (json['message'] == null) { + message = null; + } else { + message = json['message']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/category.dart b/samples/client/petstore/dart/openapi/lib/model/category.dart index b9b2481dd29..1750c6a0acb 100644 --- a/samples/client/petstore/dart/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi/lib/model/category.dart @@ -14,8 +14,16 @@ class Category { Category.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/order.dart b/samples/client/petstore/dart/openapi/lib/model/order.dart index 4e264a183ef..51d15f73041 100644 --- a/samples/client/petstore/dart/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi/lib/model/order.dart @@ -23,12 +23,36 @@ class Order { Order.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - petId = json['petId']; - quantity = json['quantity']; - shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); - status = json['status']; - complete = json['complete']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['petId'] == null) { + petId = null; + } else { + petId = json['petId']; + } + if (json['quantity'] == null) { + quantity = null; + } else { + quantity = json['quantity']; + } + if (json['shipDate'] == null) { + shipDate = null; + } else { + shipDate = DateTime.parse(json['shipDate']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } + if (json['complete'] == null) { + complete = null; + } else { + complete = json['complete']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/pet.dart b/samples/client/petstore/dart/openapi/lib/model/pet.dart index 4d2f77a1a5a..c64406368d8 100644 --- a/samples/client/petstore/dart/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi/lib/model/pet.dart @@ -23,12 +23,36 @@ class Pet { Pet.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - category = new Category.fromJson(json['category']); - name = json['name']; - photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); - tags = Tag.listFromJson(json['tags']); - status = json['status']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['category'] == null) { + category = null; + } else { + category = new Category.fromJson(json['category']); + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['photoUrls'] == null) { + photoUrls = null; + } else { + photoUrls = (json['photoUrls'] as List).map((item) => item as String).toList(); + } + if (json['tags'] == null) { + tags = null; + } else { + tags = Tag.listFromJson(json['tags']); + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/tag.dart b/samples/client/petstore/dart/openapi/lib/model/tag.dart index 315a326adb7..980c6e01630 100644 --- a/samples/client/petstore/dart/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi/lib/model/tag.dart @@ -14,8 +14,16 @@ class Tag { Tag.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - name = json['name']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } } Map<String, dynamic> toJson() { diff --git a/samples/client/petstore/dart/openapi/lib/model/user.dart b/samples/client/petstore/dart/openapi/lib/model/user.dart index 0e4cc2104c7..1555eb0a3ef 100644 --- a/samples/client/petstore/dart/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi/lib/model/user.dart @@ -26,14 +26,46 @@ class User { User.fromJson(Map<String, dynamic> json) { if (json == null) return; - id = json['id']; - username = json['username']; - firstName = json['firstName']; - lastName = json['lastName']; - email = json['email']; - password = json['password']; - phone = json['phone']; - userStatus = json['userStatus']; + if (json['id'] == null) { + id = null; + } else { + id = json['id']; + } + if (json['username'] == null) { + username = null; + } else { + username = json['username']; + } + if (json['firstName'] == null) { + firstName = null; + } else { + firstName = json['firstName']; + } + if (json['lastName'] == null) { + lastName = null; + } else { + lastName = json['lastName']; + } + if (json['email'] == null) { + email = null; + } else { + email = json['email']; + } + if (json['password'] == null) { + password = null; + } else { + password = json['password']; + } + if (json['phone'] == null) { + phone = null; + } else { + phone = json['phone']; + } + if (json['userStatus'] == null) { + userStatus = null; + } else { + userStatus = json['userStatus']; + } } Map<String, dynamic> toJson() { -- GitLab From 4e74dfe0cad3f6b569302ce37619b39f8882a127 Mon Sep 17 00:00:00 2001 From: Christian Loitsch <christian.loitsch@d3v.space> Date: Wed, 2 Jan 2019 18:26:16 +0100 Subject: [PATCH 5/5] [DART]fix: set fields to null if json value is null. --- .../src/main/resources/dart/class.mustache | 18 +++++++++++------- .../src/main/resources/dart2/class.mustache | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart/class.mustache b/modules/openapi-generator/src/main/resources/dart/class.mustache index 5090bc210d1..64726de3067 100644 --- a/modules/openapi-generator/src/main/resources/dart/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart/class.mustache @@ -16,37 +16,41 @@ class {{classname}} { {{classname}}.fromJson(Map<String, dynamic> json) { if (json == null) return; {{#vars}} + if (json['{{baseName}}'] == null) { + {{name}} = null; + } else { {{#isDateTime}} - {{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); + {{name}} = DateTime.parse(json['{{baseName}}']); {{/isDateTime}} {{#isDate}} - {{name}} = json['{{baseName}}'] == null ? null : DateTime.parse(json['{{baseName}}']); + {{name}} = DateTime.parse(json['{{baseName}}']); {{/isDate}} {{^isDateTime}} {{^isDate}} {{#complexType}} {{#isListContainer}} - {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); + {{name}} = {{complexType}}.listFromJson(json['{{baseName}}']); {{/isListContainer}} {{^isListContainer}} {{#isMapContainer}} - {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); + {{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']); {{/isMapContainer}} {{^isMapContainer}} - {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); + {{name}} = new {{complexType}}.fromJson(json['{{baseName}}']); {{/isMapContainer}} {{/isListContainer}} {{/complexType}} {{^complexType}} {{#isListContainer}} - {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList(); + {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList(); {{/isListContainer}} {{^isListContainer}} - {{name}} = json['{{baseName}}']; + {{name}} = json['{{baseName}}']; {{/isListContainer}} {{/complexType}} {{/isDate}} {{/isDateTime}} + } {{/vars}} } diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache index ad8090823e0..d238cbde0b3 100644 --- a/modules/openapi-generator/src/main/resources/dart2/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache @@ -42,7 +42,7 @@ class {{classname}} { {{/complexType}} {{^complexType}} {{#isListContainer}} - {{name}} = ((json['{{baseName}}'] ?? []) as List).map((item) => item as {{items.datatype}}).toList(); + {{name}} = (json['{{baseName}}'] as List).map((item) => item as {{items.datatype}}).toList(); {{/isListContainer}} {{^isListContainer}} {{name}} = json['{{baseName}}']; -- GitLab