From eaa01e15f10ac4f4f1f0bbff0fce374a282f1adc Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 22 Sep 2020 09:15:20 +0800 Subject: [PATCH] dart oneof support: draft --- bin/configs/dart-petstore_client_lib.yaml | 2 +- .../main/resources/dart2/class_oneof.mustache | 24 + .../src/main/resources/dart2/model.mustache | 7 + .../src/test/resources/3_0/dart/petstore.yaml | 740 ++++++++++++++++++ .../.openapi-generator/FILES | 6 + .../dart2/petstore_client_lib/README.md | 8 +- .../petstore_client_lib/doc/InlineObject.md | 16 + .../petstore_client_lib/doc/InlineObject1.md | 16 + .../petstore_client_lib/doc/OneOfTest.md | 27 + .../dart2/petstore_client_lib/doc/PetApi.md | 26 +- .../dart2/petstore_client_lib/doc/StoreApi.md | 10 +- .../dart2/petstore_client_lib/doc/UserApi.md | 76 +- .../dart2/petstore_client_lib/lib/api.dart | 3 + .../petstore_client_lib/lib/api/pet_api.dart | 34 +- .../lib/api/store_api.dart | 16 +- .../petstore_client_lib/lib/api/user_api.dart | 76 +- .../petstore_client_lib/lib/api_client.dart | 6 + .../lib/model/inline_object.dart | 57 ++ .../lib/model/inline_object1.dart | 59 ++ .../lib/model/one_of_test.dart | 27 + .../test/inline_object1_test.dart | 24 + .../test/inline_object_test.dart | 24 + .../test/one_of_test_test.dart | 79 ++ 23 files changed, 1255 insertions(+), 108 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/dart2/class_oneof.mustache create mode 100644 modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml create mode 100644 samples/client/petstore/dart2/petstore_client_lib/doc/InlineObject.md create mode 100644 samples/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md create mode 100644 samples/client/petstore/dart2/petstore_client_lib/doc/OneOfTest.md create mode 100644 samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object.dart create mode 100644 samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object1.dart create mode 100644 samples/client/petstore/dart2/petstore_client_lib/lib/model/one_of_test.dart create mode 100644 samples/client/petstore/dart2/petstore_client_lib/test/inline_object1_test.dart create mode 100644 samples/client/petstore/dart2/petstore_client_lib/test/inline_object_test.dart create mode 100644 samples/client/petstore/dart2/petstore_client_lib/test/one_of_test_test.dart diff --git a/bin/configs/dart-petstore_client_lib.yaml b/bin/configs/dart-petstore_client_lib.yaml index 861a829ac4f..82297a53677 100644 --- a/bin/configs/dart-petstore_client_lib.yaml +++ b/bin/configs/dart-petstore_client_lib.yaml @@ -1,6 +1,6 @@ generatorName: dart outputDir: samples/client/petstore/dart2/petstore_client_lib -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/dart2 additionalProperties: hideGenerationTimestamp: "true" diff --git a/modules/openapi-generator/src/main/resources/dart2/class_oneof.mustache b/modules/openapi-generator/src/main/resources/dart2/class_oneof.mustache new file mode 100644 index 00000000000..cc944f11263 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/dart2/class_oneof.mustache @@ -0,0 +1,24 @@ +class {{classname}} { + dynamic instance; + + // default constructor + {{classname}}({ + }); + + @override + String toString() { + // TODO + } + + {{classname}}.fromJson(Map json) { + // TODO + // loop through models/primitive types defined in {{#oneOf}} {{{.}}} {{/oneOf}} + // and make sure the payload `json` deserializes to one and only one schema defined in oneOf + } + + Map toJson() { + // TOOD there should be a class member/property called "instance" + // which is dynamic type and it stores the actual instance of the schema defined in oneOf + // if oneOf is [Dog, Cat], then the instance can store either an instance of Dog or Cat + } +} diff --git a/modules/openapi-generator/src/main/resources/dart2/model.mustache b/modules/openapi-generator/src/main/resources/dart2/model.mustache index 37b030ab034..daf49460d05 100644 --- a/modules/openapi-generator/src/main/resources/dart2/model.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/model.mustache @@ -2,11 +2,18 @@ part of {{pubName}}.api; {{#models}} {{#model}} +{{#oneOf}} +{{#-first}} +{{>class_oneof}} +{{/-first}} +{{/oneOf}} +{{^oneOf}} {{#isEnum}} {{>enum}} {{/isEnum}} {{^isEnum}} {{>class}} {{/isEnum}} +{{/oneOf}} {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml new file mode 100644 index 00000000000..d527f7ea263 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/dart/petstore.yaml @@ -0,0 +1,740 @@ +openapi: 3.0.0 +servers: + - url: 'http://petstore.swagger.io/v2' +info: + description: >- + This is a sample server Petstore server. For this sample, you can use the api key + `special-key` to test the authorization filters. + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: pet + description: Everything about your Pets + - name: store + description: Access to Petstore orders + - name: user + description: Operations about user +paths: + /pet: + post: + tags: + - pet + summary: Add a new pet to the store + description: '' + operationId: addPet + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + put: + tags: + - pet + summary: Update an existing pet + description: '' + operationId: updatePet + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + '405': + description: Validation exception + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + $ref: '#/components/requestBodies/Pet' + /pet/findByStatus: + get: + tags: + - pet + summary: Finds Pets by status + description: Multiple status values can be provided with comma separated strings + operationId: findPetsByStatus + parameters: + - name: status + in: query + description: Status values that need to be considered for filter + required: true + style: form + explode: false + schema: + type: array + items: + type: string + enum: + - available + - pending + - sold + default: available + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid status value + security: + - petstore_auth: + - 'read:pets' + /pet/findByTags: + get: + tags: + - pet + summary: Finds Pets by tags + description: >- + Multiple tags can be provided with comma separated strings. Use tag1, + tag2, tag3 for testing. + operationId: findPetsByTags + parameters: + - name: tags + in: query + description: Tags to filter by + required: true + style: form + explode: false + schema: + type: array + items: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid tag value + security: + - petstore_auth: + - 'read:pets' + deprecated: true + '/pet/{petId}': + get: + tags: + - pet + summary: Find pet by ID + description: Returns a single pet + operationId: getPetById + parameters: + - name: petId + in: path + description: ID of pet to return + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Pet' + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid ID supplied + '404': + description: Pet not found + security: + - api_key: [] + post: + tags: + - pet + summary: Updates a pet in the store with form data + description: '' + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: integer + format: int64 + responses: + '405': + description: Invalid input + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + delete: + tags: + - pet + summary: Deletes a pet + description: '' + operationId: deletePet + parameters: + - name: api_key + in: header + required: false + schema: + type: string + - name: petId + in: path + description: Pet id to delete + required: true + schema: + type: integer + format: int64 + responses: + '400': + description: Invalid pet value + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + '/pet/{petId}/uploadImage': + post: + tags: + - pet + summary: uploads an image + description: '' + operationId: uploadFile + parameters: + - name: petId + in: path + description: ID of pet to update + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ApiResponse' + security: + - petstore_auth: + - 'write:pets' + - 'read:pets' + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + type: string + format: binary + /store/inventory: + get: + tags: + - store + summary: Returns pet inventories by status + description: Returns a map of status codes to quantities + operationId: getInventory + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 + security: + - api_key: [] + /store/order: + post: + tags: + - store + summary: Place an order for a pet + description: '' + operationId: placeOrder + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid Order + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet + required: true + '/store/order/{orderId}': + get: + tags: + - store + summary: Find purchase order by ID + description: >- + For valid response try integer IDs with value <= 5 or > 10. Other values + will generated exceptions + operationId: getOrderById + parameters: + - name: orderId + in: path + description: ID of pet that needs to be fetched + required: true + schema: + type: integer + format: int64 + minimum: 1 + maximum: 5 + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/Order' + application/json: + schema: + $ref: '#/components/schemas/Order' + '400': + description: Invalid ID supplied + '404': + description: Order not found + delete: + tags: + - store + summary: Delete purchase order by ID + description: >- + For valid response try integer IDs with value < 1000. Anything above + 1000 or nonintegers will generate API errors + operationId: deleteOrder + parameters: + - name: orderId + in: path + description: ID of the order that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid ID supplied + '404': + description: Order not found + /user: + post: + tags: + - user + summary: Create user + description: This can only be done by the logged in user. + operationId: createUser + responses: + default: + description: successful operation + security: + - api_key: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Created user object + required: true + /user/createWithArray: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithArrayInput + responses: + default: + description: successful operation + security: + - api_key: [] + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/createWithList: + post: + tags: + - user + summary: Creates list of users with given input array + description: '' + operationId: createUsersWithListInput + responses: + default: + description: successful operation + security: + - api_key: [] + requestBody: + $ref: '#/components/requestBodies/UserArray' + /user/login: + get: + tags: + - user + summary: Logs user into the system + description: '' + operationId: loginUser + parameters: + - name: username + in: query + description: The user name for login + required: true + schema: + type: string + pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$' + - name: password + in: query + description: The password for login in clear text + required: true + schema: + type: string + responses: + '200': + description: successful operation + headers: + Set-Cookie: + description: >- + Cookie authentication key for use with the `api_key` + apiKey authentication. + schema: + type: string + example: AUTH_KEY=abcde12345; Path=/; HttpOnly + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: integer + format: int32 + X-Expires-After: + description: date in UTC when toekn expires + schema: + type: string + format: date-time + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string + '400': + description: Invalid username/password supplied + /user/logout: + get: + tags: + - user + summary: Logs out current logged in user session + description: '' + operationId: logoutUser + responses: + default: + description: successful operation + security: + - api_key: [] + '/user/{username}': + get: + tags: + - user + summary: Get user by user name + description: '' + operationId: getUserByName + parameters: + - name: username + in: path + description: The name that needs to be fetched. Use user1 for testing. + required: true + schema: + type: string + responses: + '200': + description: successful operation + content: + application/xml: + schema: + $ref: '#/components/schemas/User' + application/json: + schema: + $ref: '#/components/schemas/User' + '400': + description: Invalid username supplied + '404': + description: User not found + put: + tags: + - user + summary: Updated user + description: This can only be done by the logged in user. + operationId: updateUser + parameters: + - name: username + in: path + description: name that need to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid user supplied + '404': + description: User not found + security: + - api_key: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: Updated user object + required: true + delete: + tags: + - user + summary: Delete user + description: This can only be done by the logged in user. + operationId: deleteUser + parameters: + - name: username + in: path + description: The name that needs to be deleted + required: true + schema: + type: string + responses: + '400': + description: Invalid username supplied + '404': + description: User not found + security: + - api_key: [] +externalDocs: + description: Find out more about Swagger + url: 'http://swagger.io' +components: + requestBodies: + UserArray: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/User' + description: List of user object + required: true + Pet: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + securitySchemes: + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog' + scopes: + 'write:pets': modify pets in your account + 'read:pets': read your pets + api_key: + type: apiKey + name: api_key + in: header + schemas: + Order: + title: Pet Order + description: An order for a pets from the pet store + type: object + properties: + id: + type: integer + format: int64 + petId: + type: integer + format: int64 + quantity: + type: integer + format: int32 + shipDate: + type: string + format: date-time + status: + type: string + description: Order Status + enum: + - placed + - approved + - delivered + complete: + type: boolean + default: false + xml: + name: Order + Category: + title: Pet category + description: A category for a pet + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$' + xml: + name: Category + User: + title: a User + description: A User who is purchasing from the pet store + type: object + properties: + id: + type: integer + format: int64 + username: + type: string + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status + xml: + name: User + Tag: + title: Pet Tag + description: A tag for a pet + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + xml: + name: Tag + Pet: + title: a Pet + description: A pet for sale in the pet store + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + category: + $ref: '#/components/schemas/Category' + name: + type: string + example: doggie + photoUrls: + type: array + xml: + name: photoUrl + wrapped: true + items: + type: string + tags: + type: array + xml: + name: tag + wrapped: true + items: + $ref: '#/components/schemas/Tag' + status: + type: string + description: pet status in the store + enum: + - available + - pending + - sold + xml: + name: Pet + ApiResponse: + title: An uploaded response + description: Describes the result of uploading an image resource + type: object + properties: + code: + type: integer + format: int32 + type: + type: string + message: + type: string + OneOfTest: + oneOf: + - $ref: '#/components/schemas/Pet' + - $ref: '#/components/schemas/User' diff --git a/samples/client/petstore/dart2/petstore_client_lib/.openapi-generator/FILES b/samples/client/petstore/dart2/petstore_client_lib/.openapi-generator/FILES index 7cc5afea821..a2be76273af 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/.openapi-generator/FILES +++ b/samples/client/petstore/dart2/petstore_client_lib/.openapi-generator/FILES @@ -3,6 +3,9 @@ README.md doc/ApiResponse.md doc/Category.md +doc/InlineObject.md +doc/InlineObject1.md +doc/OneOfTest.md doc/Order.md doc/Pet.md doc/PetApi.md @@ -25,6 +28,9 @@ lib/auth/http_bearer_auth.dart lib/auth/oauth.dart lib/model/api_response.dart lib/model/category.dart +lib/model/inline_object.dart +lib/model/inline_object1.dart +lib/model/one_of_test.dart lib/model/order.dart lib/model/pet.dart lib/model/tag.dart diff --git a/samples/client/petstore/dart2/petstore_client_lib/README.md b/samples/client/petstore/dart2/petstore_client_lib/README.md index 1cf4ca28f0a..b2c2ab34ec7 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/README.md +++ b/samples/client/petstore/dart2/petstore_client_lib/README.md @@ -43,10 +43,11 @@ import 'package:openapi/api.dart'; //defaultApiClient.getAuthentication('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = PetApi(); -var body = Pet(); // Pet | Pet object that needs to be added to the store +var pet = 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"); } @@ -85,6 +86,9 @@ Class | Method | HTTP request | Description - [ApiResponse](doc//ApiResponse.md) - [Category](doc//Category.md) + - [InlineObject](doc//InlineObject.md) + - [InlineObject1](doc//InlineObject1.md) + - [OneOfTest](doc//OneOfTest.md) - [Order](doc//Order.md) - [Pet](doc//Pet.md) - [Tag](doc//Tag.md) diff --git a/samples/client/petstore/dart2/petstore_client_lib/doc/InlineObject.md b/samples/client/petstore/dart2/petstore_client_lib/doc/InlineObject.md new file mode 100644 index 00000000000..9aa480dee58 --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/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] +**status** | **String** | Updated status of the pet | [optional] + +[[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/dart2/petstore_client_lib/doc/InlineObject1.md b/samples/client/petstore/dart2/petstore_client_lib/doc/InlineObject1.md new file mode 100644 index 00000000000..013aa87e9bb --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/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] +**file** | [**MultipartFile**](File.md) | file to upload | [optional] + +[[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/dart2/petstore_client_lib/doc/OneOfTest.md b/samples/client/petstore/dart2/petstore_client_lib/doc/OneOfTest.md new file mode 100644 index 00000000000..ba557953871 --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/doc/OneOfTest.md @@ -0,0 +1,27 @@ +# openapi.model.OneOfTest + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photoUrls** | **List<String>** | | [default to const []] +**tags** | [**List<Tag>**](Tag.md) | | [optional] [default to const []] +**status** | **String** | pet status in the store | [optional] +**username** | **String** | | [optional] +**firstName** | **String** | | [optional] +**lastName** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**userStatus** | **int** | User Status | [optional] + +[[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/dart2/petstore_client_lib/doc/PetApi.md b/samples/client/petstore/dart2/petstore_client_lib/doc/PetApi.md index cdd56362b2d..a0ba3cec865 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/doc/PetApi.md +++ b/samples/client/petstore/dart2/petstore_client_lib/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'; //defaultApiClient.getAuthentication('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = PetApi(); -var body = Pet(); // Pet | Pet object that needs to be added to the store +var pet = 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'; //defaultApiClient.getAuthentication('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN'; var api_instance = PetApi(); -var body = Pet(); // Pet | Pet object that needs to be added to the store +var pet = 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/dart2/petstore_client_lib/doc/StoreApi.md b/samples/client/petstore/dart2/petstore_client_lib/doc/StoreApi.md index 6ff167fc834..f1f5d9c9b4f 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/doc/StoreApi.md +++ b/samples/client/petstore/dart2/petstore_client_lib/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 = StoreApi(); -var body = Order(); // Order | order placed for purchasing the pet +var order = 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/dart2/petstore_client_lib/doc/UserApi.md b/samples/client/petstore/dart2/petstore_client_lib/doc/UserApi.md index f3809ef73a3..6e6a49b652d 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/doc/UserApi.md +++ b/samples/client/petstore/dart2/petstore_client_lib/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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = UserApi(); -var body = User(); // User | Created user object +var user = 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 +[api_key](../README.md#api_key) ### 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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = UserApi(); -var body = [List<User>()]; // List | List of user object +var user = [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 +[api_key](../README.md#api_key) ### 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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = UserApi(); -var body = [List<User>()]; // List | List of user object +var user = [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 +[api_key](../README.md#api_key) ### 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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = 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 +[api_key](../README.md#api_key) ### 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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = UserApi(); @@ -294,7 +314,7 @@ void (empty response body) ### Authorization -No authorization required +[api_key](../README.md#api_key) ### 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: api_key +//defaultApiClient.getAuthentication('api_key').apiKey = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//defaultApiClient.getAuthentication('api_key').apiKeyPrefix = 'Bearer'; var api_instance = UserApi(); var username = username_example; // String | name that need to be deleted -var body = User(); // User | Updated user object +var user = 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 | - **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 +[api_key](../README.md#api_key) ### 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/dart2/petstore_client_lib/lib/api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart index baf59a69c13..08387ca9769 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api.dart @@ -21,6 +21,9 @@ 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/one_of_test.dart'; part 'model/order.dart'; part 'model/pet.dart'; part 'model/tag.dart'; diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart index 56efbc2492b..0ae84354ad3 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart @@ -10,12 +10,12 @@ class PetApi { /// Add a new pet to the store with HTTP info returned /// /// - Future addPetWithHttpInfo(Pet body) async { - Object postBody = body; + Future addPetWithHttpInfo(Pet pet) async { + Object postBody = pet; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(pet == null) { + throw ApiException(400, "Missing required param: pet"); } // create path and map variables @@ -53,16 +53,17 @@ class PetApi { /// Add a new pet to the store /// - ///Pet body (required): + ///Pet pet (required): /// Pet object that needs to be added to the store /// - Future addPet(Pet body) async { - Response response = await addPetWithHttpInfo(body); + Future addPet(Pet pet) async { + Response response = await addPetWithHttpInfo(pet); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { + return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; } else { - return; + return null; } } @@ -313,12 +314,12 @@ class PetApi { /// Update an existing pet with HTTP info returned /// /// - Future updatePetWithHttpInfo(Pet body) async { - Object postBody = body; + Future updatePetWithHttpInfo(Pet pet) async { + Object postBody = pet; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(pet == null) { + throw ApiException(400, "Missing required param: pet"); } // create path and map variables @@ -356,16 +357,17 @@ class PetApi { /// Update an existing pet /// - ///Pet body (required): + ///Pet pet (required): /// Pet object that needs to be added to the store /// - Future updatePet(Pet body) async { - Response response = await updatePetWithHttpInfo(body); + Future updatePet(Pet pet) async { + Response response = await updatePetWithHttpInfo(pet); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { + return apiClient.deserialize(_decodeBodyBytes(response), 'Pet') as Pet; } else { - return; + return null; } } diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart index 3c10ba5454c..51405be6e24 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart @@ -185,12 +185,12 @@ class StoreApi { /// Place an order for a pet with HTTP info returned /// /// - Future placeOrderWithHttpInfo(Order body) async { - Object postBody = body; + Future placeOrderWithHttpInfo(Order order) async { + Object postBody = order; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(order == null) { + throw ApiException(400, "Missing required param: order"); } // create path and map variables @@ -201,7 +201,7 @@ class StoreApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; @@ -228,11 +228,11 @@ class StoreApi { /// Place an order for a pet /// - ///Order body (required): + ///Order order (required): /// order placed for purchasing the pet /// - Future placeOrder(Order body) async { - Response response = await placeOrderWithHttpInfo(body); + Future placeOrder(Order order) async { + Response response = await placeOrderWithHttpInfo(order); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart index ea069b58ea8..b15b7d41c95 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api/user_api.dart @@ -10,12 +10,12 @@ class UserApi { /// Create user with HTTP info returned /// /// This can only be done by the logged in user. - Future createUserWithHttpInfo(User body) async { - Object postBody = body; + Future createUserWithHttpInfo(User user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(user == null) { + throw 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 nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -53,11 +53,11 @@ class UserApi { /// Create user /// - ///User body (required): + ///User user (required): /// Created user object /// This can only be done by the logged in user. - Future createUser(User body) async { - Response response = await createUserWithHttpInfo(body); + Future createUser(User user) async { + Response response = await createUserWithHttpInfo(user); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { @@ -69,12 +69,12 @@ class UserApi { /// Creates list of users with given input array with HTTP info returned /// /// - Future createUsersWithArrayInputWithHttpInfo(List body) async { - Object postBody = body; + Future createUsersWithArrayInputWithHttpInfo(List user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(user == null) { + throw ApiException(400, "Missing required param: user"); } // create path and map variables @@ -85,10 +85,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -112,11 +112,11 @@ class UserApi { /// Creates list of users with given input array /// - ///List<User> body (required): + ///List<User> user (required): /// List of user object /// - Future createUsersWithArrayInput(List body) async { - Response response = await createUsersWithArrayInputWithHttpInfo(body); + Future createUsersWithArrayInput(List user) async { + Response response = await createUsersWithArrayInputWithHttpInfo(user); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { @@ -128,12 +128,12 @@ class UserApi { /// Creates list of users with given input array with HTTP info returned /// /// - Future createUsersWithListInputWithHttpInfo(List body) async { - Object postBody = body; + Future createUsersWithListInputWithHttpInfo(List user) async { + Object postBody = user; // verify required params are set - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(user == null) { + throw ApiException(400, "Missing required param: user"); } // create path and map variables @@ -144,10 +144,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -171,11 +171,11 @@ class UserApi { /// Creates list of users with given input array /// - ///List<User> body (required): + ///List<User> user (required): /// List of user object /// - Future createUsersWithListInput(List body) async { - Response response = await createUsersWithListInputWithHttpInfo(body); + Future createUsersWithListInput(List user) async { + Response response = await createUsersWithListInputWithHttpInfo(user); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { @@ -206,7 +206,7 @@ class UserApi { List contentTypes = []; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -389,7 +389,7 @@ class UserApi { List contentTypes = []; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -427,15 +427,15 @@ class UserApi { /// Updated user with HTTP info returned /// /// This can only be done by the logged in user. - Future updateUserWithHttpInfo(String username, User body) async { - Object postBody = body; + Future updateUserWithHttpInfo(String username, User user) async { + Object postBody = user; // verify required params are set if(username == null) { throw ApiException(400, "Missing required param: username"); } - if(body == null) { - throw ApiException(400, "Missing required param: body"); + if(user == null) { + throw ApiException(400, "Missing required param: user"); } // create path and map variables @@ -446,10 +446,10 @@ class UserApi { Map headerParams = {}; Map formParams = {}; - List contentTypes = []; + List contentTypes = ["application/json"]; String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; - List authNames = []; + List authNames = ["api_key"]; if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; @@ -475,11 +475,11 @@ class UserApi { /// ///String username (required): /// name that need to be deleted - ///User body (required): + ///User user (required): /// Updated user object /// This can only be done by the logged in user. - Future updateUser(String username, User body) async { - Response response = await updateUserWithHttpInfo(username, body); + Future updateUser(String username, User user) async { + Response response = await updateUserWithHttpInfo(username, user); if(response.statusCode >= 400) { throw ApiException(response.statusCode, _decodeBodyBytes(response)); } else if(response.body != null) { diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart index d68c9691879..9d0b6f5df06 100644 --- a/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/api_client.dart @@ -43,6 +43,12 @@ class ApiClient { return ApiResponse.fromJson(value); case 'Category': return Category.fromJson(value); + case 'InlineObject': + return InlineObject.fromJson(value); + case 'InlineObject1': + return InlineObject1.fromJson(value); + case 'OneOfTest': + return OneOfTest.fromJson(value); case 'Order': return Order.fromJson(value); case 'Pet': diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object.dart new file mode 100644 index 00000000000..0b65517c01d --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object.dart @@ -0,0 +1,57 @@ +part of openapi.api; + +class InlineObject { + /// Updated name of the pet + String name; + /// Updated status of the pet + String status; + + InlineObject({ + this.name, + this.status, + }); + + @override + String toString() { + return 'InlineObject[name=$name, status=$status, ]'; + } + + InlineObject.fromJson(Map json) { + if (json == null) return; + name = json['name']; + status = json['status']; + } + + Map toJson() { + Map json = {}; + if (name != null) + json['name'] = name; + if (status != null) + json['status'] = status; + return json; + } + + static List listFromJson(List json) { + return json == null ? List() : json.map((value) => InlineObject.fromJson(value)).toList(); + } + + static Map mapFromJson(Map json) { + final map = Map(); + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic value) => map[key] = InlineObject.fromJson(value)); + } + return map; + } + + // maps a json object with a list of InlineObject-objects as value to a dart map + static Map> mapListFromJson(Map json) { + final map = Map>(); + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic value) { + map[key] = InlineObject.listFromJson(value); + }); + } + return map; + } +} + diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object1.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object1.dart new file mode 100644 index 00000000000..69ed12ece5e --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/inline_object1.dart @@ -0,0 +1,59 @@ +part of openapi.api; + +class InlineObject1 { + /// Additional data to pass to server + String additionalMetadata; + /// file to upload + MultipartFile file; + + InlineObject1({ + this.additionalMetadata, + this.file, + }); + + @override + String toString() { + return 'InlineObject1[additionalMetadata=$additionalMetadata, file=$file, ]'; + } + + InlineObject1.fromJson(Map json) { + if (json == null) return; + additionalMetadata = json['additionalMetadata']; + file = (json['file'] == null) ? + null : + File.fromJson(json['file']); + } + + Map toJson() { + Map json = {}; + if (additionalMetadata != null) + json['additionalMetadata'] = additionalMetadata; + if (file != null) + json['file'] = file; + return json; + } + + static List listFromJson(List json) { + return json == null ? List() : json.map((value) => InlineObject1.fromJson(value)).toList(); + } + + static Map mapFromJson(Map json) { + final map = Map(); + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic value) => map[key] = InlineObject1.fromJson(value)); + } + return map; + } + + // maps a json object with a list of InlineObject1-objects as value to a dart map + static Map> mapListFromJson(Map json) { + final map = Map>(); + if (json != null && json.isNotEmpty) { + json.forEach((String key, dynamic value) { + map[key] = InlineObject1.listFromJson(value); + }); + } + return map; + } +} + diff --git a/samples/client/petstore/dart2/petstore_client_lib/lib/model/one_of_test.dart b/samples/client/petstore/dart2/petstore_client_lib/lib/model/one_of_test.dart new file mode 100644 index 00000000000..ff8c884f4fe --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/lib/model/one_of_test.dart @@ -0,0 +1,27 @@ +part of openapi.api; + +class OneOfTest { + dynamic instance; + + // default constructor + OneOfTest({ + }); + + @override + String toString() { + // TODO + } + + OneOfTest.fromJson(Map json) { + // TODO + // loop through models/primitive types defined in Pet User + // and make sure the payload `json` deserializes to one and only one schema defined in oneOf + } + + Map toJson() { + // TOOD there should be a class member/property called "instance" + // which is dynamic type and it stores the actual instance of the schema defined in oneOf + // if oneOf is [Dog, Cat], then the instance can store either an instance of Dog or Cat + } +} + diff --git a/samples/client/petstore/dart2/petstore_client_lib/test/inline_object1_test.dart b/samples/client/petstore/dart2/petstore_client_lib/test/inline_object1_test.dart new file mode 100644 index 00000000000..aa7e3256f1a --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/test/inline_object1_test.dart @@ -0,0 +1,24 @@ +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for InlineObject1 +void main() { + var instance = new InlineObject1(); + + group('test InlineObject1', () { + // Additional data to pass to server + // String additionalMetadata + test('to test the property `additionalMetadata`', () async { + // TODO + }); + + // file to upload + // MultipartFile file + test('to test the property `file`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/client/petstore/dart2/petstore_client_lib/test/inline_object_test.dart b/samples/client/petstore/dart2/petstore_client_lib/test/inline_object_test.dart new file mode 100644 index 00000000000..084dd1cf449 --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/test/inline_object_test.dart @@ -0,0 +1,24 @@ +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for InlineObject +void main() { + var instance = new InlineObject(); + + group('test InlineObject', () { + // Updated name of the pet + // String name + test('to test the property `name`', () async { + // TODO + }); + + // Updated status of the pet + // String status + test('to test the property `status`', () async { + // TODO + }); + + + }); + +} diff --git a/samples/client/petstore/dart2/petstore_client_lib/test/one_of_test_test.dart b/samples/client/petstore/dart2/petstore_client_lib/test/one_of_test_test.dart new file mode 100644 index 00000000000..c4cc869bb98 --- /dev/null +++ b/samples/client/petstore/dart2/petstore_client_lib/test/one_of_test_test.dart @@ -0,0 +1,79 @@ +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for OneOfTest +void main() { + var instance = new OneOfTest(); + + group('test OneOfTest', () { + // int id + test('to test the property `id`', () async { + // TODO + }); + + // Category category + test('to test the property `category`', () async { + // TODO + }); + + // String name + test('to test the property `name`', () async { + // TODO + }); + + // List photoUrls (default value: const []) + test('to test the property `photoUrls`', () async { + // TODO + }); + + // List tags (default value: const []) + test('to test the property `tags`', () async { + // TODO + }); + + // pet status in the store + // String status + test('to test the property `status`', () async { + // TODO + }); + + // String username + test('to test the property `username`', () async { + // TODO + }); + + // String firstName + test('to test the property `firstName`', () async { + // TODO + }); + + // String lastName + test('to test the property `lastName`', () async { + // TODO + }); + + // String email + test('to test the property `email`', () async { + // TODO + }); + + // String password + test('to test the property `password`', () async { + // TODO + }); + + // String phone + test('to test the property `phone`', () async { + // TODO + }); + + // User Status + // int userStatus + test('to test the property `userStatus`', () async { + // TODO + }); + + + }); + +}