Skip to content

Commit 76ce99c

Browse files
authored
Merge branch 'master' into improve-json-serialization
2 parents 10993e5 + a20b20c commit 76ce99c

File tree

23 files changed

+141
-66
lines changed

23 files changed

+141
-66
lines changed

src/SDK/Language/Python.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ public function getFiles(): array
125125
'destination' => '{{ spec.title | caseSnake}}/__init__.py',
126126
'template' => 'python/package/__init__.py.twig',
127127
],
128+
[
129+
'scope' => 'default',
130+
'destination' => '{{ spec.title | caseSnake}}/utils/deprecated.py',
131+
'template' => 'python/package/utils/deprecated.py.twig',
132+
],
133+
[
134+
'scope' => 'default',
135+
'destination' => '{{ spec.title | caseSnake}}/utils/__init__.py',
136+
'template' => 'python/package/utils/__init__.py.twig',
137+
],
128138
[
129139
'scope' => 'default',
130140
'destination' => '{{ spec.title | caseSnake}}/client.py',

templates/dart/.github/workflows/format.yml.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
persist-credentials: true
2121
ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }}
2222

23+
- name: Install dependencies
24+
run: dart pub get
25+
2326
- name: Format Dart code
2427
run: dart format .
2528

@@ -29,5 +32,5 @@ jobs:
2932
- name: Add & Commit
3033
uses: EndBug/[email protected]
3134
with:
32-
add: lib
35+
add: '["lib", "test"]'
3336

templates/dart/base/requests/oauth.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
params.forEach((key, value) {
1717
if (value is List) {
1818
for (var item in value) {
19-
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
19+
query.add(
20+
'${Uri.encodeComponent('$key[]')}=${Uri.encodeComponent(item)}');
2021
}
2122
} else if (value != null) {
22-
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
23+
query.add('${Uri.encodeComponent(key)}=${Uri.encodeComponent(value)}');
2324
}
2425
});
2526

