Skip to content

Commit 2e8980c

Browse files
authored
Release 23.9 (#82)
* Go: Add client and version headers * Dart: Generate client with SDK header and version * Dart: client with Configuration Export Configuration from api * Dart: remove 'part' directive and 'part of' header Move everything to src dir Fix linting error by renaming api.dart to aspose_barcode_cloud.dart Make SDK_VERSION public * Node: rename applyToRequest -> applyToRequestAsync * Node: Add defaultHeaders Remove request prefix from local variables * Java: Fix linting Java: Add missing comments final ApiClient * Java: Configuration added * Update Maven plugin versions Remove attach test jar * New Swagger spec * Fix start-release.bash script * Release 23.9 * Java 8 (JDK 1.8) * All SDKs were released
1 parent 6490ad3 commit 2e8980c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+718
-460
lines changed

codegen/Templates/dart/README.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Aspose.BarCode Cloud SDK for Dart
22

3-
[![Dart test](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart-compile.yml/badge.svg?branch=main)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart-compile.yml)
3+
[![Dart test](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart.yml/badge.svg?branch=main)](https://github.com/aspose-barcode-cloud/aspose-barcode-cloud-dart/actions/workflows/dart.yml)
44

55
- API version: {{appVersion}}
66
- SDK version: {{pubVersion}}
@@ -44,7 +44,7 @@ dependencies:
4444
The examples below show how you can generate QR barcode and save it into a local file and then recognize using **{{pubName}}**:
4545

4646
```dart
47-
import 'package:aspose_barcode_cloud/api.dart' as barcode;
47+
import 'package:aspose_barcode_cloud/aspose_barcode_cloud.dart' as barcode;
4848

4949
import 'dart:typed_data';
5050
import 'dart:io';
@@ -65,7 +65,7 @@ Future<void> main() async {
6565
Uint8List? generated =
6666
await api.getBarcodeGenerate("QR", "text", textLocation: "None");
6767
// Save generated image to file
68-
await new File(fileName).writeAsBytes(generated!);
68+
await File(fileName).writeAsBytes(generated!);
6969
print("Generated image saved to " + fileName);
7070
7171
// Recognize generated image

codegen/Templates/dart/api.mustache

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
part of {{pubName}}.api;
1+
import 'dart:typed_data' show Uint8List;
22

3-
{{#operations}}
3+
import 'package:http/http.dart' show MultipartFile, MultipartRequest;
4+
5+
import '../../aspose_barcode_cloud.dart';
6+
import '../api_helper.dart';
47

8+
{{#operations}}
59

610
class {{classname}} {
711
{{classname}}(this.apiClient) {}
@@ -30,7 +34,7 @@ class {{classname}} {
3034
{{^required}}
3135
if({{paramName}} != null) {
3236
{{/required}}
33-
queryParams.addAll(_convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
37+
queryParams.addAll(convertParametersForCollectionFormat("{{collectionFormat}}", "{{baseName}}", {{paramName}}));
3438
{{^required}}
3539
}
3640
{{/required}}
@@ -53,7 +57,7 @@ class {{classname}} {
5357
mp.fields['{{baseName}}'] = parameterToString({{paramName}});
5458
}
5559
{{/notFile}}{{#isFile}}
56-
mp = new MultipartRequest('{{httpMethod}}', Uri.parse(requestPath));
60+
mp = MultipartRequest('{{httpMethod}}', Uri.parse(requestPath));
5761
// ignore: unnecessary_null_comparison
5862
if ({{paramName}} != null) {
5963
hasFields = true;
@@ -83,15 +87,15 @@ class {{classname}} {
8387
authNames);
8488

8589
if(response.statusCode >= 400) {
86-
throw new ApiException(response.statusCode, response.body);
90+
throw ApiException(response.statusCode, response.body);
8791
} else {
8892
return
8993
{{#isListContainer}}
9094
{{#returnType}}(apiClient.deserialize(response.body, '{{{returnType}}}') as List).map((item) => item as {{returnBaseType}}).toList();{{/returnType}}
9195
{{/isListContainer}}
9296
{{^isListContainer}}
9397
{{#isMapContainer}}
94-
{{#returnType}}new {{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}')) {{/returnType}};
98+
{{#returnType}}{{{returnType}}}.from(apiClient.deserialize(response.body, '{{{returnType}}}')) {{/returnType}};
9599
{{/isMapContainer}}
96100
{{^isMapContainer}}
97101
{{#isResponseFile}}

codegen/Templates/dart/api_client.mustache

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
1-
part of {{pubName}}.api;
1+
import 'dart:convert' show json;
22

3-
class QueryParam {
4-
String name;
5-
String value;
3+
import 'package:http/http.dart' as Http show Client, MultipartRequest, Response;
64

7-
QueryParam(this.name, this.value);
8-
}
5+
import '../aspose_barcode_cloud.dart';
6+
import 'api_helper.dart';
7+
import 'auth/authentication.dart';
8+
import 'auth/oauth.dart';
9+
10+
const String SDK_VERSION = "{{pubVersion}}";
911

1012
class ApiClient {
1113
12-
String basePath;
13-
final client = new {{#browserClient}}Browser{{/browserClient}}Client();
14+
late final String basePath;
15+
final httpClient = Http.Client();
16+
17+
static const String API_SDK_HEADER = "x-aspose-client";
18+
static const String SDK_NAME = "dart sdk";
19+
static const String API_CLIENT_VERSION_HEADER = "x-aspose-client-version";
20+
21+
Map<String, String> _defaultHeaderMap = {
22+
API_SDK_HEADER: SDK_NAME,
23+
API_CLIENT_VERSION_HEADER: SDK_VERSION,
24+
};
1425

15-
Map<String, String> _defaultHeaderMap = {};
1626
late Authentication _authentication;
1727

18-
final _regList = new RegExp(r'^List<(.*)>$');
19-
final _regMap = new RegExp(r'^Map<String,(.*)>$');
20-
21-
ApiClient(
22-
{String? clientId,
23-
String? clientSecret,
24-
String? accessToken,
25-
tokenUrl = "https://api.aspose.cloud/connect/token",
26-
this.basePath = "https://api.aspose.cloud/v3.0"}) {
27-
_authentication = new OAuth(
28-
clientId: clientId,
29-
clientSecret: clientSecret,
30-
accessToken: accessToken,
31-
tokenUrl: tokenUrl);
28+
final _regList = RegExp(r'^List<(.*)>$');
29+
final _regMap = RegExp(r'^Map<String,(.*)>$');
30+
31+
ApiClient(Configuration config) {
32+
this.basePath = config.basePath;
33+
_authentication = OAuth(
34+
clientId: config.clientId,
35+
clientSecret: config.clientSecret,
36+
accessToken: config.accessToken,
37+
tokenUrl: config.tokenUrl);
3238
}
3339

3440
void addDefaultHeader(String key, String value) {
@@ -50,10 +56,10 @@ class ApiClient {
5056
{{#model}}
5157
case '{{classname}}':
5258
{{#isEnum}}
53-
return new {{classname}}.fromJson(value);
59+
return {{classname}}.fromJson(value);
5460
{{/isEnum}}
5561
{{^isEnum}}
56-
return new {{classname}}.fromJson(value);
62+
return {{classname}}.fromJson(value);
5763
{{/isEnum}}
5864
{{/model}}
5965
{{/models}}
@@ -67,15 +73,15 @@ class ApiClient {
6773
} else if (value is Map &&
6874
(match = _regMap.firstMatch(targetType)) != null) {
6975
final newTargetType = match![1];
70-
return new Map.fromIterables(value.keys,
76+
return Map.fromIterables(value.keys,
7177
value.values.map((v) => _deserialize(v, newTargetType!)));
7278
}
7379
}
7480
}
7581
} on Exception catch (e, stack) {
76-
throw new ApiException.withInner(0, 'Exception during deserialization.', e, stack);
82+
throw ApiException.withInner(0, 'Exception during deserialization.', e, stack);
7783
}
78-
throw new ApiException(0, 'Could not find a suitable class for deserialization');
84+
throw ApiException(0, 'Could not find a suitable class for deserialization');
7985
}
8086

8187
dynamic deserialize(String jsonVal, String targetType) {
@@ -102,7 +108,7 @@ class ApiClient {
102108

103109
// We don't use a Map<String, String> for queryParams.
104110
// If collectionFormat is 'multi' a key might appear multiple times.
105-
Future<Response> invokeAPI(String path,
111+
Future<Http.Response> invokeAPI(String path,
106112
String method,
107113
List<QueryParam> queryParams,
108114
Object? body,
@@ -123,27 +129,27 @@ class ApiClient {
123129
headerParams.addAll(_defaultHeaderMap);
124130
headerParams['Content-Type'] = contentType;
125131
126-
if(body is MultipartRequest) {
127-
final request = new MultipartRequest(method, Uri.parse(url));
132+
if(body is Http.MultipartRequest) {
133+
final request = Http.MultipartRequest(method, Uri.parse(url));
128134
request.fields.addAll(body.fields);
129135
request.files.addAll(body.files);
130136
request.headers.addAll(body.headers);
131137
request.headers.addAll(headerParams);
132-
final response = await client.send(request);
133-
return Response.fromStream(response);
138+
final response = await httpClient.send(request);
139+
return Http.Response.fromStream(response);
134140
} else {
135141
final msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body);
136142
switch(method) {
137143
case "POST":
138-
return client.post(Uri.parse(url), headers: headerParams, body: msgBody);
144+
return httpClient.post(Uri.parse(url), headers: headerParams, body: msgBody);
139145
case "PUT":
140-
return client.put(Uri.parse(url), headers: headerParams, body: msgBody);
146+
return httpClient.put(Uri.parse(url), headers: headerParams, body: msgBody);
141147
case "DELETE":
142-
return client.delete(Uri.parse(url), headers: headerParams);
148+
return httpClient.delete(Uri.parse(url), headers: headerParams);
143149
case "PATCH":
144-
return client.patch(Uri.parse(url), headers: headerParams, body: msgBody);
150+
return httpClient.patch(Uri.parse(url), headers: headerParams, body: msgBody);
145151
default:
146-
return client.get(Uri.parse(url), headers: headerParams);
152+
return httpClient.get(Uri.parse(url), headers: headerParams);
147153
}
148154
}
149155
}

codegen/Templates/dart/api_doc.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## Load the API package
55
```dart
6-
import 'package:{{pubName}}/api.dart';
6+
import 'package:{{pubName}}/aspose_barcode_cloud.dart';
77
```
88

99
All URIs are relative to *{{basePath}}*
@@ -24,7 +24,7 @@ Method | HTTP request | Description
2424

2525
### Example
2626
```dart
27-
import 'package:{{pubName}}/api.dart';
27+
import 'package:{{pubName}}/aspose_barcode_cloud.dart';
2828
{{#hasAuthMethods}}
2929
{{#authMethods}}
3030
{{#isBasic}}
@@ -45,9 +45,9 @@ import 'package:{{pubName}}/api.dart';
4545
{{/authMethods}}
4646
{{/hasAuthMethods}}
4747

48-
final api_instance = new {{classname}}();
48+
final api_instance = {{classname}}();
4949
{{#allParams}}
50-
final {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}new {{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
50+
final {{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{dataType}}(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; // {{{dataType}}} | {{{description}}}
5151
{{/allParams}}
5252

5353
try {

codegen/Templates/dart/api_exception.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
part of {{pubName}}.api;
2-
31
class ApiException implements Exception {
42
int code = 0;
53
String? message = null;

codegen/Templates/dart/api_helper.mustache

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
part of {{pubName}}.api;
1+
import '../aspose_barcode_cloud.dart';
22

33
const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
44

5+
class QueryParam {
6+
String name;
7+
String value;
8+
9+
QueryParam(this.name, this.value);
10+
}
11+
512
// port from Java version
6-
Iterable<QueryParam> _convertParametersForCollectionFormat(
13+
Iterable<QueryParam> convertParametersForCollectionFormat(
714
String collectionFormat, String name, dynamic value) {
815
final params = <QueryParam>[];
916
@@ -13,7 +20,7 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
1320
}
1421

1522
if (value is! List) {
16-
params.add(new QueryParam(name, parameterToString(value)));
23+
params.add(QueryParam(name, parameterToString(value)));
1724
return params;
1825
}
1926

@@ -23,12 +30,12 @@ Iterable<QueryParam> _convertParametersForCollectionFormat(
2330
collectionFormat = collectionFormat.isEmpty ? "csv" : collectionFormat; // default: csv
2431

2532
if (collectionFormat == "multi") {
26-
return values.map((v) => new QueryParam(name, parameterToString(v)));
33+
return values.map((v) => QueryParam(name, parameterToString(v)));
2734
}
2835

2936
final String delimiter = _delimiters[collectionFormat] ?? ",";
3037

31-
params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
38+
params.add(QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter)));
3239
return params;
3340
}
3441

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
library {{pubName}}.api;
22

3-
import 'dart:async';
4-
import 'dart:convert';
5-
import 'dart:typed_data';{{#browserClient}}
6-
import 'package:http/browser_client.dart';{{/browserClient}}
7-
import 'package:http/http.dart';
3+
export 'src/configuration.dart' show Configuration;
4+
export 'src/api_client.dart' show ApiClient, SDK_VERSION;
5+
export 'src/api_exception.dart' show ApiException;
86

9-
part 'api_client.dart';
10-
part 'api_helper.dart';
11-
part 'api_exception.dart';
12-
part 'auth/authentication.dart';
13-
part 'auth/oauth.dart';
14-
15-
{{#apiInfo}}{{#apis}}part 'api/{{classFilename}}.dart';
7+
{{#apiInfo}}{{#apis}}export 'src/api/{{classFilename}}.dart' show {{classname}};
168
{{/apis}}{{/apiInfo}}
17-
{{#models}}{{#model}}part 'model/{{classFilename}}.dart';
9+
{{#models}}{{#model}}export 'src/model/{{classFilename}}.dart' show {{classname}};
1810
{{/model}}{{/models}}

codegen/Templates/dart/auth/api_key_auth.mustache

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
part of {{pubName}}.api;
2-
31
class ApiKeyAuth implements Authentication {
42
53
final String location;
@@ -19,7 +17,7 @@ class ApiKeyAuth implements Authentication {
1917
}
2018

2119
if (location == 'query' && value != null) {
22-
queryParams.add(new QueryParam(paramName, value));
20+
queryParams.add(QueryParam(paramName, value));
2321
} else if (location == 'header' && value != null) {
2422
headerParams[paramName] = value;
2523
}

codegen/Templates/dart/auth/authentication.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
part of {{pubName}}.api;
1+
import '../api_helper.dart';
22

33
abstract class Authentication {
44

codegen/Templates/dart/auth/http_basic_auth.mustache

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
part of {{pubName}}.api;
2-
31
class HttpBasicAuth implements Authentication {
42
53
String? username;

0 commit comments

Comments
 (0)