Skip to content

Commit

Permalink
[Dart] Make clients crossplatform (#3608)
Browse files Browse the repository at this point in the history
* Remove browserClient flag and bump http dependency

* Run shell scripts so CIs can verify the change
  • Loading branch information
nickmeinhold authored and wing328 committed Aug 13, 2019
1 parent 5e27f11 commit ba65f67
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 22 deletions.
Expand Up @@ -10,7 +10,7 @@ class QueryParam {
class ApiClient {
String basePath;
var client = {{#browserClient}}Browser{{/browserClient}}Client();
var client = Client();
Map<String, String> _defaultHeaderMap = {};
Map<String, Authentication> _authentications = {};
Expand Down
@@ -1,8 +1,7 @@
library {{pubName}}.api;

import 'dart:async';
import 'dart:convert';{{#browserClient}}
import 'package:http/browser_client.dart';{{/browserClient}}
import 'dart:convert';
import 'package:http/http.dart';

part 'api_client.dart';
Expand Down
Expand Up @@ -4,6 +4,6 @@ description: {{pubDescription}}
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
http: '>=0.12.0 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -1 +1 @@
4.1.0-SNAPSHOT
4.1.1-SNAPSHOT
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, maxCount)
> List<Pet> findPetsByTags(tags)
Finds Pets by tags

Expand All @@ -165,10 +165,9 @@ import 'package:openapi/api.dart';
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, maxCount);
var result = api_instance.findPetsByTags(tags);
print(result);
} catch (e) {
print("Exception when calling PetApi->findPetsByTags: $e\n");
Expand All @@ -180,7 +179,6 @@ 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 @@ -160,7 +160,7 @@ class PetApi {
/// Finds Pets by tags
///
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
Future<List<Pet>> findPetsByTags(List<String> tags, { int maxCount }) async {
Future<List<Pet>> findPetsByTags(List<String> tags) async {
Object postBody;

// verify required params are set
Expand All @@ -176,9 +176,6 @@ class PetApi {
Map<String, String> headerParams = {};
Map<String, String> formParams = {};
queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags));
if(maxCount != null) {
queryParams.addAll(_convertParametersForCollectionFormat("", "maxCount", maxCount));
}

List<String> contentTypes = [];

Expand Down
Expand Up @@ -4,6 +4,6 @@ description: OpenAPI API client
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
http: '>=0.12.0 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -1 +1 @@
4.1.0-SNAPSHOT
4.1.1-SNAPSHOT
Expand Up @@ -4,6 +4,6 @@ description: OpenAPI API client
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
http: '>=0.12.0 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -1 +1 @@
4.1.0-SNAPSHOT
4.1.1-SNAPSHOT
Expand Up @@ -2,7 +2,6 @@ library openapi.api;

import 'dart:async';
import 'dart:convert';
import 'package:http/browser_client.dart';
import 'package:http/http.dart';

part 'api_client.dart';
Expand Down
Expand Up @@ -10,7 +10,7 @@ class QueryParam {
class ApiClient {

String basePath;
var client = BrowserClient();
var client = Client();

Map<String, String> _defaultHeaderMap = {};
Map<String, Authentication> _authentications = {};
Expand Down
Expand Up @@ -4,6 +4,6 @@ description: OpenAPI API client
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
http: '>=0.12.0 <0.13.0'
dev_dependencies:
test: ^1.3.0
@@ -1 +1 @@
4.1.0-SNAPSHOT
4.1.1-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/client/petstore/dart2/openapi/pubspec.yaml
Expand Up @@ -4,6 +4,6 @@ description: OpenAPI API client
environment:
sdk: '>=2.0.0 <3.0.0'
dependencies:
http: '>=0.11.1 <0.13.0'
http: '>=0.12.0 <0.13.0'
dev_dependencies:
test: ^1.3.0

0 comments on commit ba65f67

Please sign in to comment.