From d4c23ae39fbdca1537788d2dd210a55b8ed0fc0b Mon Sep 17 00:00:00 2001 From: arndt <17650715+dont1like1this@users.noreply.github.com> Date: Sun, 2 Feb 2020 12:56:27 +0100 Subject: [PATCH] [dart] fix toJson does not handle complex type --- .../src/main/resources/dart/class.mustache | 16 +++- .../dart/flutter_petstore/openapi/README.md | 13 +++- .../openapi/doc/InlineObject.md | 16 ++++ .../openapi/doc/InlineObject1.md | 16 ++++ .../flutter_petstore/openapi/doc/PetApi.md | 26 ++++--- .../flutter_petstore/openapi/doc/StoreApi.md | 10 +-- .../flutter_petstore/openapi/doc/UserApi.md | 76 ++++++++++++------- .../flutter_petstore/openapi/lib/api.dart | 2 + .../openapi/lib/api/pet_api.dart | 22 +++--- .../openapi/lib/api/store_api.dart | 10 +-- .../openapi/lib/api/user_api.dart | 52 ++++++------- .../openapi/lib/api_client.dart | 5 ++ .../openapi/lib/model/api_response.dart | 6 +- .../openapi/lib/model/category.dart | 4 +- .../openapi/lib/model/inline_object.dart | 36 +++++---- .../openapi/lib/model/inline_object1.dart | 38 +++++----- .../openapi/lib/model/order.dart | 12 +-- .../openapi/lib/model/pet.dart | 12 +-- .../openapi/lib/model/tag.dart | 4 +- .../openapi/lib/model/user.dart | 16 ++-- .../lib/model/api_response.dart | 6 +- .../lib/model/category.dart | 4 +- .../lib/model/order.dart | 12 +-- .../openapi-browser-client/lib/model/pet.dart | 12 +-- .../openapi-browser-client/lib/model/tag.dart | 4 +- .../lib/model/user.dart | 16 ++-- .../dart/openapi/lib/model/api_response.dart | 6 +- .../dart/openapi/lib/model/category.dart | 4 +- .../dart/openapi/lib/model/order.dart | 12 +-- .../petstore/dart/openapi/lib/model/pet.dart | 12 +-- .../petstore/dart/openapi/lib/model/tag.dart | 4 +- .../petstore/dart/openapi/lib/model/user.dart | 16 ++-- 32 files changed, 298 insertions(+), 202 deletions(-) create mode 100644 samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject.md create mode 100644 samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject1.md diff --git a/modules/openapi-generator/src/main/resources/dart/class.mustache b/modules/openapi-generator/src/main/resources/dart/class.mustache index 64726de30675..b69af46ffaa9 100644 --- a/modules/openapi-generator/src/main/resources/dart/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart/class.mustache @@ -58,14 +58,24 @@ class {{classname}} { return { {{#vars}} {{#isDateTime}} - '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} + '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} {{/isDateTime}} {{#isDate}} - '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} + '{{baseName}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}} {{/isDate}} {{^isDateTime}} {{^isDate}} - '{{baseName}}': {{name}}{{^-last}},{{/-last}} + {{#complexType}} + {{#isListContainer}} + '{{baseName}}': {{name}} == null ? null : {{name}}.map((item) => item.toJson()).toList(){{^-last}},{{/-last}} + {{/isListContainer}} + {{^isListContainer}} + '{{baseName}}': {{name}} == null ? null : {{name}}.toJson(){{^-last}},{{/-last}} + {{/isListContainer}} + {{/complexType}} + {{^complexType}} + '{{baseName}}': {{name}}{{^-last}},{{/-last}} + {{/complexType}} {{/isDate}} {{/isDateTime}} {{/vars}} diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/README.md b/samples/client/petstore/dart/flutter_petstore/openapi/README.md index 79b7a9edc28b..baf22af4b428 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/README.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/README.md @@ -47,10 +47,11 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var body = new Pet(); // Pet | Pet object that needs to be added to the store +var pet = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(body); + var result = api_instance.addPet(pet); + print(result); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -89,6 +90,8 @@ Class | Method | HTTP request | Description - [ApiResponse](doc//ApiResponse.md) - [Category](doc//Category.md) + - [InlineObject](doc//InlineObject.md) + - [InlineObject1](doc//InlineObject1.md) - [Order](doc//Order.md) - [Pet](doc//Pet.md) - [Tag](doc//Tag.md) @@ -104,6 +107,12 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header +## auth_cookie + +- **Type**: API key +- **API key parameter name**: AUTH_KEY +- **Location**: + ## petstore_auth - **Type**: OAuth diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject.md b/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject.md new file mode 100644 index 000000000000..1789b30bb816 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject.md @@ -0,0 +1,16 @@ +# openapi.model.InlineObject + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | Updated name of the pet | [optional] [default to null] +**status** | **String** | Updated status of the pet | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject1.md b/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject1.md new file mode 100644 index 000000000000..a5c2c120129c --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/openapi/doc/InlineObject1.md @@ -0,0 +1,16 @@ +# openapi.model.InlineObject1 + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additionalMetadata** | **String** | Additional data to pass to server | [optional] [default to null] +**file** | [**MultipartFile**](File.md) | file to upload | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/doc/PetApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/doc/PetApi.md index 5780e7f38022..3a188dec3b3e 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/doc/PetApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/doc/PetApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **addPet** -> addPet(body) +> Pet addPet(pet) Add a new pet to the store @@ -31,10 +31,11 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var body = new Pet(); // Pet | Pet object that needs to be added to the store +var pet = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.addPet(body); + var result = api_instance.addPet(pet); + print(result); } catch (e) { print("Exception when calling PetApi->addPet: $e\n"); } @@ -44,11 +45,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type -void (empty response body) +[**Pet**](Pet.md) ### Authorization @@ -57,7 +58,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: Not defined + - **Accept**: application/xml, application/json [[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) @@ -243,7 +244,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(body) +> Pet updatePet(pet) Update an existing pet @@ -254,10 +255,11 @@ import 'package:openapi/api.dart'; //openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = new PetApi(); -var body = new Pet(); // Pet | Pet object that needs to be added to the store +var pet = new Pet(); // Pet | Pet object that needs to be added to the store try { - api_instance.updatePet(body); + var result = api_instance.updatePet(pet); + print(result); } catch (e) { print("Exception when calling PetApi->updatePet: $e\n"); } @@ -267,11 +269,11 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type -void (empty response body) +[**Pet**](Pet.md) ### Authorization @@ -280,7 +282,7 @@ void (empty response body) ### HTTP request headers - **Content-Type**: application/json, application/xml - - **Accept**: Not defined + - **Accept**: application/xml, application/json [[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) diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/doc/StoreApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/doc/StoreApi.md index df76647f11ae..a3c03643770d 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/doc/StoreApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/doc/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(body) +> Order placeOrder(order) 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 body = new Order(); // Order | order placed for purchasing the pet +var order = new Order(); // Order | order placed for purchasing the pet try { - var result = api_instance.placeOrder(body); + var result = api_instance.placeOrder(order); print(result); } catch (e) { print("Exception when calling StoreApi->placeOrder: $e\n"); @@ -167,7 +167,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | + **order** | [**Order**](Order.md)| order placed for purchasing the pet | ### Return type @@ -179,7 +179,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/xml, application/json [[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) diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/doc/UserApi.md b/samples/client/petstore/dart/flutter_petstore/openapi/doc/UserApi.md index d3bb61265e9a..3d87e0b9f2d8 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/doc/UserApi.md +++ b/samples/client/petstore/dart/flutter_petstore/openapi/doc/UserApi.md @@ -20,7 +20,7 @@ Method | HTTP request | Description # **createUser** -> createUser(body) +> createUser(user) Create user @@ -29,12 +29,16 @@ This can only be done by the logged in user. ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); -var body = new User(); // User | Created user object +var user = new User(); // User | Created user object try { - api_instance.createUser(body); + api_instance.createUser(user); } catch (e) { print("Exception when calling UserApi->createUser: $e\n"); } @@ -44,7 +48,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | + **user** | [**User**](User.md)| Created user object | ### Return type @@ -52,29 +56,33 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: Not defined [[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(body) +> createUsersWithArrayInput(user) Creates list of users with given input array ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); -var body = [new List<User>()]; // List | List of user object +var user = [new List<User>()]; // List | List of user object try { - api_instance.createUsersWithArrayInput(body); + api_instance.createUsersWithArrayInput(user); } catch (e) { print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); } @@ -84,7 +92,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | + **user** | [**List<User>**](User.md)| List of user object | ### Return type @@ -92,29 +100,33 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: Not defined [[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(body) +> createUsersWithListInput(user) Creates list of users with given input array ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); -var body = [new List<User>()]; // List | List of user object +var user = [new List<User>()]; // List | List of user object try { - api_instance.createUsersWithListInput(body); + api_instance.createUsersWithListInput(user); } catch (e) { print("Exception when calling UserApi->createUsersWithListInput: $e\n"); } @@ -124,7 +136,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**List<User>**](User.md)| List of user object | + **user** | [**List<User>**](User.md)| List of user object | ### Return type @@ -132,11 +144,11 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: Not defined [[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) @@ -151,6 +163,10 @@ This can only be done by the logged in user. ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); var username = username_example; // String | The name that needs to be deleted @@ -174,7 +190,7 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers @@ -275,6 +291,10 @@ Logs out current logged in user session ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); @@ -294,7 +314,7 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers @@ -304,7 +324,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, body) +> updateUser(username, user) Updated user @@ -313,13 +333,17 @@ This can only be done by the logged in user. ### Example ```dart import 'package:openapi/api.dart'; +// TODO Configure API key authorization: auth_cookie +//openapi.api.Configuration.apiKey{'AUTH_KEY'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//openapi.api.Configuration.apiKeyPrefix{'AUTH_KEY'} = "Bearer"; var api_instance = new UserApi(); var username = username_example; // String | name that need to be deleted -var body = new User(); // User | Updated user object +var user = new User(); // User | Updated user object try { - api_instance.updateUser(username, body); + api_instance.updateUser(username, user); } catch (e) { print("Exception when calling UserApi->updateUser: $e\n"); } @@ -330,7 +354,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | [default to null] - **body** | [**User**](User.md)| Updated user object | + **user** | [**User**](User.md)| Updated user object | ### Return type @@ -338,11 +362,11 @@ void (empty response body) ### Authorization -No authorization required +[auth_cookie](../README.md#auth_cookie) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: Not defined [[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) 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 9a64a5342b4a..4889d9c292e9 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/api.dart @@ -18,6 +18,8 @@ part 'api/user_api.dart'; part 'model/api_response.dart'; part 'model/category.dart'; +part 'model/inline_object.dart'; +part 'model/inline_object1.dart'; part 'model/order.dart'; part 'model/pet.dart'; part 'model/tag.dart'; 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 6ffc146490b8..8b68bf54e1da 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 @@ -10,12 +10,12 @@ class PetApi { /// Add a new pet to the store /// /// - Future addPet(Pet body) async { - Object postBody = body; + Future addPet(Pet pet) async { + Object postBody = pet; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(pet == null) { + throw new ApiException(400, "Missing required param: pet"); } // create path and map variables @@ -52,8 +52,9 @@ class PetApi { if(response.statusCode >= 400) { throw new ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { + return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; } else { - return; + return null; } } /// Deletes a pet @@ -261,12 +262,12 @@ class PetApi { /// Update an existing pet /// /// - Future updatePet(Pet body) async { - Object postBody = body; + Future updatePet(Pet pet) async { + Object postBody = pet; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(pet == null) { + throw new ApiException(400, "Missing required param: pet"); } // create path and map variables @@ -303,8 +304,9 @@ class PetApi { if(response.statusCode >= 400) { throw new ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { + return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; } else { - return; + return null; } } /// Updates a pet in the store with form data 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 7475aa4d9901..122b2a3e6c5c 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 @@ -157,12 +157,12 @@ class StoreApi { /// Place an order for a pet /// /// - Future placeOrder(Order body) async { - Object postBody = body; + Future placeOrder(Order order) async { + Object postBody = order; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(order == null) { + throw new ApiException(400, "Missing required param: order"); } // create path and map variables @@ -173,7 +173,7 @@ class StoreApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; List authNames = []; 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 8f00081a8c4c..0cca091dfaf4 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 @@ -10,12 +10,12 @@ class UserApi { /// Create user /// /// This can only be done by the logged in user. - Future createUser(User body) async { - Object postBody = body; + Future createUser(User user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(user == null) { + throw new ApiException(400, "Missing required param: user"); } // create path and map variables @@ -26,10 +26,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -59,12 +59,12 @@ class UserApi { /// Creates list of users with given input array /// /// - Future createUsersWithArrayInput(List body) async { - Object postBody = body; + Future createUsersWithArrayInput(List user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(user == null) { + throw new ApiException(400, "Missing required param: user"); } // create path and map variables @@ -75,10 +75,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -108,12 +108,12 @@ class UserApi { /// Creates list of users with given input array /// /// - Future createUsersWithListInput(List body) async { - Object postBody = body; + Future createUsersWithListInput(List user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(user == null) { + throw new ApiException(400, "Missing required param: user"); } // create path and map variables @@ -124,10 +124,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -176,7 +176,7 @@ class UserApi { List contentTypes = []; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -327,7 +327,7 @@ class UserApi { List contentTypes = []; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -357,15 +357,15 @@ class UserApi { /// Updated user /// /// This can only be done by the logged in user. - Future updateUser(String username, User body) async { - Object postBody = body; + Future updateUser(String username, User user) async { + Object postBody = user; // verify required params are set if(username == null) { throw new ApiException(400, "Missing required param: username"); } - if(body == null) { - throw new ApiException(400, "Missing required param: body"); + if(user == null) { + throw new ApiException(400, "Missing required param: user"); } // create path and map variables @@ -376,10 +376,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; - List authNames = []; + List authNames = ["auth_cookie"]; if(contentType.startsWith("multipart/form-data")) { bool hasFields = false; 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 3524b1301f31..efd646cc2f40 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 @@ -21,6 +21,7 @@ class ApiClient { ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { // Setup authentications (key: authentication name, value: authentication). _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); + _authentications['auth_cookie'] = new ApiKeyAuth("query", "AUTH_KEY"); _authentications['petstore_auth'] = new OAuth(); } @@ -43,6 +44,10 @@ class ApiClient { return new ApiResponse.fromJson(value); case 'Category': return new Category.fromJson(value); + case 'InlineObject': + return new InlineObject.fromJson(value); + case 'InlineObject1': + return new InlineObject1.fromJson(value); case 'Order': return new Order.fromJson(value); case 'Pet': 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 f2fddde347ae..07ab760f4f8c 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 @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } 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 1750c6a0acb1..817df42fa46c 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 @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart index 91e9c7d11756..70b56f81369f 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object.dart @@ -2,9 +2,9 @@ part of openapi.api; class InlineObject { /* Updated name of the pet */ - String name = null; + String name = null; /* Updated status of the pet */ - String status = null; + String status = null; InlineObject(); @override @@ -14,27 +14,33 @@ class InlineObject { InlineObject.fromJson(Map json) { if (json == null) return; - name = json['name']; - status = json['status']; + if (json['name'] == null) { + name = null; + } else { + name = json['name']; + } + if (json['status'] == null) { + status = null; + } else { + status = json['status']; + } } Map toJson() { - Map json = {}; - if (name != null) - json['name'] = name; - if (status != null) - json['status'] = status; - return json; + return { + 'name': name, + 'status': status + }; } static List listFromJson(List json) { - return json == null ? List() : json.map((value) => InlineObject.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new InlineObject.fromJson(value)).toList(); } - static Map mapFromJson(Map json) { - var map = Map(); - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic value) => map[key] = InlineObject.fromJson(value)); + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new InlineObject.fromJson(value)); } return map; } diff --git a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart index 6f5f3a426c31..f0a458ab2802 100644 --- a/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart +++ b/samples/client/petstore/dart/flutter_petstore/openapi/lib/model/inline_object1.dart @@ -2,9 +2,9 @@ part of openapi.api; class InlineObject1 { /* Additional data to pass to server */ - String additionalMetadata = null; + String additionalMetadata = null; /* file to upload */ - MultipartFile file = null; + MultipartFile file = null; InlineObject1(); @override @@ -14,29 +14,33 @@ class InlineObject1 { InlineObject1.fromJson(Map json) { if (json == null) return; - additionalMetadata = json['additionalMetadata']; - file = (json['file'] == null) ? - null : - File.fromJson(json['file']); + if (json['additionalMetadata'] == null) { + additionalMetadata = null; + } else { + additionalMetadata = json['additionalMetadata']; + } + if (json['file'] == null) { + file = null; + } else { + file = new File.fromJson(json['file']); + } } Map toJson() { - Map json = {}; - if (additionalMetadata != null) - json['additionalMetadata'] = additionalMetadata; - if (file != null) - json['file'] = file; - return json; + return { + 'additionalMetadata': additionalMetadata, + 'file': file == null ? null : file.toJson() + }; } static List listFromJson(List json) { - return json == null ? List() : json.map((value) => InlineObject1.fromJson(value)).toList(); + return json == null ? new List() : json.map((value) => new InlineObject1.fromJson(value)).toList(); } - static Map mapFromJson(Map json) { - var map = Map(); - if (json != null && json.isNotEmpty) { - json.forEach((String key, dynamic value) => map[key] = InlineObject1.fromJson(value)); + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new InlineObject1.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 51d15f730415..6bd66bb554a3 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 @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } 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 c64406368d87..30db0ebc8417 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 @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } 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 980c6e016302..4657fde0d393 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 @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } 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 1555eb0a3ef5..41ed8d742f1d 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 @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; } 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 f2fddde347ae..07ab760f4f8c 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 @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } 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 1750c6a0acb1..817df42fa46c 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 @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } 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 51d15f730415..6bd66bb554a3 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 @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } 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 c64406368d87..30db0ebc8417 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 @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } 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 980c6e016302..4657fde0d393 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 @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } 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 1555eb0a3ef5..41ed8d742f1d 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 @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; } 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 f2fddde347ae..07ab760f4f8c 100644 --- a/samples/client/petstore/dart/openapi/lib/model/api_response.dart +++ b/samples/client/petstore/dart/openapi/lib/model/api_response.dart @@ -35,9 +35,9 @@ class ApiResponse { Map toJson() { return { - 'code': code, - 'type': type, - 'message': message + 'code': code, + 'type': type, + 'message': message }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/category.dart b/samples/client/petstore/dart/openapi/lib/model/category.dart index 1750c6a0acb1..817df42fa46c 100644 --- a/samples/client/petstore/dart/openapi/lib/model/category.dart +++ b/samples/client/petstore/dart/openapi/lib/model/category.dart @@ -28,8 +28,8 @@ class Category { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/order.dart b/samples/client/petstore/dart/openapi/lib/model/order.dart index 51d15f730415..6bd66bb554a3 100644 --- a/samples/client/petstore/dart/openapi/lib/model/order.dart +++ b/samples/client/petstore/dart/openapi/lib/model/order.dart @@ -57,12 +57,12 @@ class Order { Map toJson() { return { - 'id': id, - 'petId': petId, - 'quantity': quantity, - 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), - 'status': status, - 'complete': complete + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/pet.dart b/samples/client/petstore/dart/openapi/lib/model/pet.dart index c64406368d87..30db0ebc8417 100644 --- a/samples/client/petstore/dart/openapi/lib/model/pet.dart +++ b/samples/client/petstore/dart/openapi/lib/model/pet.dart @@ -57,12 +57,12 @@ class Pet { Map toJson() { return { - 'id': id, - 'category': category, - 'name': name, - 'photoUrls': photoUrls, - 'tags': tags, - 'status': status + 'id': id, + 'category': category == null ? null : category.toJson(), + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags == null ? null : tags.map((item) => item.toJson()).toList(), + 'status': status }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/tag.dart b/samples/client/petstore/dart/openapi/lib/model/tag.dart index 980c6e016302..4657fde0d393 100644 --- a/samples/client/petstore/dart/openapi/lib/model/tag.dart +++ b/samples/client/petstore/dart/openapi/lib/model/tag.dart @@ -28,8 +28,8 @@ class Tag { Map toJson() { return { - 'id': id, - 'name': name + 'id': id, + 'name': name }; } diff --git a/samples/client/petstore/dart/openapi/lib/model/user.dart b/samples/client/petstore/dart/openapi/lib/model/user.dart index 1555eb0a3ef5..41ed8d742f1d 100644 --- a/samples/client/petstore/dart/openapi/lib/model/user.dart +++ b/samples/client/petstore/dart/openapi/lib/model/user.dart @@ -70,14 +70,14 @@ class User { Map toJson() { return { - 'id': id, - 'username': username, - 'firstName': firstName, - 'lastName': lastName, - 'email': email, - 'password': password, - 'phone': phone, - 'userStatus': userStatus + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus }; }