diff --git a/modules/openapi-generator/src/main/resources/dart/class.mustache b/modules/openapi-generator/src/main/resources/dart/class.mustache index 5090bc210d1c..64726de30675 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 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 b25f3d98a0ac..d238cbde0b36 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 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/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart/flutter_petstore/openapi/.openapi-generator/VERSION index f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 756e554c43f2..9a64a5342b4a 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 81b5ad0c8805..2c1cacc0d754 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 a3f62747d50b..61bf444e4de1 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 62e8759ede84..a1639b2a2349 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 c99c6d8c4927..db4116dd96dc 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 e485b6c32265..f188fd125a4d 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 e6f87d96bfb3..79af4521d5b3 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 69b407fd90e8..f9617f7ae4da 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e26ec8a005ac..4e77ddcf6e68 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 829677d6c9ce..13bfd799743b 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 5599d3925397..f2fddde347ae 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(); @@ -15,28 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map 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 bcc59c0e8934..1750c6a0acb1 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(); @@ -13,27 +14,35 @@ class Category { Category.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map 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 8fa9908b07ed..51d15f730415 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(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map 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 toJson() { @@ -43,18 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map 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 b80a0491345a..c64406368d87 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,13 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -43,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map 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 ce683e031c47..980c6e016302 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(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map 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 faa02b1ad134..1555eb0a3ef5 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; @@ -25,14 +26,46 @@ class User { User.fromJson(Map 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map 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 f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 e62b959a4567..84476e0626af 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 81b5ad0c8805..2c1cacc0d754 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 a3f62747d50b..61bf444e4de1 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 62e8759ede84..a1639b2a2349 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 bdc0ebf698da..7cca5bef5f26 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 e485b6c32265..f188fd125a4d 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 e6f87d96bfb3..79af4521d5b3 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 69b407fd90e8..f9617f7ae4da 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e26ec8a005ac..4e77ddcf6e68 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 829677d6c9ce..13bfd799743b 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 5599d3925397..f2fddde347ae 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(); @@ -15,28 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map 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 bcc59c0e8934..1750c6a0acb1 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(); @@ -13,27 +14,35 @@ class Category { Category.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map 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 8fa9908b07ed..51d15f730415 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(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map 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 toJson() { @@ -43,18 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map 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 b80a0491345a..c64406368d87 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,13 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -43,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map 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 ce683e031c47..980c6e016302 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(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map 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 faa02b1ad134..1555eb0a3ef5 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; @@ -25,14 +26,46 @@ class User { User.fromJson(Map 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map 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 f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 756e554c43f2..9a64a5342b4a 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 81b5ad0c8805..2c1cacc0d754 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 a3f62747d50b..61bf444e4de1 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 62e8759ede84..a1639b2a2349 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 c99c6d8c4927..db4116dd96dc 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 e485b6c32265..f188fd125a4d 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 e6f87d96bfb3..79af4521d5b3 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 69b407fd90e8..f9617f7ae4da 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e26ec8a005ac..4e77ddcf6e68 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 829677d6c9ce..13bfd799743b 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 5599d3925397..f2fddde347ae 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(); @@ -15,28 +16,41 @@ class ApiResponse { ApiResponse.fromJson(Map 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new ApiResponse.fromJson(value)); + json.forEach((String key, Map 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 bcc59c0e8934..1750c6a0acb1 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(); @@ -13,27 +14,35 @@ class Category { Category.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Category.fromJson(value)); + json.forEach((String key, Map 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 8fa9908b07ed..51d15f730415 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(); @@ -22,13 +23,36 @@ class Order { Order.fromJson(Map 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 toJson() { @@ -43,18 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } - static Map mapFromJson( - Map> json) { + static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Order.fromJson(value)); + json.forEach((String key, Map 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 b80a0491345a..c64406368d87 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,13 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -43,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Pet.fromJson(value)); + json.forEach((String key, Map 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 ce683e031c47..980c6e016302 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(); @@ -13,26 +14,35 @@ class Tag { Tag.fromJson(Map 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new Tag.fromJson(value)); + json.forEach((String key, Map 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 faa02b1ad134..1555eb0a3ef5 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; @@ -25,14 +26,46 @@ class User { User.fromJson(Map 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map> json) { var map = new Map(); if (json != null && json.length > 0) { - json.forEach((String key, Map value) => - map[key] = new User.fromJson(value)); + json.forEach((String key, Map value) => map[key] = new User.fromJson(value)); } return map; } } + 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 f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 08fe92eb0318..69c3ecd2e15d 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 0c625c2b04a6..2ded9e38bf9d 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 5f88bf5ac99c..0d05ff39bc96 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 94b245a56096..91d35801e438 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 d0db1fd65ecd..bfc05fe6ee85 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 a702da723eb4..668abe2c96bc 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 9f7ccc8df90e..a516a68d2649 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 b5a7a8248c0d..8caf6ab5ebae 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e141c062ae03..6342d8866892 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 73e2ae07ea36..aa08e5cdb4d1 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 7265f7138d0a..37c961b73207 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 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 ac6c55b2e37a..862b2c5b3858 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 d4aa944967f7..42dc28f0fa3e 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 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 toJson() { @@ -43,17 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 e9af61831d94..f7747b01cf1d 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -44,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 4a93785d1044..964fa48e0e23 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 55f62cc91985..067ce8f5c818 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 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 a8a3dd1fa255..4e43a1c2083f 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 0c625c2b04a6..2ded9e38bf9d 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 5f88bf5ac99c..0d05ff39bc96 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 94b245a56096..91d35801e438 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 acf873a63b21..dcdbd3769d87 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 a702da723eb4..668abe2c96bc 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 9f7ccc8df90e..a516a68d2649 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 b5a7a8248c0d..8caf6ab5ebae 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e141c062ae03..6342d8866892 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 73e2ae07ea36..aa08e5cdb4d1 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 7265f7138d0a..37c961b73207 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 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 ac6c55b2e37a..862b2c5b3858 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 d4aa944967f7..42dc28f0fa3e 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 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 toJson() { @@ -43,17 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 e9af61831d94..f7747b01cf1d 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -44,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 4a93785d1044..964fa48e0e23 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 55f62cc91985..067ce8f5c818 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 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 f4cb97d56ce2..afa636560641 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 5f3fe0547842..8520a219f887 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 cb39b3f22d36..5780e7f38022 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 0cbbd758efd9..df76647f11ae 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 9abe3cc83e2e..5e0605c6ea08 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 | List of user object +var body = [new List<User>()]; // List | 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 | List of user object +var body = [new List<User>()]; // List | 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 08fe92eb0318..69c3ecd2e15d 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 0c625c2b04a6..2ded9e38bf9d 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -70,26 +78,34 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "status", status)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams - .addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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') as List) - .map((item) => item as Pet) - .toList(); + } else if(response.body != null) { + return (apiClient.deserialize(response.body, 'List') 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 queryParams = []; @@ -207,84 +229,97 @@ class PetApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - List contentTypes = ["application/json", "application/xml"]; + List contentTypes = ["application/json","application/xml"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -293,11 +328,10 @@ class PetApi { List 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 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 uploadFile(int petId, - {String additionalMetadata, MultipartFile file}) async { + /// + Future 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 queryParams = []; @@ -348,11 +389,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 5f88bf5ac99c..0d05ff39bc96 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 queryParams = []; @@ -28,26 +28,34 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -66,30 +74,36 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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.from( - apiClient.deserialize(response.body, 'Map')); - ; + } else if(response.body != null) { + return new Map.from(apiClient.deserialize(response.body, 'Map')); + ; } 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 queryParams = []; @@ -113,41 +125,48 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 placeOrder(Order order) async { - Object postBody = order; + /// + Future 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 queryParams = []; @@ -156,22 +175,30 @@ class StoreApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 94b245a56096..91d35801e438 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 queryParams = []; @@ -26,39 +28,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithArrayInput(List 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 queryParams = []; @@ -67,39 +77,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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) async { - Object postBody = user; + /// + Future createUsersWithListInput(List 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 queryParams = []; @@ -108,26 +126,34 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -151,41 +175,47 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; @@ -194,88 +224,100 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 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 queryParams = []; Map headerParams = {}; Map formParams = {}; - queryParams.addAll( - _convertParametersForCollectionFormat("", "username", username)); - queryParams.addAll( - _convertParametersForCollectionFormat("", "password", password)); + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -284,44 +326,50 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 queryParams = []; @@ -330,22 +378,31 @@ class UserApi { List contentTypes = []; - String contentType = - contentTypes.length > 0 ? contentTypes[0] : "application/json"; + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List 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 d0db1fd65ecd..bfc05fe6ee85 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 for queryParams. // If collectionFormat is 'multi' a key might appear multiple times. - Future invokeAPI( - String path, - String method, - Iterable queryParams, - Object body, - Map headerParams, - Map formParams, - String contentType, - List authNames) async { + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List 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 authNames, - List queryParams, Map headerParams) { + void _updateParamsForAuth(List authNames, List queryParams, Map 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 a702da723eb4..668abe2c96bc 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 9f7ccc8df90e..a516a68d2649 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 _convertParametersForCollectionFormat( - String collectionFormat, String name, dynamic value) { + String collectionFormat, String name, dynamic value) { var params = []; // preconditions @@ -19,8 +19,8 @@ Iterable _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 _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 b5a7a8248c0d..8caf6ab5ebae 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 2c4d5f301fa1..abd5e2fe68a3 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 queryParams, Map headerParams); + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map 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 e141c062ae03..6342d8866892 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 queryParams, Map headerParams) { - String str = (username == null ? "" : username) + - ":" + - (password == null ? "" : password); + void applyToParams(List queryParams, Map 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 73e2ae07ea36..aa08e5cdb4d1 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 queryParams, Map headerParams) { + void applyToParams(List queryParams, Map 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 7265f7138d0a..37c961b73207 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 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 toJson() { - return {'code': code, 'type': type, 'message': message}; + return { + 'code': code, + 'type': type, + 'message': message + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new ApiResponse.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new ApiResponse.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 ac6c55b2e37a..862b2c5b3858 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Category.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Category.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 d4aa944967f7..42dc28f0fa3e 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 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 toJson() { @@ -43,17 +67,15 @@ class Order { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Order.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Order.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 e9af61831d94..f7747b01cf1d 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 photoUrls = []; - + List tags = []; /* pet status in the store */ String status = null; @@ -22,14 +23,36 @@ class Pet { Pet.fromJson(Map 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 toJson() { @@ -44,17 +67,15 @@ class Pet { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Pet.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Pet.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 4a93785d1044..964fa48e0e23 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 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 toJson() { - return {'id': id, 'name': name}; + return { + 'id': id, + 'name': name + }; } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new Tag.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new Tag.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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 55f62cc91985..067ce8f5c818 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 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 toJson() { @@ -49,17 +82,15 @@ class User { } static List listFromJson(List json) { - return json == null - ? new List() - : json.map((value) => new User.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new User.fromJson(value)).toList(); } static Map mapFromJson(Map json) { var map = new Map(); 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; } } +