diff --git a/scripts/generate-sdk/generate-sdk.sh b/scripts/generate-sdk/generate-sdk.sh index aac1e5e..e1e7e56 100755 --- a/scripts/generate-sdk/generate-sdk.sh +++ b/scripts/generate-sdk/generate-sdk.sh @@ -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." diff --git a/scripts/generate-sdk/languages/java.sh b/scripts/generate-sdk/languages/java.sh index fa6da55..2e98ed1 100644 --- a/scripts/generate-sdk/languages/java.sh +++ b/scripts/generate-sdk/languages/java.sh @@ -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 @@ -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 @@ -174,4 +174,4 @@ to_pascal_case() { for (i=2; i<=NF; i++) printf "%s", $i print "" }' -} \ No newline at end of file +} diff --git a/templates/java/README.mustache b/templates/java/README.mustache index 4e16b55..6c14a5f 100644 --- a/templates/java/README.mustache +++ b/templates/java/README.mustache @@ -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 diff --git a/templates/java/build.gradle.mustache b/templates/java/build.gradle.mustache index c59b10f..1bc1bee 100644 --- a/templates/java/build.gradle.mustache +++ b/templates/java/build.gradle.mustache @@ -15,7 +15,6 @@ ext { } dependencies { - implementation project (':core') {{#swagger1AnnotationLibrary}} implementation "io.swagger:swagger-annotations:$swagger_annotations_version" {{/swagger1AnnotationLibrary}}