templates/dart/lib/query.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Query {
66
final String? attribute;
77
final dynamic values;
88

9-
Query._(this.method, [this.attribute = null, this.values = null]);
9+
Query._(this.method, [this.attribute, this.values]);
1010

1111
Map<String, dynamic> toJson() {
1212
final result = <String, dynamic>{};

templates/dart/lib/src/client.dart.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import 'upload_progress.dart';
77

88
/// [Client] that handles requests to {{spec.title | caseUcfirst}}
99
abstract class Client {
10-
/// The size for cunked uploads in bytes.
11-
static const int CHUNK_SIZE = 5 * 1024 * 1024;
10+
/// The size for chunked uploads in bytes.
11+
static const int chunkSize = 5 * 1024 * 1024;
1212

1313
/// Holds configuration such as project.
1414
late Map<String, String> config;
@@ -42,7 +42,7 @@ abstract class Client {
4242
///
4343
/// {{header.description}}
4444
{% endif %}
45-
Client set{{header.key | caseUcfirst}}(value);
45+
Client set{{header.key | caseUcfirst}}(String value);
4646

4747
{% endfor %}
4848
/// Add headers that should be sent with all API calls.

templates/dart/lib/src/client_browser.dart.twig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ClientBase createClient({
1616
ClientBrowser(endPoint: endPoint, selfSigned: selfSigned);
1717

1818
class ClientBrowser extends ClientBase with ClientMixin {
19-
static const int CHUNK_SIZE = 5*1024*1024;
19+
static const int chunkSize = 5*1024*1024;
2020
String _endPoint;
2121
Map<String, String>? _headers;
2222
@override
@@ -106,7 +106,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
106106
int size = file.bytes!.length;
107107

108108
late Response res;
109-
if (size <= CHUNK_SIZE) {
109+
if (size <= chunkSize) {
110110
params[paramName] = http.MultipartFile.fromBytes(paramName, file.bytes!, filename: file.filename);
111111
return call(
112112
HttpMethod.post,
@@ -122,25 +122,25 @@ class ClientBrowser extends ClientBase with ClientMixin {
122122
try {
123123
res = await call(
124124
HttpMethod.get,
125-
path: path + '/' + params[idParamName],
125+
path: '$path/${params[idParamName]}',
126126
headers: headers,
127127
);
128128
final int chunksUploaded = res.data['chunksUploaded'] as int;
129-
offset = chunksUploaded * CHUNK_SIZE;
129+
offset = chunksUploaded * chunkSize;
130130
} on {{spec.title | caseUcfirst}}Exception catch (_) {}
131131
}
132132

133133
while (offset < size) {
134134
List<int> chunk = [];
135-
final end = min(offset + CHUNK_SIZE, size);
135+
final end = min(offset + chunkSize, size);
136136
chunk = file.bytes!.getRange(offset, end).toList();
137137
params[paramName] =
138138
http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename);
139139
headers['content-range'] =
140-
'bytes $offset-${min<int>((offset + CHUNK_SIZE - 1), size - 1)}/$size';
140+
'bytes $offset-${min<int>((offset + chunkSize - 1), size - 1)}/$size';
141141
res = await call(HttpMethod.post,
142142
path: path, headers: headers, params: params);
143-
offset += CHUNK_SIZE;
143+
offset += chunkSize;
144144
if (offset < size) {
145145
headers['x-{{spec.title | caseLower }}-id'] = res.data['\$id'];
146146
}

templates/dart/lib/src/client_io.dart.twig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ClientBase createClient({
2020
);
2121

2222
class ClientIO extends ClientBase with ClientMixin {
23-
static const int CHUNK_SIZE = 5*1024*1024;
23+
static const int chunkSize = 5*1024*1024;
2424
String _endPoint;
2525
Map<String, String>? _headers;
2626
@override
@@ -120,7 +120,7 @@ class ClientIO extends ClientBase with ClientMixin {
120120
}
121121

122122
late Response res;
123-
if (size <= CHUNK_SIZE) {
123+
if (size <= chunkSize) {
124124
if (file.path != null) {
125125
params[paramName] = await http.MultipartFile.fromPath(
126126
paramName, file.path!,
@@ -143,11 +143,11 @@ class ClientIO extends ClientBase with ClientMixin {
143143
try {
144144
res = await call(
145145
HttpMethod.get,
146-
path: path + '/' + params[idParamName],
146+
path: '$path/${params[idParamName]}',
147147
headers: headers,
148148
);
149149
final int chunksUploaded = res.data['chunksUploaded'] as int;
150-
offset = chunksUploaded * CHUNK_SIZE;
150+
offset = chunksUploaded * chunkSize;
151151
} on {{spec.title | caseUcfirst}}Exception catch (_) {}
152152
}
153153

@@ -160,19 +160,19 @@ class ClientIO extends ClientBase with ClientMixin {
160160
while (offset < size) {
161161
List<int> chunk = [];
162162
if (file.bytes != null) {
163-
final end = min(offset + CHUNK_SIZE, size);
163+
final end = min(offset + chunkSize, size);
164164
chunk = file.bytes!.getRange(offset, end).toList();
165165
} else {
166166
raf!.setPositionSync(offset);
167-
chunk = raf.readSync(CHUNK_SIZE);
167+
chunk = raf.readSync(chunkSize);
168168
}
169169
params[paramName] =
170170
http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename);
171171
headers['content-range'] =
172-
'bytes $offset-${min<int>((offset + CHUNK_SIZE - 1), size - 1)}/$size';
172+
'bytes $offset-${min<int>((offset + chunkSize - 1), size - 1)}/$size';
173173
res = await call(HttpMethod.post,
174174
path: path, headers: headers, params: params);
175-
offset += CHUNK_SIZE;
175+
offset += chunkSize;
176176
if (offset < size) {
177177
headers['x-{{spec.title | caseLower }}-id'] = res.data['\$id'];
178178
}

templates/dart/lib/src/client_mixin.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mixin ClientMixin {
4545
return MapEntry(key, value.toString());
4646
}
4747
if (value is List) {
48-
return MapEntry(key + "[]", value);
48+
return MapEntry("$key[]", value);
4949
}
5050
return MapEntry(key, value);
5151
});

templates/dart/lib/src/models/model.dart.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class {{ definition.name | caseUcfirst | overrideIdentifier }} implements Model
5959
);
6060
}
6161

62+
@override
6263
Map<String, dynamic> toMap() {
6364
return {
6465
{% for property in definition.properties %}

templates/dotnet/Package/Extensions/Extensions.cs.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Linq;
45
using System.Text.Json;
56

67
namespace {{ spec.title | caseUcfirst }}.Extensions

0 commit comments

Comments
 (0)