Skip to content

Commit 995d706

Browse files
Ivan KamkinDenis-Averin
authored andcommitted
Latest changes for templates and configs
1 parent 8072809 commit 995d706

27 files changed

Lines changed: 359 additions & 110 deletions

codegen/Templates/csharp/README.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
- API version: {{appVersion}}
99
- SDK version: {{packageVersion}}
1010

11+
## SDK and API Version Compatibility:
12+
13+
- SDK Version 25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
14+
- SDK Version 24.12 and Earlier: These versions are compatible with API Version v3.0.
15+
1116
## Demo applications
1217

1318
[Scan QR](https://products.aspose.app/barcode/scanqr) | [Generate Barcode](https://products.aspose.app/barcode/generate) | [Recognize Barcode](https://products.aspose.app/barcode/recognize)

codegen/Templates/csharp/api.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace {{packageName}}.Api
6666
/// </summary>
6767
{{#allParams}}/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}</param>
6868
{{/allParams}}
69+
/// <param name="cancellationToken"></param>
6970
/// <returns>
7071
/// A task that represents the asynchronous operation. {{#returnType}}Task result type is <see cref="{{returnType}}" /> {{/returnType}}
7172
/// </returns>

codegen/Templates/dart/README.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
- API version: {{appVersion}}
66
- SDK version: {{pubVersion}}
77

8+
## SDK and API Version Compatibility:
9+
10+
- SDK Version 4.25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
11+
- SDK Version 1.24.12 and Earlier: These versions are compatible with API Version v3.0.
12+
813
{{pubDescription}}
914

1015
## Demo applications

codegen/Templates/dart/api_client.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class ApiClient {
118118
}
119119

120120
/// Invoke HTTP request
121-
/// We don't use a Map<String, String> for queryParams.
121+
/// We don't use a `Map<String, String>` for queryParams.
122122
/// If collectionFormat is 'multi' a key might appear multiple times.
123123
Future<Http.Response> invokeAPI(String path,
124124
String method,

codegen/Templates/dart/enum.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class {{classname}} {
1111
{{#description}}
1212
/// {{description}}
1313
{{/description}}
14-
// ignore: non_constant_identifier_names
14+
// ignore: non_constant_identifier_names{{^description}}, public_member_api_docs{{/description}}
1515
static final {{classname}} {{.}} = {{classname}}._internal("{{.}}");
1616
{{/values}}
1717
{{/allowableValues}}

codegen/Templates/go/README.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- API version: {{appVersion}}
88
- SDK version: {{packageVersion}}
99

10+
## SDK and API Version Compatibility:
11+
12+
- SDK Version 4.2501.0 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
13+
- SDK Version 1.2412.0 and Earlier: These versions are compatible with API Version v3.0.
14+
1015
## Demo applications
1116

1217
[Scan QR](https://products.aspose.app/barcode/scanqr) | [Generate Barcode](https://products.aspose.app/barcode/generate) | [Recognize Barcode](https://products.aspose.app/barcode/recognize)

codegen/Templates/java/ApiClient.mustache

Lines changed: 61 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package {{invokerPackage}};
22

33
import com.aspose.barcode.cloud.model.ApiErrorResponse;
4-
import com.squareup.okhttp.Call;
5-
import com.squareup.okhttp.Callback;
6-
import com.squareup.okhttp.FormEncodingBuilder;
7-
import com.squareup.okhttp.Headers;
8-
import com.squareup.okhttp.MediaType;
9-
import com.squareup.okhttp.MultipartBuilder;
10-
import com.squareup.okhttp.OkHttpClient;
11-
import com.squareup.okhttp.Request;
12-
import com.squareup.okhttp.RequestBody;
13-
import com.squareup.okhttp.Response;
14-
import com.squareup.okhttp.internal.http.HttpMethod;
15-
import com.squareup.okhttp.logging.HttpLoggingInterceptor;
16-
import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level;
4+
import okhttp3.Call;
5+
import okhttp3.Callback;
6+
import okhttp3.FormBody;
7+
import okhttp3.Headers;
8+
import okhttp3.MediaType;
9+
import okhttp3.MultipartBody;
10+
import okhttp3.OkHttpClient;
11+
import okhttp3.Request;
12+
import okhttp3.RequestBody;
13+
import okhttp3.Response;
14+
import okhttp3.internal.http.HttpMethod;
15+
import okhttp3.logging.HttpLoggingInterceptor;
16+
import okhttp3.logging.HttpLoggingInterceptor.Level;
1717
import okio.BufferedSink;
1818
import okio.Okio;
1919
{{#joda}}
@@ -65,7 +65,7 @@ public class ApiClient {
6565
private boolean debugging = false;
6666
private final Map<String, String> defaultHeaderMap = new HashMap<>();
6767
private String tempFolderPath = null;
68-
private final OkHttpClient httpClient;
68+
private OkHttpClient httpClient;
6969
private final JSON json;
7070
private HttpLoggingInterceptor loggingInterceptor;
7171
private String accessToken;
@@ -98,13 +98,11 @@ public class ApiClient {
9898
}
9999
}
100100

101-
protected ApiClient() {
102-
httpClient = new OkHttpClient();
103-
104-
{{#useGzipFeature}}
105-
// Enable gzip request compression
106-
httpClient.interceptors().add(new GzipRequestInterceptor());
107-
{{/useGzipFeature}}
101+
/** Constructor for ApiClient with readTimeout */
102+
protected ApiClient(long readTimeoutMillis) {
103+
httpClient = new OkHttpClient.Builder()
104+
.readTimeout(readTimeoutMillis, TimeUnit.MILLISECONDS)
105+
.build();
108106
109107
json = new JSON();
110108
@@ -116,6 +114,9 @@ public class ApiClient {
116114
setReadTimeout(60_000);
117115
}
118116

117+
protected ApiClient() {
118+
this(60_000);
119+
}
119120
/**
120121
* Get base path.
121122
*
@@ -230,27 +231,18 @@ public class ApiClient {
230231
* @return Timeout in milliseconds
231232
*/
232233
public int getConnectTimeout() {
233-
return httpClient.getConnectTimeout();
234+
return httpClient.connectTimeoutMillis();
234235
}
235236

236-
/**
237-
* Sets the connect timeout (in milliseconds).
238-
* A value of 0 means no timeout, otherwise values must be between 1 and
239-
* {@link Integer#MAX_VALUE}.
240-
*
241-
* @param connectionTimeout connection timeout in milliseconds
242-
*/
243-
public void setConnectTimeout(int connectionTimeout) {
244-
httpClient.setConnectTimeout(connectionTimeout, TimeUnit.MILLISECONDS);
245-
}
237+
246238

247239
/**
248240
* Get read timeout (in milliseconds).
249241
*
250242
* @return Timeout in milliseconds
251243
*/
252244
public int getReadTimeout() {
253-
return httpClient.getReadTimeout();
245+
return httpClient.readTimeoutMillis();
254246
}
255247

256248
/**
@@ -261,7 +253,7 @@ public class ApiClient {
261253
* @param readTimeout read timeout in milliseconds
262254
*/
263255
public void setReadTimeout(int readTimeout) {
264-
httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS);
256+
httpClient = new OkHttpClient.Builder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build();
265257
}
266258

267259
/**
@@ -270,19 +262,10 @@ public class ApiClient {
270262
* @return Timeout in milliseconds
271263
*/
272264
public int getWriteTimeout() {
273-
return httpClient.getWriteTimeout();
265+
return httpClient.writeTimeoutMillis();
274266
}
275267

276-
/**
277-
* Sets the write timeout (in milliseconds).
278-
* A value of 0 means no timeout, otherwise values must be between 1 and
279-
* {@link Integer#MAX_VALUE}.
280-
*
281-
* @param writeTimeout connection timeout in milliseconds
282-
*/
283-
public void setWriteTimeout(int writeTimeout) {
284-
httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS);
285-
}
268+
286269

287270
/**
288271
* Format the given parameter object into string.
@@ -293,13 +276,15 @@ public class ApiClient {
293276
public String parameterToString(Object param) {
294277
if (param == null) {
295278
return "";
296-
} else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) {
297-
//Serialize to json string and remove the " enclosing characters
279+
} else if (param instanceof Date
280+
|| param instanceof OffsetDateTime
281+
|| param instanceof LocalDate) {
282+
// Serialize to json string and remove the " enclosing characters
298283
String jsonStr = json.serialize(param);
299284
return jsonStr.substring(1, jsonStr.length() - 1);
300285
} else if (param instanceof Collection) {
301286
StringBuilder b = new StringBuilder();
302-
for (Object o : (Collection)param) {
287+
for (Object o : (Collection<Object>) param) {
303288
if (b.length() > 0) {
304289
b.append(",");
305290
}
@@ -371,7 +356,7 @@ public class ApiClient {
371356
delimiter = escapeString("|");
372357
}
373358
374-
StringBuilder sb = new StringBuilder() ;
359+
StringBuilder sb = new StringBuilder();
375360
for (Object item : value) {
376361
sb.append(delimiter);
377362
sb.append(escapeString(parameterToString(item)));
@@ -539,18 +524,18 @@ public class ApiClient {
539524
public RequestBody serialize(Object obj, String contentType) throws ApiException {
540525
if (obj instanceof byte[]) {
541526
// Binary (byte array) body parameter support.
542-
return RequestBody.create(MediaType.parse(contentType), (byte[]) obj);
527+
return RequestBody.create((byte[]) obj,MediaType.parse(contentType));
543528
} else if (obj instanceof File) {
544529
// File body parameter support.
545-
return RequestBody.create(MediaType.parse(contentType), (File) obj);
530+
return RequestBody.create((File) obj, MediaType.parse(contentType));
546531
} else if (isJsonMime(contentType)) {
547532
String content;
548533
if (obj != null) {
549534
content = json.serialize(obj);
550535
} else {
551536
content = null;
552537
}
553-
return RequestBody.create(MediaType.parse(contentType), content);
538+
return RequestBody.create(content, MediaType.parse(contentType));
554539
} else {
555540
throw new ApiException("Content type \"" + contentType + "\" is not supported");
556541
}
@@ -672,24 +657,26 @@ public class ApiClient {
672657
* @param callback ApiCallback
673658
*/
674659
public <T> void executeAsync(Call call, final Type returnType, final ApiCallback<T> callback) {
675-
call.enqueue(new Callback() {
676-
@Override
677-
public void onFailure(Request request, IOException e) {
678-
callback.onFailure(new ApiException(e), 0, null);
679-
}
660+
call.enqueue(
661+
new okhttp3.Callback() {
662+
@Override
663+
public void onFailure(Call call, IOException e) {
664+
callback.onFailure(new ApiException(e), 0, null);
665+
}
680666

681667
@Override
682-
public void onResponse(Response response) {
683-
T result;
684-
try {
685-
result = handleResponse(response, returnType);
686-
} catch (ApiException e) {
687-
callback.onFailure(e, response.code(), response.headers().toMultimap());
688-
return;
689-
}
690-
callback.onSuccess(result, response.code(), response.headers().toMultimap());
691-
}
692-
});
668+
public void onResponse(Call call, Response response) {
669+
T result;
670+
try {
671+
result = handleResponse(response, returnType);
672+
} catch (ApiException e) {
673+
callback.onFailure(e, response.code(), response.headers().toMultimap());
674+
return;
675+
}
676+
callback.onSuccess(
677+
result, response.code(), response.headers().toMultimap());
678+
}
679+
});
693680
}
694681

695682
/**
@@ -708,7 +695,7 @@ public class ApiClient {
708695
if (response.body() != null) {
709696
try {
710697
response.body().close();
711-
} catch (IOException e) {
698+
} catch (Exception e) {
712699
throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
713700
}
714701
}
@@ -788,7 +775,7 @@ public class ApiClient {
788775
reqBody = null;
789776
} else {
790777
// use an empty request body (for POST, PUT and PATCH)
791-
reqBody = RequestBody.create(MediaType.parse(contentType), "");
778+
reqBody = RequestBody.create( "", MediaType.parse(contentType));
792779
}
793780
} else {
794781
reqBody = serialize(body, contentType);
@@ -880,14 +867,14 @@ public class ApiClient {
880867
* @return RequestBody
881868
*/
882869
public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) {
883-
MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM);
870+
MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
884871
for (Entry<String, Object> param : formParams.entrySet()) {
885872
Object paramValue = param.getValue();
886873
if (paramValue instanceof File) {
887874
File file = (File) paramValue;
888875
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
889876
MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
890-
mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file));
877+
mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType));
891878
} else if (paramValue instanceof Collection) {
892879
Collection<Object> collection = (Collection<Object>) paramValue;
893880
for (Object item : collection) {
@@ -896,7 +883,7 @@ public class ApiClient {
896883
"Content-Disposition",
897884
"form-data; name=\"" + param.getKey() + "\"");
898885
mpBuilder.addPart(
899-
partHeaders, RequestBody.create(null, parameterToString(item)));
886+
partHeaders, RequestBody.create(parameterToString(item), null));
900887
}
901888
} else {
902889
Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"");
@@ -929,7 +916,7 @@ public class ApiClient {
929916
public void requestToken() throws ApiException {
930917
try {
931918
RequestBody requestBody =
932-
new FormEncodingBuilder()
919+
new FormBody.Builder()
933920
.addEncoded("grant_type", "client_credentials")
934921
.addEncoded("client_id", clientId)
935922
.addEncoded("client_secret", clientSecret)

codegen/Templates/java/README.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- API version: {{appVersion}}
88
- SDK version: {{artifactVersion}}
99

10+
## SDK and API Version Compatibility:
11+
12+
- SDK Version 25.1 and Later: Starting from SDK version 25.1, all subsequent versions are compatible with API Version v4.0.
13+
- SDK Version 24.12 and Earlier: These versions are compatible with API Version v3.0.
14+
1015
## Demo applications
1116

1217
[Scan QR](https://products.aspose.app/barcode/scanqr) | [Generate Barcode](https://products.aspose.app/barcode/generate) | [Recognize Barcode](https://products.aspose.app/barcode/recognize)

0 commit comments

Comments
 (0)