Skip to content

Commit 4d37d95

Browse files
authored
feat(java-sdk): include core module in service generation (#184)
1 parent ec3ed8b commit 4d37d95

File tree

6 files changed

+2448
-0
lines changed

6 files changed

+2448
-0
lines changed

scripts/generate-sdk/.openapi-generator-ignore-java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ gradle.properties
1919
gradlew.bat
2020
gradlew
2121
gradle/**
22+
23+
# ApiException from core library should be used (avoid multiple ApiException imports in case different services are used at the same time)
24+
**/ApiException.java
25+
26+
# Authentication classes are not required because the KeyFlowAuth is attached as interceptor
27+
**/auth/**
28+
29+
# Service Configuration is not required. It only stores a defaultApiClient
30+
**/Configuration.java

scripts/generate-sdk/generate-sdk.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,16 @@ fi
5454
# Renovate: datasource=github-tags depName=OpenAPITools/openapi-generator versioning=semver
5555
case "${LANGUAGE}" in
5656
go)
57+
# When the GENERATOR_VERSION changes, migrate also the templates in templates/go
5758
GENERATOR_VERSION="v6.6.0" # There are issues with GO SDK generation in version v7
5859
;;
5960
python)
61+
# When the GENERATOR_VERSION changes, migrate also the templates in templates/python
6062
# Renovate: datasource=github-tags depName=OpenAPITools/openapi-generator versioning=semver
6163
GENERATOR_VERSION="v7.14.0"
6264
;;
6365
java)
66+
# When the GENERATOR_VERSION changes, migrate also the templates in templates/java
6467
# Renovate: datasource=github-tags depName=OpenAPITools/openapi-generator versioning=semver
6568
GENERATOR_VERSION="v7.14.0"
6669
;;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{{! This template was customized to add the core ApiException class as import. }}
2+
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.14.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiCallback.mustache }}
3+
{{>licenseInfo}}
4+
5+
package {{invokerPackage}};
6+
7+
import java.io.IOException;
8+
import cloud.stackit.sdk.core.exception.ApiException;
9+
10+
import java.util.Map;
11+
import java.util.List;
12+
13+
/**
14+
* Callback for asynchronous API call.
15+
*
16+
* @param <T> The return type
17+
*/
18+
public interface ApiCallback<T> {
19+
/**
20+
* This is called when the API call fails.
21+
*
22+
* @param e The exception causing the failure
23+
* @param statusCode Status code of the response if available, otherwise it would be 0
24+
* @param responseHeaders Headers of the response if available, otherwise it would be null
25+
*/
26+
void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders);
27+
28+
/**
29+
* This is called when the API call succeeded.
30+
*
31+
* @param result The result deserialized from response
32+
* @param statusCode Status code of the response
33+
* @param responseHeaders Headers of the response
34+
*/
35+
void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders);
36+
37+
/**
38+
* This is called when the API upload processing.
39+
*
40+
* @param bytesWritten bytes Written
41+
* @param contentLength content length of request body
42+
* @param done write end
43+
*/
44+
void onUploadProgress(long bytesWritten, long contentLength, boolean done);
45+
46+
/**
47+
* This is called when the API download processing.
48+
*
49+
* @param bytesRead bytes Read
50+
* @param contentLength content length of the response
51+
* @param done Read end
52+
*/
53+
void onDownloadProgress(long bytesRead, long contentLength, boolean done);
54+
}

0 commit comments

Comments
 (0)