Skip to content
Draft
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 generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ do
-g java \
--additional-properties=modelPackage=saasus.sdk.${module}.models,apiPackage=saasus.sdk.${module}.api \
-o /local/generated/${module} \
--additional-properties useOneOfDiscriminatorLookup=true
--additional-properties useOneOfDiscriminatorLookup=true,disallowAdditionalPropertiesIfNotPresent=false
done

for module in ${MODULES}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/ApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* <p>ApiException class.</p>
*/
@SuppressWarnings("serial")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package saasus.sdk.apilog;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class Configuration {
public static final String VERSION = "1.0.0";

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package saasus.sdk.apilog;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class Pair {
private String name = "";
private String value = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Collection;
import java.util.Iterator;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/auth/ApiKeyAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Map;
import java.util.List;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/saasus/sdk/apilog/auth/HttpBearerAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Optional;
import java.util.function.Supplier;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class HttpBearerAuth implements Authentication {
private final String scheme;
private Supplier<String> tokenSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public abstract class AbstractOpenApiSchema {

// store the actual instance of the schema/object
Expand Down
100 changes: 88 additions & 12 deletions src/main/java/saasus/sdk/apilog/models/ApiLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/**
* ApiLog
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class ApiLog {
public static final String SERIALIZED_NAME_TRACE_ID = "trace_id";
@SerializedName(SERIALIZED_NAME_TRACE_ID)
Expand Down Expand Up @@ -375,6 +375,50 @@ public void setResponseBody(String responseBody) {
this.responseBody = responseBody;
}

/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;

/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
*
* @param key name of the property
* @param value value of the property
* @return the ApiLog instance itself
*/
public ApiLog putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}

/**
* Return the additional (undeclared) property.
*
* @return a map of objects
*/
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}

/**
* Return the additional (undeclared) property with the specified name.
*
* @param key name of the property
* @return an object
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}


@Override
Expand All @@ -399,12 +443,13 @@ public boolean equals(Object o) {
Objects.equals(this.remoteAddress, apiLog.remoteAddress) &&
Objects.equals(this.referer, apiLog.referer) &&
Objects.equals(this.requestBody, apiLog.requestBody) &&
Objects.equals(this.responseBody, apiLog.responseBody);
Objects.equals(this.responseBody, apiLog.responseBody)&&
Objects.equals(this.additionalProperties, apiLog.additionalProperties);
}

@Override
public int hashCode() {
return Objects.hash(traceId, apiLogId, createdAt, createdDate, ttl, requestMethod, saasId, apiKey, responseStatus, requestUri, remoteAddress, referer, requestBody, responseBody);
return Objects.hash(traceId, apiLogId, createdAt, createdDate, ttl, requestMethod, saasId, apiKey, responseStatus, requestUri, remoteAddress, referer, requestBody, responseBody, additionalProperties);
}

@Override
Expand All @@ -425,6 +470,7 @@ public String toString() {
sb.append(" referer: ").append(toIndentedString(referer)).append("\n");
sb.append(" requestBody: ").append(toIndentedString(requestBody)).append("\n");
sb.append(" responseBody: ").append(toIndentedString(responseBody)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down Expand Up @@ -493,14 +539,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
}
}

Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry<String, JsonElement> entry : entries) {
if (!ApiLog.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApiLog` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}

// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ApiLog.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
Expand Down Expand Up @@ -561,14 +599,52 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
@Override
public void write(JsonWriter out, ApiLog value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// serialize additional properties
if (value.getAdditionalProperties() != null) {
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
if (entry.getValue() instanceof String)
obj.addProperty(entry.getKey(), (String) entry.getValue());
else if (entry.getValue() instanceof Number)
obj.addProperty(entry.getKey(), (Number) entry.getValue());
else if (entry.getValue() instanceof Boolean)
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
else if (entry.getValue() instanceof Character)
obj.addProperty(entry.getKey(), (Character) entry.getValue());
else {
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
}
}
}
elementAdapter.write(out, obj);
}

@Override
public ApiLog read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
ApiLog instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
if (!openapiFields.contains(entry.getKey())) {
if (entry.getValue().isJsonPrimitive()) { // primitive type
if (entry.getValue().getAsJsonPrimitive().isString())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
else if (entry.getValue().getAsJsonPrimitive().isNumber())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
} else if (entry.getValue().isJsonArray()) {
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
} else { // JSON object
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
return instance;
}

}.nullSafe();
Expand Down
100 changes: 88 additions & 12 deletions src/main/java/saasus/sdk/apilog/models/ApiLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/**
* ApiLogs
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T05:09:40.405574501Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-08-16T07:40:38.269057263Z[Etc/UTC]")
public class ApiLogs {
public static final String SERIALIZED_NAME_API_LOGS = "api_logs";
@SerializedName(SERIALIZED_NAME_API_LOGS)
Expand Down Expand Up @@ -110,6 +110,50 @@ public void setCursor(String cursor) {
this.cursor = cursor;
}

/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;

/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
*
* @param key name of the property
* @param value value of the property
* @return the ApiLogs instance itself
*/
public ApiLogs putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}

/**
* Return the additional (undeclared) property.
*
* @return a map of objects
*/
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}

/**
* Return the additional (undeclared) property with the specified name.
*
* @param key name of the property
* @return an object
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}


@Override
Expand All @@ -122,12 +166,13 @@ public boolean equals(Object o) {
}
ApiLogs apiLogs = (ApiLogs) o;
return Objects.equals(this.apiLogs, apiLogs.apiLogs) &&
Objects.equals(this.cursor, apiLogs.cursor);
Objects.equals(this.cursor, apiLogs.cursor)&&
Objects.equals(this.additionalProperties, apiLogs.additionalProperties);
}

@Override
public int hashCode() {
return Objects.hash(apiLogs, cursor);
return Objects.hash(apiLogs, cursor, additionalProperties);
}

@Override
Expand All @@ -136,6 +181,7 @@ public String toString() {
sb.append("class ApiLogs {\n");
sb.append(" apiLogs: ").append(toIndentedString(apiLogs)).append("\n");
sb.append(" cursor: ").append(toIndentedString(cursor)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down Expand Up @@ -179,14 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
}
}

Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry<String, JsonElement> entry : entries) {
if (!ApiLogs.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ApiLogs` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}

// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ApiLogs.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
Expand Down Expand Up @@ -224,14 +262,52 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
@Override
public void write(JsonWriter out, ApiLogs value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// serialize additional properties
if (value.getAdditionalProperties() != null) {
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
if (entry.getValue() instanceof String)
obj.addProperty(entry.getKey(), (String) entry.getValue());
else if (entry.getValue() instanceof Number)
obj.addProperty(entry.getKey(), (Number) entry.getValue());
else if (entry.getValue() instanceof Boolean)
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
else if (entry.getValue() instanceof Character)
obj.addProperty(entry.getKey(), (Character) entry.getValue());
else {
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
}
}
}
elementAdapter.write(out, obj);
}

@Override
public ApiLogs read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
ApiLogs instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
if (!openapiFields.contains(entry.getKey())) {
if (entry.getValue().isJsonPrimitive()) { // primitive type
if (entry.getValue().getAsJsonPrimitive().isString())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
else if (entry.getValue().getAsJsonPrimitive().isNumber())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
} else if (entry.getValue().isJsonArray()) {
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
} else { // JSON object
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
return instance;
}

}.nullSafe();
Expand Down
Loading