From 9834819d9a24456c30a854c9ae5f40f0b2fc2de3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 3 Oct 2025 07:02:52 +0000 Subject: [PATCH] Update SDK to version v1.98.1 - Generated from OpenAPI spec version v1.98.1 - Auto-generated by GitHub Actions --- README.md | 2 - ...AppApiRestV2SimilaritySchemaANNFunction.md | 4 +- docs/SearchBinaryIds.md | 13 - docs/SearchFunctionIds.md | 13 - src/main/java/ai/reveng/invoker/JSON.java | 2 - ...pApiRestV2SimilaritySchemaANNFunction.java | 58 +++- .../ai/reveng/model/FunctionBatchAnn.java | 2 +- .../java/ai/reveng/model/SearchBinaryIds.java | 288 ------------------ .../ai/reveng/model/SearchFunctionIds.java | 288 ------------------ ...RestV2SimilaritySchemaANNFunctionTest.java | 3 +- .../ai/reveng/model/SearchBinaryIdsTest.java | 33 -- .../reveng/model/SearchFunctionIdsTest.java | 33 -- 12 files changed, 46 insertions(+), 693 deletions(-) delete mode 100644 docs/SearchBinaryIds.md delete mode 100644 docs/SearchFunctionIds.md delete mode 100644 src/main/java/ai/reveng/model/SearchBinaryIds.java delete mode 100644 src/main/java/ai/reveng/model/SearchFunctionIds.java delete mode 100644 src/test/java/ai/reveng/model/SearchBinaryIdsTest.java delete mode 100644 src/test/java/ai/reveng/model/SearchFunctionIdsTest.java diff --git a/README.md b/README.md index d515886..8465eb9 100644 --- a/README.md +++ b/README.md @@ -456,8 +456,6 @@ Class | Method | HTTP request | Description - [SBOMPackage](docs/SBOMPackage.md) - [SandboxOptions](docs/SandboxOptions.md) - [ScrapeThirdPartyConfig](docs/ScrapeThirdPartyConfig.md) - - [SearchBinaryIds](docs/SearchBinaryIds.md) - - [SearchFunctionIds](docs/SearchFunctionIds.md) - [SectionModel](docs/SectionModel.md) - [SecurityChecksResponse](docs/SecurityChecksResponse.md) - [SecurityChecksResult](docs/SecurityChecksResult.md) diff --git a/docs/AppApiRestV2SimilaritySchemaANNFunction.md b/docs/AppApiRestV2SimilaritySchemaANNFunction.md index 7fa8bec..a9404a0 100644 --- a/docs/AppApiRestV2SimilaritySchemaANNFunction.md +++ b/docs/AppApiRestV2SimilaritySchemaANNFunction.md @@ -11,8 +11,8 @@ |**distance** | **BigDecimal** | The distance between two neighbours | [optional] | |**analysisSearchIds** | **List<Integer>** | Perform a search on functions within a list of analyses | [optional] | |**collectionSearchIds** | **List<Integer>** | Search only within these collections | [optional] | -|**searchBinaryIds** | [**SearchBinaryIds**](SearchBinaryIds.md) | | [optional] | -|**searchFunctionIds** | [**SearchFunctionIds**](SearchFunctionIds.md) | | [optional] | +|**searchBinaryIds** | **List<Integer>** | | [optional] | +|**searchFunctionIds** | **List<Integer>** | | [optional] | |**debugOnly** | **Boolean** | Searches for only functions which are debug | [optional] | diff --git a/docs/SearchBinaryIds.md b/docs/SearchBinaryIds.md deleted file mode 100644 index 145fd7f..0000000 --- a/docs/SearchBinaryIds.md +++ /dev/null @@ -1,13 +0,0 @@ - - -# SearchBinaryIds - -Optionally perform the search on matching functions from binaries in this list - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| - - - diff --git a/docs/SearchFunctionIds.md b/docs/SearchFunctionIds.md deleted file mode 100644 index 730b258..0000000 --- a/docs/SearchFunctionIds.md +++ /dev/null @@ -1,13 +0,0 @@ - - -# SearchFunctionIds - -Optionally perform the search on matching functions within this list of functions - -## Properties - -| Name | Type | Description | Notes | -|------------ | ------------- | ------------- | -------------| - - - diff --git a/src/main/java/ai/reveng/invoker/JSON.java b/src/main/java/ai/reveng/invoker/JSON.java index 74896c0..7547e9c 100644 --- a/src/main/java/ai/reveng/invoker/JSON.java +++ b/src/main/java/ai/reveng/invoker/JSON.java @@ -343,8 +343,6 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SBOMPackage.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SandboxOptions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.ScrapeThirdPartyConfig.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SearchBinaryIds.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SearchFunctionIds.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SectionModel.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityChecksResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ai.reveng.model.SecurityChecksResult.CustomTypeAdapterFactory()); diff --git a/src/main/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunction.java b/src/main/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunction.java index d17ae0e..e2e0d28 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunction.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunction.java @@ -14,8 +14,6 @@ import java.util.Objects; import java.util.Locale; -import ai.reveng.model.SearchBinaryIds; -import ai.reveng.model.SearchFunctionIds; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -26,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -79,12 +78,12 @@ public class AppApiRestV2SimilaritySchemaANNFunction { public static final String SERIALIZED_NAME_SEARCH_BINARY_IDS = "search_binary_ids"; @SerializedName(SERIALIZED_NAME_SEARCH_BINARY_IDS) @javax.annotation.Nullable - private SearchBinaryIds searchBinaryIds; + private List searchBinaryIds; public static final String SERIALIZED_NAME_SEARCH_FUNCTION_IDS = "search_function_ids"; @SerializedName(SERIALIZED_NAME_SEARCH_FUNCTION_IDS) @javax.annotation.Nullable - private SearchFunctionIds searchFunctionIds; + private List searchFunctionIds; public static final String SERIALIZED_NAME_DEBUG_ONLY = "debug_only"; @SerializedName(SERIALIZED_NAME_DEBUG_ONLY) @@ -186,40 +185,56 @@ public void setCollectionSearchIds(@javax.annotation.Nullable List coll } - public AppApiRestV2SimilaritySchemaANNFunction searchBinaryIds(@javax.annotation.Nullable SearchBinaryIds searchBinaryIds) { + public AppApiRestV2SimilaritySchemaANNFunction searchBinaryIds(@javax.annotation.Nullable List searchBinaryIds) { this.searchBinaryIds = searchBinaryIds; return this; } + public AppApiRestV2SimilaritySchemaANNFunction addSearchBinaryIdsItem(Integer searchBinaryIdsItem) { + if (this.searchBinaryIds == null) { + this.searchBinaryIds = new ArrayList<>(); + } + this.searchBinaryIds.add(searchBinaryIdsItem); + return this; + } + /** * Get searchBinaryIds * @return searchBinaryIds */ @javax.annotation.Nullable - public SearchBinaryIds getSearchBinaryIds() { + public List getSearchBinaryIds() { return searchBinaryIds; } - public void setSearchBinaryIds(@javax.annotation.Nullable SearchBinaryIds searchBinaryIds) { + public void setSearchBinaryIds(@javax.annotation.Nullable List searchBinaryIds) { this.searchBinaryIds = searchBinaryIds; } - public AppApiRestV2SimilaritySchemaANNFunction searchFunctionIds(@javax.annotation.Nullable SearchFunctionIds searchFunctionIds) { + public AppApiRestV2SimilaritySchemaANNFunction searchFunctionIds(@javax.annotation.Nullable List searchFunctionIds) { this.searchFunctionIds = searchFunctionIds; return this; } + public AppApiRestV2SimilaritySchemaANNFunction addSearchFunctionIdsItem(Integer searchFunctionIdsItem) { + if (this.searchFunctionIds == null) { + this.searchFunctionIds = new ArrayList<>(); + } + this.searchFunctionIds.add(searchFunctionIdsItem); + return this; + } + /** * Get searchFunctionIds * @return searchFunctionIds */ @javax.annotation.Nullable - public SearchFunctionIds getSearchFunctionIds() { + public List getSearchFunctionIds() { return searchFunctionIds; } - public void setSearchFunctionIds(@javax.annotation.Nullable SearchFunctionIds searchFunctionIds) { + public void setSearchFunctionIds(@javax.annotation.Nullable List searchFunctionIds) { this.searchFunctionIds = searchFunctionIds; } @@ -307,11 +322,22 @@ public boolean equals(Object o) { Objects.equals(this.additionalProperties, appApiRestV2SimilaritySchemaANNFunction.additionalProperties); } + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + @Override public int hashCode() { return Objects.hash(limit, distance, analysisSearchIds, collectionSearchIds, searchBinaryIds, searchFunctionIds, debugOnly, additionalProperties); } + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -372,13 +398,13 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti if (jsonObj.get("collection_search_ids") != null && !jsonObj.get("collection_search_ids").isJsonNull() && !jsonObj.get("collection_search_ids").isJsonArray()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_search_ids` to be an array in the JSON string but got `%s`", jsonObj.get("collection_search_ids").toString())); } - // validate the optional field `search_binary_ids` - if (jsonObj.get("search_binary_ids") != null && !jsonObj.get("search_binary_ids").isJsonNull()) { - SearchBinaryIds.validateJsonElement(jsonObj.get("search_binary_ids")); + // ensure the optional json data is an array if present + if (jsonObj.get("search_binary_ids") != null && !jsonObj.get("search_binary_ids").isJsonNull() && !jsonObj.get("search_binary_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `search_binary_ids` to be an array in the JSON string but got `%s`", jsonObj.get("search_binary_ids").toString())); } - // validate the optional field `search_function_ids` - if (jsonObj.get("search_function_ids") != null && !jsonObj.get("search_function_ids").isJsonNull()) { - SearchFunctionIds.validateJsonElement(jsonObj.get("search_function_ids")); + // ensure the optional json data is an array if present + if (jsonObj.get("search_function_ids") != null && !jsonObj.get("search_function_ids").isJsonNull() && !jsonObj.get("search_function_ids").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `search_function_ids` to be an array in the JSON string but got `%s`", jsonObj.get("search_function_ids").toString())); } } diff --git a/src/main/java/ai/reveng/model/FunctionBatchAnn.java b/src/main/java/ai/reveng/model/FunctionBatchAnn.java index 85847b2..41713f8 100644 --- a/src/main/java/ai/reveng/model/FunctionBatchAnn.java +++ b/src/main/java/ai/reveng/model/FunctionBatchAnn.java @@ -55,7 +55,7 @@ public class FunctionBatchAnn { public static final String SERIALIZED_NAME_SUCCESS = "success"; @SerializedName(SERIALIZED_NAME_SUCCESS) @javax.annotation.Nullable - private Object success = null; + private Object success = true; public static final String SERIALIZED_NAME_SETTINGS = "settings"; @SerializedName(SERIALIZED_NAME_SETTINGS) diff --git a/src/main/java/ai/reveng/model/SearchBinaryIds.java b/src/main/java/ai/reveng/model/SearchBinaryIds.java deleted file mode 100644 index bb84253..0000000 --- a/src/main/java/ai/reveng/model/SearchBinaryIds.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is Similarity Search Engine for executable binaries - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.Objects; -import java.util.Locale; -import java.util.List; - - - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Locale; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.JsonPrimitive; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonArray; -import com.google.gson.JsonParseException; - -import ai.reveng.invoker.JSON; - -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class SearchBinaryIds extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(SearchBinaryIds.class.getName()); - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SearchBinaryIds.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SearchBinaryIds' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - - final Type typeInstanceListInteger = new TypeToken>(){}.getType(); - final TypeAdapter> adapterListInteger = (TypeAdapter>) gson.getDelegateAdapter(this, TypeToken.get(typeInstanceListInteger)); - final TypeAdapter adapterObject = gson.getDelegateAdapter(this, TypeToken.get(Object.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SearchBinaryIds value) throws IOException { - if (value == null || value.getActualInstance() == null) { - elementAdapter.write(out, null); - return; - } - - // check if the actual instance is of the type `List` - if (value.getActualInstance() instanceof List) { - JsonPrimitive primitive = adapterListInteger.toJsonTree((List)value.getActualInstance()).getAsJsonPrimitive(); - elementAdapter.write(out, primitive); - return; - } - // check if the actual instance is of the type `Object` - if (value.getActualInstance() instanceof Object) { - JsonPrimitive primitive = adapterObject.toJsonTree((Object)value.getActualInstance()).getAsJsonPrimitive(); - elementAdapter.write(out, primitive); - return; - } - throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: List, Object"); - } - - @Override - public SearchBinaryIds read(JsonReader in) throws IOException { - Object deserialized = null; - JsonElement jsonElement = elementAdapter.read(in); - - ArrayList errorMessages = new ArrayList<>(); - TypeAdapter actualAdapter = elementAdapter; - - // deserialize List - try { - // validate the JSON object to see if any exception is thrown - if (!jsonElement.isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); - } - - JsonArray array = jsonElement.getAsJsonArray(); - // validate array items - for(JsonElement element : array) { - if (!element.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - } - actualAdapter = adapterListInteger; - SearchBinaryIds ret = new SearchBinaryIds(); - ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); - return ret; - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for List failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'List'", e); - } - // deserialize Object - try { - // validate the JSON object to see if any exception is thrown - if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - actualAdapter = adapterObject; - SearchBinaryIds ret = new SearchBinaryIds(); - ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); - return ret; - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'Object'", e); - } - - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for SearchBinaryIds: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); - } - }.nullSafe(); - } - } - - // store a list of schema names defined in anyOf - public static final Map> schemas = new HashMap>(); - - public SearchBinaryIds() { - super("anyOf", Boolean.FALSE); - } - - public SearchBinaryIds(Object o) { - super("anyOf", Boolean.FALSE); - setActualInstance(o); - } - - static { - schemas.put("List", List.class); - schemas.put("Object", Object.class); - } - - @Override - public Map> getSchemas() { - return SearchBinaryIds.schemas; - } - - /** - * Set the instance that matches the anyOf child schema, check - * the instance parameter is valid against the anyOf child schemas: - * List, Object - * - * It could be an instance of the 'anyOf' schemas. - */ - @Override - public void setActualInstance(Object instance) { - if (instance instanceof List) { - List list = (List) instance; - if (!list.isEmpty() && list.get(0) instanceof Integer) { - super.setActualInstance(instance); - return; - } - } - - if (instance instanceof Object) { - super.setActualInstance(instance); - return; - } - - throw new RuntimeException("Invalid instance type. Must be List, Object"); - } - - /** - * Get the actual instance, which can be the following: - * List, Object - * - * @return The actual instance (List, Object) - */ - @SuppressWarnings("unchecked") - @Override - public Object getActualInstance() { - return super.getActualInstance(); - } - - /** - * Get the actual instance of `List`. If the actual instance is not `List`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `List` - * @throws ClassCastException if the instance is not `List` - */ - public List getListInteger() throws ClassCastException { - return (List)super.getActualInstance(); - } - - /** - * Get the actual instance of `Object`. If the actual instance is not `Object`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Object` - * @throws ClassCastException if the instance is not `Object` - */ - public Object getObject() throws ClassCastException { - return (Object)super.getActualInstance(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SearchBinaryIds - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - // validate anyOf schemas one by one - ArrayList errorMessages = new ArrayList<>(); - // validate the json string with List - try { - if (!jsonElement.isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); - } - JsonArray array = jsonElement.getAsJsonArray(); - // validate array items - for(JsonElement element : array) { - if (!element.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - } - return; - } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for List failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with Object - try { - if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - return; - } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); - // continue to the next one - } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for SearchBinaryIds with anyOf schemas: List, Object. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); - } - - /** - * Create an instance of SearchBinaryIds given an JSON string - * - * @param jsonString JSON string - * @return An instance of SearchBinaryIds - * @throws IOException if the JSON string is invalid with respect to SearchBinaryIds - */ - public static SearchBinaryIds fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SearchBinaryIds.class); - } - - /** - * Convert an instance of SearchBinaryIds to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/main/java/ai/reveng/model/SearchFunctionIds.java b/src/main/java/ai/reveng/model/SearchFunctionIds.java deleted file mode 100644 index 86663ea..0000000 --- a/src/main/java/ai/reveng/model/SearchFunctionIds.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is Similarity Search Engine for executable binaries - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.Objects; -import java.util.Locale; -import java.util.List; - - - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Locale; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.JsonPrimitive; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonArray; -import com.google.gson.JsonParseException; - -import ai.reveng.invoker.JSON; - -@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") -public class SearchFunctionIds extends AbstractOpenApiSchema { - private static final Logger log = Logger.getLogger(SearchFunctionIds.class.getName()); - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!SearchFunctionIds.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'SearchFunctionIds' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - - final Type typeInstanceListInteger = new TypeToken>(){}.getType(); - final TypeAdapter> adapterListInteger = (TypeAdapter>) gson.getDelegateAdapter(this, TypeToken.get(typeInstanceListInteger)); - final TypeAdapter adapterObject = gson.getDelegateAdapter(this, TypeToken.get(Object.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, SearchFunctionIds value) throws IOException { - if (value == null || value.getActualInstance() == null) { - elementAdapter.write(out, null); - return; - } - - // check if the actual instance is of the type `List` - if (value.getActualInstance() instanceof List) { - JsonPrimitive primitive = adapterListInteger.toJsonTree((List)value.getActualInstance()).getAsJsonPrimitive(); - elementAdapter.write(out, primitive); - return; - } - // check if the actual instance is of the type `Object` - if (value.getActualInstance() instanceof Object) { - JsonPrimitive primitive = adapterObject.toJsonTree((Object)value.getActualInstance()).getAsJsonPrimitive(); - elementAdapter.write(out, primitive); - return; - } - throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: List, Object"); - } - - @Override - public SearchFunctionIds read(JsonReader in) throws IOException { - Object deserialized = null; - JsonElement jsonElement = elementAdapter.read(in); - - ArrayList errorMessages = new ArrayList<>(); - TypeAdapter actualAdapter = elementAdapter; - - // deserialize List - try { - // validate the JSON object to see if any exception is thrown - if (!jsonElement.isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); - } - - JsonArray array = jsonElement.getAsJsonArray(); - // validate array items - for(JsonElement element : array) { - if (!element.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - } - actualAdapter = adapterListInteger; - SearchFunctionIds ret = new SearchFunctionIds(); - ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); - return ret; - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for List failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'List'", e); - } - // deserialize Object - try { - // validate the JSON object to see if any exception is thrown - if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - actualAdapter = adapterObject; - SearchFunctionIds ret = new SearchFunctionIds(); - ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); - return ret; - } catch (Exception e) { - // deserialization failed, continue - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); - log.log(Level.FINER, "Input data does not match schema 'Object'", e); - } - - throw new IOException(String.format(Locale.ROOT, "Failed deserialization for SearchFunctionIds: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); - } - }.nullSafe(); - } - } - - // store a list of schema names defined in anyOf - public static final Map> schemas = new HashMap>(); - - public SearchFunctionIds() { - super("anyOf", Boolean.FALSE); - } - - public SearchFunctionIds(Object o) { - super("anyOf", Boolean.FALSE); - setActualInstance(o); - } - - static { - schemas.put("List", List.class); - schemas.put("Object", Object.class); - } - - @Override - public Map> getSchemas() { - return SearchFunctionIds.schemas; - } - - /** - * Set the instance that matches the anyOf child schema, check - * the instance parameter is valid against the anyOf child schemas: - * List, Object - * - * It could be an instance of the 'anyOf' schemas. - */ - @Override - public void setActualInstance(Object instance) { - if (instance instanceof List) { - List list = (List) instance; - if (!list.isEmpty() && list.get(0) instanceof Integer) { - super.setActualInstance(instance); - return; - } - } - - if (instance instanceof Object) { - super.setActualInstance(instance); - return; - } - - throw new RuntimeException("Invalid instance type. Must be List, Object"); - } - - /** - * Get the actual instance, which can be the following: - * List, Object - * - * @return The actual instance (List, Object) - */ - @SuppressWarnings("unchecked") - @Override - public Object getActualInstance() { - return super.getActualInstance(); - } - - /** - * Get the actual instance of `List`. If the actual instance is not `List`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `List` - * @throws ClassCastException if the instance is not `List` - */ - public List getListInteger() throws ClassCastException { - return (List)super.getActualInstance(); - } - - /** - * Get the actual instance of `Object`. If the actual instance is not `Object`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `Object` - * @throws ClassCastException if the instance is not `Object` - */ - public Object getObject() throws ClassCastException { - return (Object)super.getActualInstance(); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to SearchFunctionIds - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - // validate anyOf schemas one by one - ArrayList errorMessages = new ArrayList<>(); - // validate the json string with List - try { - if (!jsonElement.isJsonArray()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString())); - } - JsonArray array = jsonElement.getAsJsonArray(); - // validate array items - for(JsonElement element : array) { - if (!element.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected array items to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - } - return; - } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for List failed with `%s`.", e.getMessage())); - // continue to the next one - } - // validate the json string with Object - try { - if (!jsonElement.getAsJsonPrimitive().isNumber()) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected json element to be of type Number in the JSON string but got `%s`", jsonElement.toString())); - } - return; - } catch (Exception e) { - errorMessages.add(String.format(Locale.ROOT, "Deserialization for Object failed with `%s`.", e.getMessage())); - // continue to the next one - } - throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for SearchFunctionIds with anyOf schemas: List, Object. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString())); - } - - /** - * Create an instance of SearchFunctionIds given an JSON string - * - * @param jsonString JSON string - * @return An instance of SearchFunctionIds - * @throws IOException if the JSON string is invalid with respect to SearchFunctionIds - */ - public static SearchFunctionIds fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, SearchFunctionIds.class); - } - - /** - * Convert an instance of SearchFunctionIds to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} - diff --git a/src/test/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunctionTest.java b/src/test/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunctionTest.java index 32f960a..2db4140 100644 --- a/src/test/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunctionTest.java +++ b/src/test/java/ai/reveng/model/AppApiRestV2SimilaritySchemaANNFunctionTest.java @@ -12,8 +12,6 @@ package ai.reveng.model; -import ai.reveng.model.SearchBinaryIds; -import ai.reveng.model.SearchFunctionIds; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; @@ -24,6 +22,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.openapitools.jackson.nullable.JsonNullable; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/src/test/java/ai/reveng/model/SearchBinaryIdsTest.java b/src/test/java/ai/reveng/model/SearchBinaryIdsTest.java deleted file mode 100644 index 06cae8c..0000000 --- a/src/test/java/ai/reveng/model/SearchBinaryIdsTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is Similarity Search Engine for executable binaries - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.List; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * Model tests for SearchBinaryIds - */ -public class SearchBinaryIdsTest { - private final SearchBinaryIds model = new SearchBinaryIds(); - - /** - * Model tests for SearchBinaryIds - */ - @Test - public void testSearchBinaryIds() { - // TODO: test SearchBinaryIds - } - -} diff --git a/src/test/java/ai/reveng/model/SearchFunctionIdsTest.java b/src/test/java/ai/reveng/model/SearchFunctionIdsTest.java deleted file mode 100644 index dabf9ae..0000000 --- a/src/test/java/ai/reveng/model/SearchFunctionIdsTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * RevEng.AI API - * RevEng.AI is Similarity Search Engine for executable binaries - * - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -package ai.reveng.model; - -import java.util.List; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; - -/** - * Model tests for SearchFunctionIds - */ -public class SearchFunctionIdsTest { - private final SearchFunctionIds model = new SearchFunctionIds(); - - /** - * Model tests for SearchFunctionIds - */ - @Test - public void testSearchFunctionIds() { - // TODO: test SearchFunctionIds - } - -}