Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/generate-sdk/generate-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ python)
java)
# When the GENERATOR_VERSION changes, migrate also the templates in templates/java
# Renovate: datasource=github-tags depName=OpenAPITools/openapi-generator versioning=semver
GENERATOR_VERSION="v7.14.0"
GENERATOR_VERSION="v7.15.0"
;;
*)
echo "SDK language not supported."
Expand Down
6 changes: 3 additions & 3 deletions scripts/generate-sdk/languages/java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SERVICES_FOLDER="${SDK_REPO_LOCAL_PATH}/services"

GENERATOR_LOG_LEVEL="error" # Must be a Java log level (error, warn, info...)

INCLUDE_SERVICES=("resourcemanager")
INCLUDE_SERVICES=("resourcemanager" "iaas")

generate_java_sdk() {
# Required parameters
Expand Down Expand Up @@ -119,7 +119,7 @@ generate_java_sdk() {
--git-user-id ${GIT_USER_ID} \
--git-repo-id ${GIT_REPO_ID} \
--global-property apis,models,modelTests=false,modelDocs=false,apiDocs=false,apiTests=false,supportingFiles \
--additional-properties=artifactId="stackit-sdk-${service}",artifactDescription="${SERVICE_DESCRIPTION}",invokerPackage="cloud.stackit.sdk.${service}",modelPackage="cloud.stackit.sdk.${service}.model",apiPackage="cloud.stackit.sdk.${service}.api",serviceName="${service_pascal_case}" >/dev/null \
--additional-properties=artifactId="stackit-sdk-${service}",artifactDescription="${SERVICE_DESCRIPTION}",invokerPackage="cloud.stackit.sdk.${service}",modelPackage="cloud.stackit.sdk.${service}.model",apiPackage="cloud.stackit.sdk.${service}.api",serviceName="${service_pascal_case},serviceId=${service}" >/dev/null \
--http-user-agent stackit-sdk-java/"${service}" \
--config openapi-generator-config-java.yml

Expand Down Expand Up @@ -174,4 +174,4 @@ to_pascal_case() {
for (i=2; i<=NF; i++) printf "%s", $i
print ""
}'
}
}
68 changes: 1 addition & 67 deletions templates/java/README.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -105,74 +105,8 @@ defaultClient.setClientConfig(clientConfig);
{{/jersey2}}
## Getting Started

Please follow the [installation](#installation) instruction and execute the following Java code:
See the [{{serviceId}} examples]({{scmUrl}}/tree/main/examples/{{serviceId}}/src/main/java/cloud/stackit/sdk/{{serviceId}}/examples).

```java
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
import {{{invokerPackage}}}.*;
import {{{invokerPackage}}}.auth.*;
import {{{modelPackage}}}.*;
import {{{package}}}.{{{classname}}};

public class {{{classname}}}Example {

public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("{{{basePath}}}");
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
// Configure HTTP basic authorization: {{{name}}}
HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}");
{{{name}}}.setUsername("YOUR USERNAME");
{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasicBasic}}{{#isBasicBearer}}
// Configure HTTP bearer authorization: {{{name}}}
HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}");
{{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
// Configure API key authorization: {{{name}}}
ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}");
{{{name}}}.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}}
// Configure OAuth2 access token for authorization: {{{name}}}
OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}");
{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}}{{#isHttpSignature}}
// Configure HTTP signature authorization: {{{name}}}
HttpSignatureAuth {{{name}}} = (HttpSignatureAuth) defaultClient.getAuthentication("{{{name}}}");
// All the HTTP signature parameters below should be customized to your environment.
// Configure the keyId
{{{name}}}.setKeyId("YOUR KEY ID");
// Configure the signature algorithm
{{{name}}}.setSigningAlgorithm(SigningAlgorithm.HS2019);
// Configure the specific cryptographic algorithm
{{{name}}}.setAlgorithm(Algorithm.ECDSA_SHA256);
// Configure the cryptographic algorithm parameters, if applicable
{{{name}}}.setAlgorithmParameterSpec(null);
// Set the cryptographic digest algorithm.
{{{name}}}.setDigestAlgorithm("SHA-256");
// Set the HTTP headers that should be included in the HTTP signature.
{{{name}}}.setHeaders(Arrays.asList("date", "host"));
// Set the private key used to sign the HTTP messages
{{{name}}}.setPrivateKey();{{/isHttpSignature}}
{{/authMethods}}
{{/hasAuthMethods}}

{{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
{{#allParams}}
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}
try {
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
System.out.println(result);{{/returnType}}
} catch (ApiException e) {
System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```

## Recommendation

Expand Down
1 change: 0 additions & 1 deletion templates/java/build.gradle.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ext {
}

dependencies {
implementation project (':core')
{{#swagger1AnnotationLibrary}}
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
{{/swagger1AnnotationLibrary}}
Expand Down
Loading