Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ import 'package:{{pubName}}/api.dart';
{{/authMethods}}
{{/hasAuthMethods}}

var api_instance = new {{classname}}();
var api_instance = {{classname}}();
{{#allParams}}
var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class {{classname}} {
{{#allParams}}
{{#required}}
if({{paramName}} == null) {
throw new ApiException(400, "Missing required param: {{paramName}}");
throw ApiException(400, "Missing required param: {{paramName}}");
}
{{/required}}
{{/allParams}}
Expand Down Expand Up @@ -51,7 +51,7 @@ class {{classname}} {

if(contentType.startsWith("multipart/form-data")) {
bool hasFields = false;
MultipartRequest mp = new MultipartRequest(null, null);
MultipartRequest mp = MultipartRequest(null, null);
{{#formParams}}
{{^isFile}}
if ({{paramName}} != null) {
Expand Down Expand Up @@ -89,7 +89,7 @@ class {{classname}} {
authNames);

if(response.statusCode >= 400) {
throw new ApiException(response.statusCode, _decodeBodyBytes(response));
throw ApiException(response.statusCode, _decodeBodyBytes(response));
} else if(response.body != null) {
{{#isListContainer}}
{{#returnType}}
Expand All @@ -99,7 +99,7 @@ class {{classname}} {
{{^isListContainer}}
{{#isMapContainer}}
{{#returnType}}
return new {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}'));
return {{{returnType}}}.from(apiClient.deserialize(_decodeBodyBytes(response), '{{{returnType}}}'));
{{/returnType}};
{{/isMapContainer}}
{{^isMapContainer}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import 'package:{{pubName}}/api.dart';
{{/authMethods}}
{{/hasAuthMethods}}

var api_instance = new {{classname}}();
var api_instance = {{classname}}();
{{#allParams}}
var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
var {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:test/test.dart';

/// tests for {{classname}}
void main() {
var instance = new {{classname}}();
var instance = {{classname}}();

group('tests for {{classname}}', () {
{{#operation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class {{classname}} {
{{name}} = {{complexType}}.mapFromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{^isMapContainer}}
{{name}} = new {{complexType}}.fromJson(json['{{baseName}}']);
{{name}} = {{complexType}}.fromJson(json['{{baseName}}']);
{{/isMapContainer}}
{{/isListContainer}}
{{/complexType}}
Expand All @@ -49,7 +49,12 @@ class {{classname}} {
{{name}} = (json['{{baseName}}'] as Map).cast<String, {{items.datatype}}>();
{{/isMapContainer}}
{{^isMapContainer}}
{{#isDouble}}
{{name}} = json['{{baseName}}'].toDouble();
{{/isDouble}}
{{^isDouble}}
{{name}} = json['{{baseName}}'];
{{/isDouble}}
{{/isMapContainer}}
{{/isListContainer}}
{{/complexType}}
Expand Down Expand Up @@ -81,13 +86,13 @@ class {{classname}} {
}

static List<{{classname}}> listFromJson(List<dynamic> json) {
return json == null ? new List<{{classname}}>() : json.map((value) => new {{classname}}.fromJson(value)).toList();
return json == null ? List<{{classname}}>() : json.map((value) => {{classname}}.fromJson(value)).toList();
}

static Map<String, {{classname}}> mapFromJson(Map<String, dynamic> json) {
var map = new Map<String, {{classname}}>();
var map = Map<String, {{classname}}>();
if (json != null && json.isNotEmpty) {
json.forEach((String key, dynamic value) => map[key] = new {{classname}}.fromJson(value));
json.forEach((String key, dynamic value) => map[key] = {{classname}}.fromJson(value));
}
return map;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:test/test.dart';

// tests for {{classname}}
void main() {
var instance = new Pet();
var instance = {{classname}}();

group('test {{classname}}', () {
{{#vars}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.1-SNAPSHOT
4.1.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
language: dart
dart:
# Install a specific stable release
- "1.24.3"
- "2.2.0"
install:
- pub get

Expand Down
16 changes: 12 additions & 4 deletions samples/client/petstore/dart/flutter_petstore/openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Please follow the [installation procedure](#installation--usage) and then run th
import 'package:openapi/api.dart';

// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').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 api_instance = PetApi();
var pet = Pet(); // Pet | Pet object that needs to be added to the store

try {
api_instance.addPet(body);
api_instance.addPet(pet);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}
Expand Down Expand Up @@ -89,6 +89,8 @@ Class | Method | HTTP request | Description

- [ApiResponse](docs//ApiResponse.md)
- [Category](docs//Category.md)
- [InlineObject](docs//InlineObject.md)
- [InlineObject1](docs//InlineObject1.md)
- [Order](docs//Order.md)
- [Pet](docs//Pet.md)
- [Tag](docs//Tag.md)
Expand All @@ -104,6 +106,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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)


Original file line number Diff line number Diff line change
@@ -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)


Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ Method | HTTP request | Description


# **addPet**
> addPet(body)
> addPet(pet)

Add a new pet to the store

### Example
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').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 api_instance = PetApi();
var pet = Pet(); // Pet | Pet object that needs to be added to the store

try {
api_instance.addPet(body);
api_instance.addPet(pet);
} catch (e) {
print("Exception when calling PetApi->addPet: $e\n");
}
Expand All @@ -44,7 +44,7 @@ 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

Expand All @@ -70,9 +70,9 @@ Deletes a pet
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

var api_instance = new PetApi();
var api_instance = PetApi();
var petId = 789; // int | Pet id to delete
var apiKey = apiKey_example; // String |

Expand Down Expand Up @@ -116,9 +116,9 @@ Multiple status values can be provided with comma separated strings
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

var api_instance = new PetApi();
var api_instance = PetApi();
var status = []; // List<String> | Status values that need to be considered for filter

try {
Expand Down Expand Up @@ -151,7 +151,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)

# **findPetsByTags**
> List<Pet> findPetsByTags(tags)
> List<Pet> findPetsByTags(tags, maxCount)

Finds Pets by tags

Expand All @@ -161,13 +161,14 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

var api_instance = new PetApi();
var api_instance = PetApi();
var tags = []; // List<String> | Tags to filter by
var maxCount = 56; // int | Maximum number of items to return

try {
var result = api_instance.findPetsByTags(tags);
var result = api_instance.findPetsByTags(tags, maxCount);
print(result);
} catch (e) {
print("Exception when calling PetApi->findPetsByTags: $e\n");
Expand All @@ -179,6 +180,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**List&lt;String&gt;**](String.md)| Tags to filter by | [default to []]
**maxCount** | **int**| Maximum number of items to return | [optional] [default to null]

### Return type

Expand Down Expand Up @@ -206,11 +208,11 @@ Returns a single pet
```dart
import 'package:openapi/api.dart';
// TODO Configure API key authorization: api_key
//openapi.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY';
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKey = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//openapi.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer";
//defaultApiClient.getAuthentication<ApiKeyAuth>('api_key').apiKeyPrefix = 'Bearer';

var api_instance = new PetApi();
var api_instance = PetApi();
var petId = 789; // int | ID of pet to return

try {
Expand Down Expand Up @@ -243,21 +245,21 @@ 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)
> updatePet(pet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmundt Which version of OpenAPI Generator are you using when working on this PR?

If it's the latest version, body should be used instead of pet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done with the current master from git shortly before the PR was created - with a full clean/install. I can attempt to wipe the tree and try it again in case this has accidentally cached some old build artifacts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 let me pull the changes locally to test it out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your change looks good. I'll troubleshoot after merging your fix into master.


Update an existing pet

### Example
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').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 api_instance = PetApi();
var pet = Pet(); // Pet | Pet object that needs to be added to the store

try {
api_instance.updatePet(body);
api_instance.updatePet(pet);
} catch (e) {
print("Exception when calling PetApi->updatePet: $e\n");
}
Expand All @@ -267,7 +269,7 @@ 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

Expand All @@ -293,9 +295,9 @@ Updates a pet in the store with form data
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

var api_instance = new PetApi();
var api_instance = PetApi();
var petId = 789; // int | ID of pet that needs to be updated
var name = name_example; // String | Updated name of the pet
var status = status_example; // String | Updated status of the pet
Expand Down Expand Up @@ -339,9 +341,9 @@ uploads an image
```dart
import 'package:openapi/api.dart';
// TODO Configure OAuth2 access token for authorization: petstore_auth
//openapi.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN';
//defaultApiClient.getAuthentication<OAuth>('petstore_auth').accessToken = 'YOUR_ACCESS_TOKEN';

var api_instance = new PetApi();
var api_instance = PetApi();
var petId = 789; // int | ID of pet to update
var additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server
var file = BINARY_DATA_HERE; // MultipartFile | file to upload
Expand Down
Loading