Skip to content
Open
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 languages/java/templates/ApiCallback.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! This template was customized to add the core ApiException class as import. }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.19.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiCallback.mustache }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.26.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiCallback.mustache }}
{{>licenseInfo}}

package {{invokerPackage}};
Expand Down
59 changes: 57 additions & 2 deletions languages/java/templates/ApiClient.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! This template was customized to initialize the ApiClient with the CoreConfiguration to easily setup the KeyFlow Authentication and custom endpoints. }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.19.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.26.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache }}

{{>licenseInfo}}

Expand Down Expand Up @@ -557,6 +557,17 @@ public class ApiClient {
return this;
}

/**
* <p>Set LocalDateTimeFormat.</p>
*
* @param dateFormat a {@link java.time.format.DateTimeFormatter} object
* @return a {@link {{invokerPackage}}.ApiClient} object
*/
public ApiClient setLocalDateTimeFormat(DateTimeFormatter dateFormat) {
JSON.setLocalDateTimeFormat(dateFormat);
return this;
}

{{/jsr310}}
/**
* <p>Set LenientOnJson.</p>
Expand Down Expand Up @@ -823,6 +834,46 @@ public class ApiClient {
}
}

/**
* Format the given parameter object as an ASCII-safe JSON string.
*
* @param param Parameter
* @return JSON representation of the parameter
*/
public String parameterToJsonString(Object param) {
if (param == null) {
return "";
}
String json = JSON.serialize(param);
int firstUnsafe = -1;
for (int i = 0; i < json.length(); i++) {
if (json.charAt(i) >= 0x7f) {
firstUnsafe = i;
break;
}
}
if (firstUnsafe == -1) {
return json;
}

StringBuilder escaped = new StringBuilder(json.length());
escaped.append(json, 0, firstUnsafe);
for (int i = firstUnsafe; i < json.length(); i++) {
char c = json.charAt(i);
if (c >= 0x7f) {
escaped.append("\\u");
escaped.append(Character.forDigit((c >> 12) & 0xf, 16));
escaped.append(Character.forDigit((c >> 8) & 0xf, 16));
escaped.append(Character.forDigit((c >> 4) & 0xf, 16));
escaped.append(Character.forDigit(c & 0xf, 16));
} else {
escaped.append(c);
}
}

return escaped.toString();
}

/**
* Formats the specified query parameter to a list containing a single {@code Pair} object.
*
Expand Down Expand Up @@ -1845,7 +1896,11 @@ public class ApiClient {
}
break;
case "header":
headerParams.put(param.getName(), parameterToString(value));
if (param.getContent() != null && param.getContent().containsKey("application/json")) {
headerParams.put(param.getName(), parameterToJsonString(value));
} else {
headerParams.put(param.getName(), parameterToString(value));
}
break;
case "cookie":
cookieParams.put(param.getName(), parameterToString(value));
Expand Down
17 changes: 11 additions & 6 deletions languages/java/templates/api.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! This template was customized to initialize the DefaultApi with the CoreConfiguration to easily setup the KeyFlow Authentication and custom endpoints. }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.19.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.26.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache }}

{{>licenseInfo}}

Expand Down Expand Up @@ -139,7 +139,7 @@ class {{classname}} {
{{#operation}}
{{^vendorExtensions.x-group-parameters}}/**
* Build call for {{operationId}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{#lambda.escapeJavaDoc}}{{.}}{{/lambda.escapeJavaDoc}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param _callback Callback for upload/download progress
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
Expand Down Expand Up @@ -276,7 +276,12 @@ class {{classname}} {
{{#headerParams}}

if ({{paramName}} != null) {
{{#headerIsJsonMimeType}}
localVarHeaderParams.put("{{baseName}}", localVarApiClient.parameterToJsonString({{paramName}}));
{{/headerIsJsonMimeType}}
{{^headerIsJsonMimeType}}
localVarHeaderParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
{{/headerIsJsonMimeType}}
}

{{/headerParams}}
Expand Down Expand Up @@ -333,7 +338,7 @@ class {{classname}} {
/**
* {{summary}}
* {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{#lambda.escapeJavaDoc}}{{.}}{{/lambda.escapeJavaDoc}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
* @return {{.}}{{/returnType}}
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
{{#responses.0}}
Expand Down Expand Up @@ -374,7 +379,7 @@ class {{classname}} {
{{^vendorExtensions.x-group-parameters}}/**
* {{summary}}
* {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{#lambda.escapeJavaDoc}}{{.}}{{/lambda.escapeJavaDoc}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @return ApiResponse&lt;{{returnType}}{{^returnType}}Void{{/returnType}}&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
{{#responses.0}}
Expand Down Expand Up @@ -442,7 +447,7 @@ class {{classname}} {
{{^vendorExtensions.x-group-parameters}}/**
* {{summary}} (asynchronously)
* {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{#lambda.escapeJavaDoc}}{{.}}{{/lambda.escapeJavaDoc}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
Expand Down Expand Up @@ -495,7 +500,7 @@ class {{classname}} {
{{#optionalParams}}
/**
* Set {{paramName}}
* @param {{paramName}} {{description}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}})
* @param {{paramName}} {{description}} (optional{{^isContainer}}{{#defaultValue}}, default to {{#lambda.escapeJavaDoc}}{{.}}{{/lambda.escapeJavaDoc}}{{/defaultValue}}{{/isContainer}})
* @return API{{operationId}}Request
*/
public API{{operationId}}Request {{paramName}}({{>nullable_var_annotations}} {{{dataType}}} {{paramName}}) {
Expand Down
2 changes: 1 addition & 1 deletion languages/java/templates/api_test.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! This template had to be customized because of our changes to the DefaultApi and ApiClient classes }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.19.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api_test.mustache }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.26.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api_test.mustache }}

{{>licenseInfo}}

Expand Down
4 changes: 2 additions & 2 deletions languages/java/templates/build.gradle.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{! This template was customized to allow the services to be a subprojects in one big gradle project. }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.19.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache }}
{{! Original template: https://github.com/OpenAPITools/openapi-generator/blob/v7.26.0/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/build.gradle.mustache }}

ext {
{{#swagger1AnnotationLibrary}}
Expand Down Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
{{#openApiNullable}}
implementation 'org.openapitools:jackson-databind-nullable:0.2.8'
implementation 'org.openapitools:jackson-databind-nullable:0.2.12'
{{/openApiNullable}}
{{#withAWSV4Signature}}
implementation 'software.amazon.awssdk:auth:2.20.157'
Expand Down
1 change: 1 addition & 0 deletions scripts/build/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
2 changes: 1 addition & 1 deletion scripts/generate-sdk/generate-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,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.19.0"
GENERATOR_VERSION="v7.26.0"
;;
*)
echo "SDK language not supported."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.automation.v1betaapi.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -33,7 +34,7 @@
import java.util.UUID;

/** CreateSnapshotsResult */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class CreateSnapshotsResult {
public static final String SERIALIZED_NAME_CREATED_SNAPSHOT_I_DS = "createdSnapshotIDs";

Expand Down Expand Up @@ -178,10 +179,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -286,7 +284,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.automation.v1betaapi.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -33,7 +34,7 @@
import java.util.UUID;

/** GetVolumeIDsResult */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class GetVolumeIDsResult {
public static final String SERIALIZED_NAME_KIND = "kind";

Expand Down Expand Up @@ -175,10 +176,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -283,7 +281,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.automation.v1betaapi.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -32,7 +33,7 @@
import java.util.Objects;

/** SnapshotRetentionPolicyCount */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class SnapshotRetentionPolicyCount {
/** Gets or Sets kind */
@JsonAdapter(KindEnum.Adapter.class)
Expand Down Expand Up @@ -221,10 +222,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -324,7 +322,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import cloud.stackit.sdk.automation.v1betaapi.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
Expand All @@ -32,7 +33,7 @@
import java.util.Objects;

/** SnapshotRetentionPolicyIndefinitely */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class SnapshotRetentionPolicyIndefinitely {
/** Gets or Sets kind */
@JsonAdapter(KindEnum.Adapter.class)
Expand Down Expand Up @@ -194,10 +195,7 @@ public String toString() {
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}

public static HashSet<String> openapiFields;
Expand Down Expand Up @@ -298,7 +296,9 @@ else if (entry.getValue() instanceof Character)
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonNull;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
Expand All @@ -48,15 +49,15 @@
/**
* IPv4 Classless Inter-Domain Routing (CIDR) Object.
*/
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0")
public class DestinationCIDRv4 {
/**
* Gets or Sets type
*/
@JsonAdapter(TypeEnum.Adapter.class)
public enum TypeEnum {
CIDRV4("cidrv4"),

UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");

private String value;
Expand Down Expand Up @@ -233,10 +234,7 @@ public String toString() {
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
return o == null ? "null" : o.toString().replace("\n", "\n ");
}


Expand Down Expand Up @@ -320,7 +318,9 @@ else if (entry.getValue() instanceof Character)
obj.addProperty(entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
if (jsonElement.isJsonNull()) {
obj.add(entry.getKey(), JsonNull.INSTANCE);
} else if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
Expand Down
Loading
Loading