From 6d4cbe3af0464c9bdad7264a50acef77dc2279e2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 Oct 2025 14:33:25 +0000 Subject: [PATCH] Update SDK to version v2.1.0 - Generated from OpenAPI spec version v2.1.0 - Auto-generated by GitHub Actions --- .sdk-version | 2 +- README.md | 4 +- build.gradle | 4 +- build.sbt | 2 +- .../AppApiRestV2FunctionsResponsesFunction.md | 2 +- pom.xml | 2 +- .../java/ai/reveng/invoker/ApiClient.java | 2 +- .../java/ai/reveng/invoker/Configuration.java | 2 +- .../ai/reveng/model/AiUnstripRequest.java | 103 +++++++++++++-- .../ai/reveng/model/AnalysisAccessInfo.java | 103 +++++++++++++-- .../java/ai/reveng/model/AnalysisConfig.java | 103 +++++++++++++-- .../reveng/model/AnalysisCreateRequest.java | 103 +++++++++++++-- .../reveng/model/AnalysisCreateResponse.java | 103 +++++++++++++-- .../reveng/model/AnalysisDetailResponse.java | 103 +++++++++++++-- .../reveng/model/AnalysisFunctionMapping.java | 103 +++++++++++++-- .../AnalysisFunctionMatchingRequest.java | 103 +++++++++++++-- .../ai/reveng/model/AnalysisFunctions.java | 103 +++++++++++++-- .../java/ai/reveng/model/AnalysisRecord.java | 103 +++++++++++++-- .../reveng/model/AnalysisStringsResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/AnalysisTags.java | 103 +++++++++++++-- .../reveng/model/AnalysisUpdateRequest.java | 103 +++++++++++++-- .../model/AnalysisUpdateTagsRequest.java | 103 +++++++++++++-- .../model/AnalysisUpdateTagsResponse.java | 103 +++++++++++++-- .../AppApiRestV2AnalysesResponsesTagItem.java | 103 +++++++++++++-- ...ppApiRestV2FunctionsResponsesFunction.java | 125 +++++++++++++++--- .../AppApiRestV2FunctionsTypesFunction.java | 103 +++++++++++++-- .../AppServicesBinaryAnnSchemaTagItem.java | 103 +++++++++++++-- ...xecutionSchemasDynamicExecutionStatus.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Argument.java | 103 +++++++++++++-- .../ai/reveng/model/AutoUnstripRequest.java | 103 +++++++++++++-- .../ai/reveng/model/AutoUnstripResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/BaseResponse.java | 103 +++++++++++++-- .../BaseResponseAnalysisCreateResponse.java | 103 +++++++++++++-- .../BaseResponseAnalysisDetailResponse.java | 103 +++++++++++++-- .../BaseResponseAnalysisFunctionMapping.java | 103 +++++++++++++-- .../model/BaseResponseAnalysisFunctions.java | 103 +++++++++++++-- .../BaseResponseAnalysisStringsResponse.java | 103 +++++++++++++-- .../model/BaseResponseAnalysisTags.java | 103 +++++++++++++-- ...aseResponseAnalysisUpdateTagsResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseBasic.java | 103 +++++++++++++-- .../BaseResponseBinaryAdditionalResponse.java | 103 +++++++++++++-- .../BaseResponseBinaryAnnListResponse.java | 103 +++++++++++++-- .../BaseResponseBinaryDetailsResponse.java | 103 +++++++++++++-- .../BaseResponseBinaryExternalsResponse.java | 103 +++++++++++++-- .../BaseResponseBinarySearchResponse.java | 103 +++++++++++++-- ...CommentsGenerationForFunctionResponse.java | 103 +++++++++++++-- ...ockCommentsOverviewGenerationResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseBool.java | 103 +++++++++++++-- .../model/BaseResponseBoxPlotConfidence.java | 103 +++++++++++++-- ...esponseCalleesCallerFunctionsResponse.java | 103 +++++++++++++-- .../model/BaseResponseCapabilities.java | 103 +++++++++++++-- ...sponseCheckSecurityChecksTaskResponse.java | 103 +++++++++++++-- .../BaseResponseChildBinariesResponse.java | 103 +++++++++++++-- ...ponseCollectionBinariesUpdateResponse.java | 103 +++++++++++++-- .../model/BaseResponseCollectionResponse.java | 103 +++++++++++++-- .../BaseResponseCollectionSearchResponse.java | 103 +++++++++++++-- ...eResponseCollectionTagsUpdateResponse.java | 103 +++++++++++++-- .../model/BaseResponseCommentResponse.java | 103 +++++++++++++-- .../reveng/model/BaseResponseCommunities.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseCreated.java | 103 +++++++++++++-- .../BaseResponseDecompilationResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseDict.java | 103 +++++++++++++-- .../BaseResponseDynamicExecutionStatus.java | 103 +++++++++++++-- .../model/BaseResponseExternalResponse.java | 103 +++++++++++++-- .../BaseResponseFunctionBlocksResponse.java | 103 +++++++++++++-- ...aseResponseFunctionCapabilityResponse.java | 103 +++++++++++++-- .../model/BaseResponseFunctionDataTypes.java | 103 +++++++++++++-- .../BaseResponseFunctionDataTypesList.java | 103 +++++++++++++-- .../BaseResponseFunctionSearchResponse.java | 103 +++++++++++++-- .../BaseResponseFunctionStringsResponse.java | 103 +++++++++++++-- .../BaseResponseFunctionTaskResponse.java | 103 +++++++++++++-- .../BaseResponseFunctionsDetailResponse.java | 103 +++++++++++++-- ...BaseResponseGenerateFunctionDataTypes.java | 103 +++++++++++++-- .../BaseResponseGenerationStatusList.java | 103 +++++++++++++-- ...ponseGetAiDecompilationRatingResponse.java | 103 +++++++++++++-- .../BaseResponseGetAiDecompilationTask.java | 103 +++++++++++++-- .../BaseResponseGetPublicUserResponse.java | 103 +++++++++++++-- .../model/BaseResponseGetUserResponse.java | 103 +++++++++++++-- .../BaseResponseListCollectionResults.java | 103 +++++++++++++-- .../BaseResponseListCommentResponse.java | 103 +++++++++++++-- .../model/BaseResponseListDieMatch.java | 103 +++++++++++++-- ...ResponseListFunctionBoxPlotConfidence.java | 103 +++++++++++++-- .../BaseResponseListFunctionNameHistory.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseListSBOM.java | 103 +++++++++++++-- ...eResponseListSimilarFunctionsResponse.java | 103 +++++++++++++-- ...esponseListTagOriginBoxPlotConfidence.java | 103 +++++++++++++-- .../BaseResponseListUserActivityResponse.java | 103 +++++++++++++-- .../model/BaseResponseLoginResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseLogs.java | 103 +++++++++++++-- .../model/BaseResponseModelsResponse.java | 103 +++++++++++++-- .../BaseResponseNearestNeighborAnalysis.java | 103 +++++++++++++-- .../BaseResponseNetworkOverviewResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseParams.java | 103 +++++++++++++-- .../model/BaseResponseProcessDumps.java | 103 +++++++++++++-- .../model/BaseResponseProcessRegistry.java | 103 +++++++++++++-- .../reveng/model/BaseResponseProcessTree.java | 103 +++++++++++++-- ...ponseQueuedSecurityChecksTaskResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseRecent.java | 103 +++++++++++++-- .../BaseResponseSecurityChecksResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseStatus.java | 103 +++++++++++++-- .../java/ai/reveng/model/BaseResponseStr.java | 103 +++++++++++++-- .../ai/reveng/model/BaseResponseTTPS.java | 103 +++++++++++++-- .../model/BaseResponseTagSearchResponse.java | 103 +++++++++++++-- .../model/BaseResponseTaskResponse.java | 103 +++++++++++++-- .../model/BaseResponseUploadResponse.java | 103 +++++++++++++-- .../model/BaseResponseVulnerabilities.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Basic.java | 103 +++++++++++++-- .../BinaryAdditionalDetailsDataResponse.java | 103 +++++++++++++-- .../model/BinaryAdditionalResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/BinaryAnnForm.java | 103 +++++++++++++-- .../reveng/model/BinaryAnnListResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/BinaryConfig.java | 103 +++++++++++++-- .../reveng/model/BinaryDetailsResponse.java | 103 +++++++++++++-- .../reveng/model/BinaryExternalsResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BinarySearchResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BinarySearchResult.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Block.java | 103 +++++++++++++-- ...CommentsGenerationForFunctionResponse.java | 103 +++++++++++++-- .../ai/reveng/model/BoxPlotConfidence.java | 103 +++++++++++++-- .../ai/reveng/model/CalleeFunctionInfo.java | 103 +++++++++++++-- .../model/CalleesCallerFunctionsResponse.java | 103 +++++++++++++-- .../ai/reveng/model/CallerFunctionInfo.java | 103 +++++++++++++-- .../java/ai/reveng/model/Capabilities.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Capability.java | 103 +++++++++++++-- .../CheckSecurityChecksTaskResponse.java | 103 +++++++++++++-- .../reveng/model/ChildBinariesResponse.java | 103 +++++++++++++-- .../ai/reveng/model/CodeSignatureModel.java | 103 +++++++++++++-- .../CollectionBinariesUpdateRequest.java | 103 +++++++++++++-- .../CollectionBinariesUpdateResponse.java | 103 +++++++++++++-- .../model/CollectionBinaryResponse.java | 103 +++++++++++++-- .../reveng/model/CollectionCreateRequest.java | 103 +++++++++++++-- .../ai/reveng/model/CollectionListItem.java | 103 +++++++++++++-- .../ai/reveng/model/CollectionResponse.java | 103 +++++++++++++-- .../model/CollectionSearchResponse.java | 103 +++++++++++++-- .../reveng/model/CollectionSearchResult.java | 103 +++++++++++++-- .../model/CollectionTagsUpdateRequest.java | 103 +++++++++++++-- .../model/CollectionTagsUpdateResponse.java | 103 +++++++++++++-- .../reveng/model/CollectionUpdateRequest.java | 103 +++++++++++++-- .../java/ai/reveng/model/CommentBase.java | 103 +++++++++++++-- .../java/ai/reveng/model/CommentResponse.java | 103 +++++++++++++-- .../ai/reveng/model/CommentUpdateRequest.java | 103 +++++++++++++-- .../java/ai/reveng/model/Communities.java | 103 +++++++++++++-- .../model/CommunityMatchPercentages.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Created.java | 103 +++++++++++++-- .../model/DecompilationCommentContext.java | 103 +++++++++++++-- .../reveng/model/DecompilationResponse.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/DieMatch.java | 103 +++++++++++++-- .../java/ai/reveng/model/ELFImportModel.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/ELFModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/ELFRelocation.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/ELFSection.java | 103 +++++++++++++-- .../java/ai/reveng/model/ELFSecurity.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/ELFSegment.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/ELFSymbol.java | 103 +++++++++++++-- .../java/ai/reveng/model/ElfDynamicEntry.java | 103 +++++++++++++-- .../java/ai/reveng/model/EntrypointModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/Enumeration.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/ErrorModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/ExportModel.java | 103 +++++++++++++-- .../reveng/model/ExportedBinaryAnnResult.java | 103 +++++++++++++-- .../ai/reveng/model/ExternalResponse.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/FileHashes.java | 103 +++++++++++++-- .../java/ai/reveng/model/FileMetadata.java | 103 +++++++++++++-- .../FunctionBlockDestinationResponse.java | 103 +++++++++++++-- .../reveng/model/FunctionBlockResponse.java | 103 +++++++++++++-- .../reveng/model/FunctionBlocksResponse.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionBoundary.java | 103 +++++++++++++-- .../model/FunctionBoxPlotConfidence.java | 103 +++++++++++++-- .../model/FunctionCapabilityResponse.java | 103 +++++++++++++-- .../model/FunctionCommentCreateRequest.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionDataTypes.java | 103 +++++++++++++-- .../reveng/model/FunctionDataTypesList.java | 103 +++++++++++++-- .../model/FunctionDataTypesListItem.java | 103 +++++++++++++-- .../reveng/model/FunctionDataTypesParams.java | 103 +++++++++++++-- .../reveng/model/FunctionDataTypesStatus.java | 103 +++++++++++++-- .../java/ai/reveng/model/FunctionHeader.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionInfoInput.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionInfoOutput.java | 103 +++++++++++++-- .../model/FunctionLocalVariableResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/FunctionMapping.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionMappingFull.java | 103 +++++++++++++-- .../model/FunctionMatchingBatchResponse.java | 103 +++++++++++++-- .../reveng/model/FunctionMatchingFilters.java | 103 +++++++++++++-- .../reveng/model/FunctionMatchingRequest.java | 103 +++++++++++++-- .../FunctionMatchingResultWithBestMatch.java | 103 +++++++++++++-- .../model/FunctionNameConfidenceBody.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionNameHistory.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionNameInput.java | 103 +++++++++++++-- .../reveng/model/FunctionParamResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/FunctionRename.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionRenameMap.java | 103 +++++++++++++-- .../reveng/model/FunctionSearchResponse.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionSearchResult.java | 103 +++++++++++++-- .../java/ai/reveng/model/FunctionString.java | 103 +++++++++++++-- .../reveng/model/FunctionStringsResponse.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionTaskResponse.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionTypeInput.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionTypeOutput.java | 103 +++++++++++++-- .../reveng/model/FunctionsDetailResponse.java | 103 +++++++++++++-- .../ai/reveng/model/FunctionsListRename.java | 103 +++++++++++++-- .../model/GenerateFunctionDataTypes.java | 103 +++++++++++++-- .../ai/reveng/model/GenerationStatusList.java | 103 +++++++++++++-- .../GetAiDecompilationRatingResponse.java | 103 +++++++++++++-- .../reveng/model/GetAiDecompilationTask.java | 103 +++++++++++++-- .../reveng/model/GetPublicUserResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/GetUserResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/GlobalVariable.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/IconModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/ImportModel.java | 103 +++++++++++++-- .../reveng/model/InverseFunctionMapItem.java | 103 +++++++++++++-- .../ai/reveng/model/InverseStringMapItem.java | 103 +++++++++++++-- .../java/ai/reveng/model/InverseValue.java | 103 +++++++++++++-- .../reveng/model/ListCollectionResults.java | 103 +++++++++++++-- .../java/ai/reveng/model/LoginRequest.java | 103 +++++++++++++-- .../java/ai/reveng/model/LoginResponse.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Logs.java | 103 +++++++++++++-- .../java/ai/reveng/model/MatchedFunction.java | 103 +++++++++++++-- .../model/MatchedFunctionSuggestion.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/MetaModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/ModelsResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/NameConfidence.java | 103 +++++++++++++-- .../java/ai/reveng/model/NearestNeighbor.java | 103 +++++++++++++-- .../ai/reveng/model/NetworkOverviewDns.java | 103 +++++++++++++-- .../model/NetworkOverviewDnsAnswer.java | 103 +++++++++++++-- .../reveng/model/NetworkOverviewMetadata.java | 103 +++++++++++++-- .../reveng/model/NetworkOverviewResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/PDBDebugModel.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/PEModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/PaginationModel.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Params.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Process.java | 103 +++++++++++++-- .../java/ai/reveng/model/ProcessDump.java | 103 +++++++++++++-- .../ai/reveng/model/ProcessDumpMetadata.java | 103 +++++++++++++-- .../java/ai/reveng/model/ProcessDumps.java | 103 +++++++++++++-- .../ai/reveng/model/ProcessDumpsData.java | 103 +++++++++++++-- .../java/ai/reveng/model/ProcessRegistry.java | 103 +++++++++++++-- .../java/ai/reveng/model/ProcessTree.java | 103 +++++++++++++-- .../QueuedSecurityChecksTaskResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/ReAnalysisForm.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Recent.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Registry.java | 103 +++++++++++++-- .../reveng/model/RelativeBinaryResponse.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/SBOM.java | 103 +++++++++++++-- .../java/ai/reveng/model/SBOMPackage.java | 103 +++++++++++++-- .../java/ai/reveng/model/SandboxOptions.java | 103 +++++++++++++-- .../reveng/model/ScrapeThirdPartyConfig.java | 103 +++++++++++++-- .../java/ai/reveng/model/SectionModel.java | 103 +++++++++++++-- .../reveng/model/SecurityChecksResponse.java | 103 +++++++++++++-- .../ai/reveng/model/SecurityChecksResult.java | 103 +++++++++++++-- .../java/ai/reveng/model/SecurityModel.java | 103 +++++++++++++-- .../model/SimilarFunctionsResponse.java | 103 +++++++++++++-- .../model/SingleCodeCertificateModel.java | 103 +++++++++++++-- .../model/SingleCodeSignatureModel.java | 103 +++++++++++++-- .../ai/reveng/model/SinglePDBEntryModel.java | 103 +++++++++++++-- .../ai/reveng/model/SingleSectionModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/StackVariable.java | 103 +++++++++++++-- .../java/ai/reveng/model/StatusOutput.java | 103 +++++++++++++-- .../java/ai/reveng/model/StringFunctions.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Structure.java | 103 +++++++++++++-- .../java/ai/reveng/model/StructureMember.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Symbols.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/TTPS.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/TTPSAttack.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/TTPSData.java | 103 +++++++++++++-- .../java/ai/reveng/model/TTPSElement.java | 103 +++++++++++++-- .../java/ai/reveng/model/TTPSOccurance.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Tag.java | 103 +++++++++++++-- .../ai/reveng/model/TagConfidenceBody.java | 103 +++++++++++++-- .../model/TagOriginBoxPlotConfidence.java | 103 +++++++++++++-- .../java/ai/reveng/model/TagResponse.java | 103 +++++++++++++-- .../ai/reveng/model/TagSearchResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/TagSearchResult.java | 103 +++++++++++++-- src/main/java/ai/reveng/model/Tags.java | 103 +++++++++++++-- .../java/ai/reveng/model/TaskResponse.java | 103 +++++++++++++-- .../reveng/model/ThreatScoreFunctionBody.java | 103 +++++++++++++-- .../java/ai/reveng/model/TimestampModel.java | 103 +++++++++++++-- .../java/ai/reveng/model/TypeDefinition.java | 103 +++++++++++++-- .../reveng/model/UpdateFunctionDataTypes.java | 103 +++++++++++++-- .../java/ai/reveng/model/UploadResponse.java | 103 +++++++++++++-- .../UpsertAiDecomplationRatingRequest.java | 103 +++++++++++++-- .../ai/reveng/model/UserActivityResponse.java | 103 +++++++++++++-- .../java/ai/reveng/model/Vulnerabilities.java | 103 +++++++++++++-- .../java/ai/reveng/model/Vulnerability.java | 103 +++++++++++++-- ...iRestV2FunctionsResponsesFunctionTest.java | 1 + 284 files changed, 25328 insertions(+), 3040 deletions(-) diff --git a/.sdk-version b/.sdk-version index 8a5b818..1defe53 100644 --- a/.sdk-version +++ b/.sdk-version @@ -1 +1 @@ -v2.0.4 +v2.1.0 diff --git a/README.md b/README.md index fe747f6..a184c5a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Add this dependency to your project's POM: ai.reveng sdk - 2.0.4 + 2.1.0 compile ``` @@ -31,7 +31,7 @@ repositories { } dependencies { - implementation "ai.reveng:sdk:2.0.4" + implementation "ai.reveng:sdk:2.1.0" } ``` diff --git a/build.gradle b/build.gradle index 0959728..fbbecfc 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'ai.reveng' -version = '2.0.4' +version = '2.1.0' @@ -171,7 +171,7 @@ mavenPublishing { publishToMavenCentral(true) signAllPublications() - coordinates("ai.reveng", "sdk", "2.0.4") + coordinates("ai.reveng", "sdk", "2.1.0") pom { name = "sdk" diff --git a/build.sbt b/build.sbt index d096f03..6d60368 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "ai.reveng", name := "sdk", - version := "2.0.4", + version := "2.1.0", scalaVersion := "2.11.12", scalacOptions ++= Seq("-feature"), compile / javacOptions ++= Seq("-Xlint:deprecation"), diff --git a/docs/AppApiRestV2FunctionsResponsesFunction.md b/docs/AppApiRestV2FunctionsResponsesFunction.md index 6d9bbd8..be7aeb0 100644 --- a/docs/AppApiRestV2FunctionsResponsesFunction.md +++ b/docs/AppApiRestV2FunctionsResponsesFunction.md @@ -8,7 +8,7 @@ Function schema used in function strings response. | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**functionId** | **Integer** | | | +|**functionId** | **Integer** | | [optional] | |**functionVaddr** | **Long** | Function virtual address | | diff --git a/pom.xml b/pom.xml index 5815d3e..e59f99a 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ sdk jar sdk - 2.0.4 + 2.1.0 https://github.com/RevEngAI/sdk-java Java SDK for the RevEng.AI API diff --git a/src/main/java/ai/reveng/invoker/ApiClient.java b/src/main/java/ai/reveng/invoker/ApiClient.java index 8a2b67d..6206715 100644 --- a/src/main/java/ai/reveng/invoker/ApiClient.java +++ b/src/main/java/ai/reveng/invoker/ApiClient.java @@ -140,7 +140,7 @@ protected void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/2.0.4/java"); + setUserAgent("OpenAPI-Generator/2.1.0/java"); authentications = new HashMap(); } diff --git a/src/main/java/ai/reveng/invoker/Configuration.java b/src/main/java/ai/reveng/invoker/Configuration.java index cf7dbd9..cfb5acf 100644 --- a/src/main/java/ai/reveng/invoker/Configuration.java +++ b/src/main/java/ai/reveng/invoker/Configuration.java @@ -18,7 +18,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "2.0.4"; + public static final String VERSION = "2.1.0"; private static final AtomicReference defaultApiClient = new AtomicReference<>(); private static volatile Supplier apiClientFactory = ApiClient::new; diff --git a/src/main/java/ai/reveng/model/AiUnstripRequest.java b/src/main/java/ai/reveng/model/AiUnstripRequest.java index 23d865d..619c107 100644 --- a/src/main/java/ai/reveng/model/AiUnstripRequest.java +++ b/src/main/java/ai/reveng/model/AiUnstripRequest.java @@ -77,6 +77,50 @@ public void setApply(@javax.annotation.Nullable Boolean apply) { this.apply = apply; } + /** + * 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 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 AiUnstripRequest instance itself + */ + public AiUnstripRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } AiUnstripRequest aiUnstripRequest = (AiUnstripRequest) o; - return Objects.equals(this.apply, aiUnstripRequest.apply); + return Objects.equals(this.apply, aiUnstripRequest.apply)&& + Objects.equals(this.additionalProperties, aiUnstripRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(apply); + return Objects.hash(apply, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AiUnstripRequest {\n"); sb.append(" apply: ").append(toIndentedString(apply)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -140,14 +186,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AiUnstripRequest is not found in the empty JSON string", AiUnstripRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AiUnstripRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AiUnstripRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -166,6 +204,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AiUnstripRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -173,7 +233,28 @@ public void write(JsonWriter out, AiUnstripRequest value) throws IOException { public AiUnstripRequest 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 + AiUnstripRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisAccessInfo.java b/src/main/java/ai/reveng/model/AnalysisAccessInfo.java index ffeaef5..a28f4d1 100644 --- a/src/main/java/ai/reveng/model/AnalysisAccessInfo.java +++ b/src/main/java/ai/reveng/model/AnalysisAccessInfo.java @@ -101,6 +101,50 @@ public void setUsername(@javax.annotation.Nonnull String username) { this.username = username; } + /** + * 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 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 AnalysisAccessInfo instance itself + */ + public AnalysisAccessInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } AnalysisAccessInfo analysisAccessInfo = (AnalysisAccessInfo) o; return Objects.equals(this.owner, analysisAccessInfo.owner) && - Objects.equals(this.username, analysisAccessInfo.username); + Objects.equals(this.username, analysisAccessInfo.username)&& + Objects.equals(this.additionalProperties, analysisAccessInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(owner, username); + return Objects.hash(owner, username, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class AnalysisAccessInfo {\n"); sb.append(" owner: ").append(toIndentedString(owner)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisAccessInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisAccessInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisAccessInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisAccessInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, AnalysisAccessInfo value) throws IOException { public AnalysisAccessInfo 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 + AnalysisAccessInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisConfig.java b/src/main/java/ai/reveng/model/AnalysisConfig.java index 8f05d83..d89bdf3 100644 --- a/src/main/java/ai/reveng/model/AnalysisConfig.java +++ b/src/main/java/ai/reveng/model/AnalysisConfig.java @@ -223,6 +223,50 @@ public void setSandboxConfig(@javax.annotation.Nullable SandboxOptions sandboxCo this.sandboxConfig = sandboxConfig; } + /** + * 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 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 AnalysisConfig instance itself + */ + public AnalysisConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -240,12 +284,13 @@ public boolean equals(Object o) { Objects.equals(this.generateCapabilities, analysisConfig.generateCapabilities) && Objects.equals(this.noCache, analysisConfig.noCache) && Objects.equals(this.advancedAnalysis, analysisConfig.advancedAnalysis) && - Objects.equals(this.sandboxConfig, analysisConfig.sandboxConfig); + Objects.equals(this.sandboxConfig, analysisConfig.sandboxConfig)&& + Objects.equals(this.additionalProperties, analysisConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(scrapeThirdPartyConfig, generateCves, generateSbom, generateCapabilities, noCache, advancedAnalysis, sandboxConfig); + return Objects.hash(scrapeThirdPartyConfig, generateCves, generateSbom, generateCapabilities, noCache, advancedAnalysis, sandboxConfig, additionalProperties); } @Override @@ -259,6 +304,7 @@ public String toString() { sb.append(" noCache: ").append(toIndentedString(noCache)).append("\n"); sb.append(" advancedAnalysis: ").append(toIndentedString(advancedAnalysis)).append("\n"); sb.append(" sandboxConfig: ").append(toIndentedString(sandboxConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -298,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisConfig is not found in the empty JSON string", AnalysisConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `scrape_third_party_config` if (jsonObj.get("scrape_third_party_config") != null && !jsonObj.get("scrape_third_party_config").isJsonNull()) { @@ -332,6 +370,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisConfig value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -339,7 +399,28 @@ public void write(JsonWriter out, AnalysisConfig value) throws IOException { public AnalysisConfig 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 + AnalysisConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java index a591dd4..378d186 100644 --- a/src/main/java/ai/reveng/model/AnalysisCreateRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisCreateRequest.java @@ -261,6 +261,50 @@ public void setBinaryConfig(@javax.annotation.Nullable BinaryConfig binaryConfig this.binaryConfig = binaryConfig; } + /** + * 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 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 AnalysisCreateRequest instance itself + */ + public AnalysisCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -279,7 +323,8 @@ public boolean equals(Object o) { Objects.equals(this.symbols, analysisCreateRequest.symbols) && Objects.equals(this.debugHash, analysisCreateRequest.debugHash) && Objects.equals(this.analysisConfig, analysisCreateRequest.analysisConfig) && - Objects.equals(this.binaryConfig, analysisCreateRequest.binaryConfig); + Objects.equals(this.binaryConfig, analysisCreateRequest.binaryConfig)&& + Objects.equals(this.additionalProperties, analysisCreateRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -288,7 +333,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(filename, sha256Hash, tags, analysisScope, symbols, debugHash, analysisConfig, binaryConfig); + return Objects.hash(filename, sha256Hash, tags, analysisScope, symbols, debugHash, analysisConfig, binaryConfig, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -310,6 +355,7 @@ public String toString() { sb.append(" debugHash: ").append(toIndentedString(debugHash)).append("\n"); sb.append(" analysisConfig: ").append(toIndentedString(analysisConfig)).append("\n"); sb.append(" binaryConfig: ").append(toIndentedString(binaryConfig)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -350,14 +396,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisCreateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisCreateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -421,6 +459,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisCreateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -428,7 +488,28 @@ public void write(JsonWriter out, AnalysisCreateRequest value) throws IOExceptio public AnalysisCreateRequest 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 + AnalysisCreateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisCreateResponse.java b/src/main/java/ai/reveng/model/AnalysisCreateResponse.java index dd1f2ae..73ab0d6 100644 --- a/src/main/java/ai/reveng/model/AnalysisCreateResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisCreateResponse.java @@ -101,6 +101,50 @@ public void setBinaryId(@javax.annotation.Nonnull Integer binaryId) { this.binaryId = binaryId; } + /** + * 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 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 AnalysisCreateResponse instance itself + */ + public AnalysisCreateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } AnalysisCreateResponse analysisCreateResponse = (AnalysisCreateResponse) o; return Objects.equals(this.analysisId, analysisCreateResponse.analysisId) && - Objects.equals(this.binaryId, analysisCreateResponse.binaryId); + Objects.equals(this.binaryId, analysisCreateResponse.binaryId)&& + Objects.equals(this.additionalProperties, analysisCreateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId); + return Objects.hash(analysisId, binaryId, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class AnalysisCreateResponse {\n"); sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisCreateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisCreateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisCreateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -199,6 +237,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisCreateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -206,7 +266,28 @@ public void write(JsonWriter out, AnalysisCreateResponse value) throws IOExcepti public AnalysisCreateResponse 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 + AnalysisCreateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java index 33bd682..8ca2b2a 100644 --- a/src/main/java/ai/reveng/model/AnalysisDetailResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisDetailResponse.java @@ -401,6 +401,50 @@ public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { this.sha256Hash = sha256Hash; } + /** + * 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 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 AnalysisDetailResponse instance itself + */ + public AnalysisDetailResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -425,7 +469,8 @@ public boolean equals(Object o) { Objects.equals(this.debug, analysisDetailResponse.debug) && Objects.equals(this.modelName, analysisDetailResponse.modelName) && Objects.equals(this.sbom, analysisDetailResponse.sbom) && - Objects.equals(this.sha256Hash, analysisDetailResponse.sha256Hash); + Objects.equals(this.sha256Hash, analysisDetailResponse.sha256Hash)&& + Objects.equals(this.additionalProperties, analysisDetailResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -434,7 +479,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(access, analysisId, analysisScope, architecture, binaryDynamic, binaryFormat, binaryName, binarySize, binaryType, creation, debug, modelName, sbom, sha256Hash); + return Objects.hash(access, analysisId, analysisScope, architecture, binaryDynamic, binaryFormat, binaryName, binarySize, binaryType, creation, debug, modelName, sbom, sha256Hash, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -462,6 +507,7 @@ public String toString() { sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" sbom: ").append(toIndentedString(sbom)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -502,14 +548,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisDetailResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisDetailResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisDetailResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -560,6 +598,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisDetailResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -567,7 +627,28 @@ public void write(JsonWriter out, AnalysisDetailResponse value) throws IOExcepti public AnalysisDetailResponse 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 + AnalysisDetailResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java b/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java index 55bd5a1..c5875bb 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionMapping.java @@ -78,6 +78,50 @@ public void setFunctionMaps(@javax.annotation.Nonnull FunctionMapping functionMa this.functionMaps = functionMaps; } + /** + * 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 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 AnalysisFunctionMapping instance itself + */ + public AnalysisFunctionMapping putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -89,12 +133,13 @@ public boolean equals(Object o) { return false; } AnalysisFunctionMapping analysisFunctionMapping = (AnalysisFunctionMapping) o; - return Objects.equals(this.functionMaps, analysisFunctionMapping.functionMaps); + return Objects.equals(this.functionMaps, analysisFunctionMapping.functionMaps)&& + Objects.equals(this.additionalProperties, analysisFunctionMapping.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionMaps); + return Objects.hash(functionMaps, additionalProperties); } @Override @@ -102,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisFunctionMapping {\n"); sb.append(" functionMaps: ").append(toIndentedString(functionMaps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -142,14 +188,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisFunctionMapping.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisFunctionMapping` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisFunctionMapping.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisFunctionMapping value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, AnalysisFunctionMapping value) throws IOExcept public AnalysisFunctionMapping 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 + AnalysisFunctionMapping instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java b/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java index fac70d4..900d86e 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctionMatchingRequest.java @@ -183,6 +183,50 @@ public void setPageSize(@javax.annotation.Nullable Integer pageSize) { this.pageSize = pageSize; } + /** + * 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 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 AnalysisFunctionMatchingRequest instance itself + */ + public AnalysisFunctionMatchingRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -198,7 +242,8 @@ public boolean equals(Object o) { Objects.equals(this.filters, analysisFunctionMatchingRequest.filters) && Objects.equals(this.resultsPerFunction, analysisFunctionMatchingRequest.resultsPerFunction) && Objects.equals(this.page, analysisFunctionMatchingRequest.page) && - Objects.equals(this.pageSize, analysisFunctionMatchingRequest.pageSize); + Objects.equals(this.pageSize, analysisFunctionMatchingRequest.pageSize)&& + Objects.equals(this.additionalProperties, analysisFunctionMatchingRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -207,7 +252,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(minSimilarity, filters, resultsPerFunction, page, pageSize); + return Objects.hash(minSimilarity, filters, resultsPerFunction, page, pageSize, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -226,6 +271,7 @@ public String toString() { sb.append(" resultsPerFunction: ").append(toIndentedString(resultsPerFunction)).append("\n"); sb.append(" page: ").append(toIndentedString(page)).append("\n"); sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -265,14 +311,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisFunctionMatchingRequest is not found in the empty JSON string", AnalysisFunctionMatchingRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisFunctionMatchingRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisFunctionMatchingRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `filters` if (jsonObj.get("filters") != null && !jsonObj.get("filters").isJsonNull()) { @@ -295,6 +333,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisFunctionMatchingRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -302,7 +362,28 @@ public void write(JsonWriter out, AnalysisFunctionMatchingRequest value) throws public AnalysisFunctionMatchingRequest 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 + AnalysisFunctionMatchingRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisFunctions.java b/src/main/java/ai/reveng/model/AnalysisFunctions.java index c1cdc8a..c0f3281 100644 --- a/src/main/java/ai/reveng/model/AnalysisFunctions.java +++ b/src/main/java/ai/reveng/model/AnalysisFunctions.java @@ -88,6 +88,50 @@ public void setFunctions(@javax.annotation.Nonnull List 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 AnalysisFunctions instance itself + */ + public AnalysisFunctions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } AnalysisFunctions analysisFunctions = (AnalysisFunctions) o; - return Objects.equals(this.functions, analysisFunctions.functions); + return Objects.equals(this.functions, analysisFunctions.functions)&& + Objects.equals(this.additionalProperties, analysisFunctions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions); + return Objects.hash(functions, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisFunctions {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisFunctions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisFunctions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisFunctions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisFunctions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, AnalysisFunctions value) throws IOException { public AnalysisFunctions 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 + AnalysisFunctions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisRecord.java b/src/main/java/ai/reveng/model/AnalysisRecord.java index 29ae260..66901a4 100644 --- a/src/main/java/ai/reveng/model/AnalysisRecord.java +++ b/src/main/java/ai/reveng/model/AnalysisRecord.java @@ -440,6 +440,50 @@ public void setBaseAddress(@javax.annotation.Nonnull Long baseAddress) { this.baseAddress = baseAddress; } + /** + * 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 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 AnalysisRecord instance itself + */ + public AnalysisRecord putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -466,7 +510,8 @@ public boolean equals(Object o) { Objects.equals(this.username, analysisRecord.username) && Objects.equals(this.dynamicExecutionStatus, analysisRecord.dynamicExecutionStatus) && Objects.equals(this.dynamicExecutionTaskId, analysisRecord.dynamicExecutionTaskId) && - Objects.equals(this.baseAddress, analysisRecord.baseAddress); + Objects.equals(this.baseAddress, analysisRecord.baseAddress)&& + Objects.equals(this.additionalProperties, analysisRecord.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -475,7 +520,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(analysisId, analysisScope, binaryId, modelId, modelName, status, creation, isOwner, binaryName, sha256Hash, functionBoundariesHash, binarySize, username, dynamicExecutionStatus, dynamicExecutionTaskId, baseAddress); + return Objects.hash(analysisId, analysisScope, binaryId, modelId, modelName, status, creation, isOwner, binaryName, sha256Hash, functionBoundariesHash, binarySize, username, dynamicExecutionStatus, dynamicExecutionTaskId, baseAddress, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -505,6 +550,7 @@ public String toString() { sb.append(" dynamicExecutionStatus: ").append(toIndentedString(dynamicExecutionStatus)).append("\n"); sb.append(" dynamicExecutionTaskId: ").append(toIndentedString(dynamicExecutionTaskId)).append("\n"); sb.append(" baseAddress: ").append(toIndentedString(baseAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -545,14 +591,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisRecord.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisRecord` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisRecord.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -602,6 +640,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisRecord value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -609,7 +669,28 @@ public void write(JsonWriter out, AnalysisRecord value) throws IOException { public AnalysisRecord 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 + AnalysisRecord instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisStringsResponse.java b/src/main/java/ai/reveng/model/AnalysisStringsResponse.java index 3b2d9c1..7805e50 100644 --- a/src/main/java/ai/reveng/model/AnalysisStringsResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisStringsResponse.java @@ -112,6 +112,50 @@ public void setTotalStrings(@javax.annotation.Nonnull Integer totalStrings) { this.totalStrings = totalStrings; } + /** + * 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 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 AnalysisStringsResponse instance itself + */ + public AnalysisStringsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } AnalysisStringsResponse analysisStringsResponse = (AnalysisStringsResponse) o; return Objects.equals(this.strings, analysisStringsResponse.strings) && - Objects.equals(this.totalStrings, analysisStringsResponse.totalStrings); + Objects.equals(this.totalStrings, analysisStringsResponse.totalStrings)&& + Objects.equals(this.additionalProperties, analysisStringsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings); + return Objects.hash(strings, totalStrings, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class AnalysisStringsResponse {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisStringsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisStringsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisStringsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisStringsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, AnalysisStringsResponse value) throws IOExcept public AnalysisStringsResponse 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 + AnalysisStringsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisTags.java b/src/main/java/ai/reveng/model/AnalysisTags.java index e88003b..796cf87 100644 --- a/src/main/java/ai/reveng/model/AnalysisTags.java +++ b/src/main/java/ai/reveng/model/AnalysisTags.java @@ -120,6 +120,50 @@ public void setSuggestedTags(@javax.annotation.Nonnull List 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 AnalysisTags instance itself + */ + public AnalysisTags putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -132,12 +176,13 @@ public boolean equals(Object o) { } AnalysisTags analysisTags = (AnalysisTags) o; return Objects.equals(this.analysisTags, analysisTags.analysisTags) && - Objects.equals(this.suggestedTags, analysisTags.suggestedTags); + Objects.equals(this.suggestedTags, analysisTags.suggestedTags)&& + Objects.equals(this.additionalProperties, analysisTags.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisTags, suggestedTags); + return Objects.hash(analysisTags, suggestedTags, additionalProperties); } @Override @@ -146,6 +191,7 @@ public String toString() { sb.append("class AnalysisTags {\n"); sb.append(" analysisTags: ").append(toIndentedString(analysisTags)).append("\n"); sb.append(" suggestedTags: ").append(toIndentedString(suggestedTags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -186,14 +232,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisTags.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisTags` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisTags.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -238,6 +276,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisTags value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -245,7 +305,28 @@ public void write(JsonWriter out, AnalysisTags value) throws IOException { public AnalysisTags 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 + AnalysisTags instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java b/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java index c406944..c7bcc18 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateRequest.java @@ -154,6 +154,50 @@ public void setAnalysisScope(@javax.annotation.Nullable AnalysisScopeEnum analys this.analysisScope = analysisScope; } + /** + * 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 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 AnalysisUpdateRequest instance itself + */ + public AnalysisUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -166,7 +210,8 @@ public boolean equals(Object o) { } AnalysisUpdateRequest analysisUpdateRequest = (AnalysisUpdateRequest) o; return Objects.equals(this.binaryName, analysisUpdateRequest.binaryName) && - Objects.equals(this.analysisScope, analysisUpdateRequest.analysisScope); + Objects.equals(this.analysisScope, analysisUpdateRequest.analysisScope)&& + Objects.equals(this.additionalProperties, analysisUpdateRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -175,7 +220,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaryName, analysisScope); + return Objects.hash(binaryName, analysisScope, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -191,6 +236,7 @@ public String toString() { sb.append("class AnalysisUpdateRequest {\n"); sb.append(" binaryName: ").append(toIndentedString(binaryName)).append("\n"); sb.append(" analysisScope: ").append(toIndentedString(analysisScope)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -230,14 +276,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AnalysisUpdateRequest is not found in the empty JSON string", AnalysisUpdateRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("binary_name") != null && !jsonObj.get("binary_name").isJsonNull()) && !jsonObj.get("binary_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `binary_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("binary_name").toString())); @@ -266,6 +304,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -273,7 +333,28 @@ public void write(JsonWriter out, AnalysisUpdateRequest value) throws IOExceptio public AnalysisUpdateRequest 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 + AnalysisUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java b/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java index 60e66e9..1013099 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateTagsRequest.java @@ -87,6 +87,50 @@ public void setTags(@javax.annotation.Nonnull List tags) { this.tags = tags; } + /** + * 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 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 AnalysisUpdateTagsRequest instance itself + */ + public AnalysisUpdateTagsRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } AnalysisUpdateTagsRequest analysisUpdateTagsRequest = (AnalysisUpdateTagsRequest) o; - return Objects.equals(this.tags, analysisUpdateTagsRequest.tags); + return Objects.equals(this.tags, analysisUpdateTagsRequest.tags)&& + Objects.equals(this.additionalProperties, analysisUpdateTagsRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisUpdateTagsRequest {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisUpdateTagsRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisUpdateTagsRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisUpdateTagsRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisUpdateTagsRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, AnalysisUpdateTagsRequest value) throws IOExce public AnalysisUpdateTagsRequest 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 + AnalysisUpdateTagsRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java b/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java index 88470e0..deda6c6 100644 --- a/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java +++ b/src/main/java/ai/reveng/model/AnalysisUpdateTagsResponse.java @@ -88,6 +88,50 @@ public void setTags(@javax.annotation.Nonnull List tags) { this.tags = tags; } + /** + * 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 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 AnalysisUpdateTagsResponse instance itself + */ + public AnalysisUpdateTagsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } AnalysisUpdateTagsResponse analysisUpdateTagsResponse = (AnalysisUpdateTagsResponse) o; - return Objects.equals(this.tags, analysisUpdateTagsResponse.tags); + return Objects.equals(this.tags, analysisUpdateTagsResponse.tags)&& + Objects.equals(this.additionalProperties, analysisUpdateTagsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AnalysisUpdateTagsResponse {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AnalysisUpdateTagsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AnalysisUpdateTagsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AnalysisUpdateTagsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AnalysisUpdateTagsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, AnalysisUpdateTagsResponse value) throws IOExc public AnalysisUpdateTagsResponse 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 + AnalysisUpdateTagsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AppApiRestV2AnalysesResponsesTagItem.java b/src/main/java/ai/reveng/model/AppApiRestV2AnalysesResponsesTagItem.java index 794aac3..691844e 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2AnalysesResponsesTagItem.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2AnalysesResponsesTagItem.java @@ -126,6 +126,50 @@ public void setCollectionId(@javax.annotation.Nullable Integer collectionId) { this.collectionId = collectionId; } + /** + * 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 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 AppApiRestV2AnalysesResponsesTagItem instance itself + */ + public AppApiRestV2AnalysesResponsesTagItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -139,7 +183,8 @@ public boolean equals(Object o) { AppApiRestV2AnalysesResponsesTagItem appApiRestV2AnalysesResponsesTagItem = (AppApiRestV2AnalysesResponsesTagItem) o; return Objects.equals(this.name, appApiRestV2AnalysesResponsesTagItem.name) && Objects.equals(this.origin, appApiRestV2AnalysesResponsesTagItem.origin) && - Objects.equals(this.collectionId, appApiRestV2AnalysesResponsesTagItem.collectionId); + Objects.equals(this.collectionId, appApiRestV2AnalysesResponsesTagItem.collectionId)&& + Objects.equals(this.additionalProperties, appApiRestV2AnalysesResponsesTagItem.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -148,7 +193,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(name, origin, collectionId); + return Objects.hash(name, origin, collectionId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -165,6 +210,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); sb.append(" collectionId: ").append(toIndentedString(collectionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,14 +251,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AppApiRestV2AnalysesResponsesTagItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AppApiRestV2AnalysesResponsesTagItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2AnalysesResponsesTagItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -243,6 +281,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AppApiRestV2AnalysesResponsesTagItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -250,7 +310,28 @@ public void write(JsonWriter out, AppApiRestV2AnalysesResponsesTagItem value) th public AppApiRestV2AnalysesResponsesTagItem 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 + AppApiRestV2AnalysesResponsesTagItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java index c13c8af..7468928 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunction.java @@ -21,6 +21,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -53,7 +54,7 @@ public class AppApiRestV2FunctionsResponsesFunction { public static final String SERIALIZED_NAME_FUNCTION_ID = "function_id"; @SerializedName(SERIALIZED_NAME_FUNCTION_ID) - @javax.annotation.Nonnull + @javax.annotation.Nullable private Integer functionId; public static final String SERIALIZED_NAME_FUNCTION_VADDR = "function_vaddr"; @@ -64,7 +65,7 @@ public class AppApiRestV2FunctionsResponsesFunction { public AppApiRestV2FunctionsResponsesFunction() { } - public AppApiRestV2FunctionsResponsesFunction functionId(@javax.annotation.Nonnull Integer functionId) { + public AppApiRestV2FunctionsResponsesFunction functionId(@javax.annotation.Nullable Integer functionId) { this.functionId = functionId; return this; } @@ -73,12 +74,12 @@ public AppApiRestV2FunctionsResponsesFunction functionId(@javax.annotation.Nonnu * Get functionId * @return functionId */ - @javax.annotation.Nonnull + @javax.annotation.Nullable public Integer getFunctionId() { return functionId; } - public void setFunctionId(@javax.annotation.Nonnull Integer functionId) { + public void setFunctionId(@javax.annotation.Nullable Integer functionId) { this.functionId = functionId; } @@ -101,6 +102,50 @@ public void setFunctionVaddr(@javax.annotation.Nonnull Long functionVaddr) { this.functionVaddr = functionVaddr; } + /** + * 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 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 AppApiRestV2FunctionsResponsesFunction instance itself + */ + public AppApiRestV2FunctionsResponsesFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +158,24 @@ public boolean equals(Object o) { } AppApiRestV2FunctionsResponsesFunction appApiRestV2FunctionsResponsesFunction = (AppApiRestV2FunctionsResponsesFunction) o; return Objects.equals(this.functionId, appApiRestV2FunctionsResponsesFunction.functionId) && - Objects.equals(this.functionVaddr, appApiRestV2FunctionsResponsesFunction.functionVaddr); + Objects.equals(this.functionVaddr, appApiRestV2FunctionsResponsesFunction.functionVaddr)&& + Objects.equals(this.additionalProperties, appApiRestV2FunctionsResponsesFunction.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(functionId, functionVaddr); + return Objects.hash(functionId, functionVaddr, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; } @Override @@ -127,6 +184,7 @@ public String toString() { sb.append("class AppApiRestV2FunctionsResponsesFunction {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,7 +209,7 @@ private String toIndentedString(Object o) { openapiFields = new HashSet(Arrays.asList("function_id", "function_vaddr")); // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("function_id", "function_vaddr")); + openapiRequiredFields = new HashSet(Arrays.asList("function_vaddr")); } /** @@ -167,14 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AppApiRestV2FunctionsResponsesFunction.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AppApiRestV2FunctionsResponsesFunction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2FunctionsResponsesFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -199,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AppApiRestV2FunctionsResponsesFunction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -206,7 +278,28 @@ public void write(JsonWriter out, AppApiRestV2FunctionsResponsesFunction value) public AppApiRestV2FunctionsResponsesFunction 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 + AppApiRestV2FunctionsResponsesFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java index f5a36e4..748b853 100644 --- a/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java +++ b/src/main/java/ai/reveng/model/AppApiRestV2FunctionsTypesFunction.java @@ -264,6 +264,50 @@ public void setEmbedding1d(@javax.annotation.Nullable List embedding this.embedding1d = embedding1d; } + /** + * 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 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 AppApiRestV2FunctionsTypesFunction instance itself + */ + public AppApiRestV2FunctionsTypesFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -282,12 +326,13 @@ public boolean equals(Object o) { Objects.equals(this.functionSize, appApiRestV2FunctionsTypesFunction.functionSize) && Objects.equals(this.debug, appApiRestV2FunctionsTypesFunction.debug) && Objects.equals(this.embedding3d, appApiRestV2FunctionsTypesFunction.embedding3d) && - Objects.equals(this.embedding1d, appApiRestV2FunctionsTypesFunction.embedding1d); + Objects.equals(this.embedding1d, appApiRestV2FunctionsTypesFunction.embedding1d)&& + Objects.equals(this.additionalProperties, appApiRestV2FunctionsTypesFunction.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName, functionMangledName, functionVaddr, functionSize, debug, embedding3d, embedding1d); + return Objects.hash(functionId, functionName, functionMangledName, functionVaddr, functionSize, debug, embedding3d, embedding1d, additionalProperties); } @Override @@ -302,6 +347,7 @@ public String toString() { sb.append(" debug: ").append(toIndentedString(debug)).append("\n"); sb.append(" embedding3d: ").append(toIndentedString(embedding3d)).append("\n"); sb.append(" embedding1d: ").append(toIndentedString(embedding1d)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -342,14 +388,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AppApiRestV2FunctionsTypesFunction.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AppApiRestV2FunctionsTypesFunction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppApiRestV2FunctionsTypesFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -392,6 +430,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AppApiRestV2FunctionsTypesFunction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -399,7 +459,28 @@ public void write(JsonWriter out, AppApiRestV2FunctionsTypesFunction value) thro public AppApiRestV2FunctionsTypesFunction 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 + AppApiRestV2FunctionsTypesFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AppServicesBinaryAnnSchemaTagItem.java b/src/main/java/ai/reveng/model/AppServicesBinaryAnnSchemaTagItem.java index 19652e1..9c2245d 100644 --- a/src/main/java/ai/reveng/model/AppServicesBinaryAnnSchemaTagItem.java +++ b/src/main/java/ai/reveng/model/AppServicesBinaryAnnSchemaTagItem.java @@ -102,6 +102,50 @@ public void setOrigin(@javax.annotation.Nullable String origin) { this.origin = origin; } + /** + * 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 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 AppServicesBinaryAnnSchemaTagItem instance itself + */ + public AppServicesBinaryAnnSchemaTagItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,7 +158,8 @@ public boolean equals(Object o) { } AppServicesBinaryAnnSchemaTagItem appServicesBinaryAnnSchemaTagItem = (AppServicesBinaryAnnSchemaTagItem) o; return Objects.equals(this.tag, appServicesBinaryAnnSchemaTagItem.tag) && - Objects.equals(this.origin, appServicesBinaryAnnSchemaTagItem.origin); + Objects.equals(this.origin, appServicesBinaryAnnSchemaTagItem.origin)&& + Objects.equals(this.additionalProperties, appServicesBinaryAnnSchemaTagItem.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -123,7 +168,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(tag, origin); + return Objects.hash(tag, origin, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -139,6 +184,7 @@ public String toString() { sb.append("class AppServicesBinaryAnnSchemaTagItem {\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AppServicesBinaryAnnSchemaTagItem is not found in the empty JSON string", AppServicesBinaryAnnSchemaTagItem.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AppServicesBinaryAnnSchemaTagItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AppServicesBinaryAnnSchemaTagItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); @@ -210,6 +248,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AppServicesBinaryAnnSchemaTagItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -217,7 +277,28 @@ public void write(JsonWriter out, AppServicesBinaryAnnSchemaTagItem value) throw public AppServicesBinaryAnnSchemaTagItem 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 + AppServicesBinaryAnnSchemaTagItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AppServicesDynamicExecutionSchemasDynamicExecutionStatus.java b/src/main/java/ai/reveng/model/AppServicesDynamicExecutionSchemasDynamicExecutionStatus.java index dc0e63f..46bff83 100644 --- a/src/main/java/ai/reveng/model/AppServicesDynamicExecutionSchemasDynamicExecutionStatus.java +++ b/src/main/java/ai/reveng/model/AppServicesDynamicExecutionSchemasDynamicExecutionStatus.java @@ -77,6 +77,50 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } + /** + * 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 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 AppServicesDynamicExecutionSchemasDynamicExecutionStatus instance itself + */ + public AppServicesDynamicExecutionSchemasDynamicExecutionStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } AppServicesDynamicExecutionSchemasDynamicExecutionStatus appServicesDynamicExecutionSchemasDynamicExecutionStatus = (AppServicesDynamicExecutionSchemasDynamicExecutionStatus) o; - return Objects.equals(this.status, appServicesDynamicExecutionSchemasDynamicExecutionStatus.status); + return Objects.equals(this.status, appServicesDynamicExecutionSchemasDynamicExecutionStatus.status)&& + Objects.equals(this.additionalProperties, appServicesDynamicExecutionSchemasDynamicExecutionStatus.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AppServicesDynamicExecutionSchemasDynamicExecutionStatus {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AppServicesDynamicExecutionSchemasDynamicExecutionStatus.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AppServicesDynamicExecutionSchemasDynamicExecutionStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : AppServicesDynamicExecutionSchemasDynamicExecutionStatus.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AppServicesDynamicExecutionSchemasDynamicExecutionStatus value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, AppServicesDynamicExecutionSchemasDynamicExecu public AppServicesDynamicExecutionSchemasDynamicExecutionStatus 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 + AppServicesDynamicExecutionSchemasDynamicExecutionStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Argument.java b/src/main/java/ai/reveng/model/Argument.java index f8bb482..ccafd16 100644 --- a/src/main/java/ai/reveng/model/Argument.java +++ b/src/main/java/ai/reveng/model/Argument.java @@ -174,6 +174,50 @@ public void setSize(@javax.annotation.Nonnull Integer size) { this.size = size; } + /** + * 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 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 Argument instance itself + */ + public Argument putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -189,7 +233,8 @@ public boolean equals(Object o) { Objects.equals(this.offset, argument.offset) && Objects.equals(this.name, argument.name) && Objects.equals(this.type, argument.type) && - Objects.equals(this.size, argument.size); + Objects.equals(this.size, argument.size)&& + Objects.equals(this.additionalProperties, argument.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -198,7 +243,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, offset, name, type, size); + return Objects.hash(lastChange, offset, name, type, size, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -217,6 +262,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -257,14 +303,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Argument.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Argument` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Argument.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -298,6 +336,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Argument value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -305,7 +365,28 @@ public void write(JsonWriter out, Argument value) throws IOException { public Argument 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 + Argument instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AutoUnstripRequest.java b/src/main/java/ai/reveng/model/AutoUnstripRequest.java index e661614..75d91a1 100644 --- a/src/main/java/ai/reveng/model/AutoUnstripRequest.java +++ b/src/main/java/ai/reveng/model/AutoUnstripRequest.java @@ -156,6 +156,50 @@ public void setMinGroupSize(@javax.annotation.Nullable Integer minGroupSize) { this.minGroupSize = minGroupSize; } + /** + * 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 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 AutoUnstripRequest instance itself + */ + public AutoUnstripRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -170,12 +214,13 @@ public boolean equals(Object o) { return Objects.equals(this.minSimilarity, autoUnstripRequest.minSimilarity) && Objects.equals(this.apply, autoUnstripRequest.apply) && Objects.equals(this.confidenceThreshold, autoUnstripRequest.confidenceThreshold) && - Objects.equals(this.minGroupSize, autoUnstripRequest.minGroupSize); + Objects.equals(this.minGroupSize, autoUnstripRequest.minGroupSize)&& + Objects.equals(this.additionalProperties, autoUnstripRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(minSimilarity, apply, confidenceThreshold, minGroupSize); + return Objects.hash(minSimilarity, apply, confidenceThreshold, minGroupSize, additionalProperties); } @Override @@ -186,6 +231,7 @@ public String toString() { sb.append(" apply: ").append(toIndentedString(apply)).append("\n"); sb.append(" confidenceThreshold: ").append(toIndentedString(confidenceThreshold)).append("\n"); sb.append(" minGroupSize: ").append(toIndentedString(minGroupSize)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AutoUnstripRequest is not found in the empty JSON string", AutoUnstripRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AutoUnstripRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AutoUnstripRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -251,6 +289,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AutoUnstripRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -258,7 +318,28 @@ public void write(JsonWriter out, AutoUnstripRequest value) throws IOException { public AutoUnstripRequest 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 + AutoUnstripRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/AutoUnstripResponse.java b/src/main/java/ai/reveng/model/AutoUnstripResponse.java index f26dde6..7ad4a15 100644 --- a/src/main/java/ai/reveng/model/AutoUnstripResponse.java +++ b/src/main/java/ai/reveng/model/AutoUnstripResponse.java @@ -209,6 +209,50 @@ public void setErrorMessage(@javax.annotation.Nullable String errorMessage) { this.errorMessage = errorMessage; } + /** + * 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 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 AutoUnstripResponse instance itself + */ + public AutoUnstripResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -225,7 +269,8 @@ public boolean equals(Object o) { Objects.equals(this.totalTime, autoUnstripResponse.totalTime) && Objects.equals(this.matches, autoUnstripResponse.matches) && Objects.equals(this.applied, autoUnstripResponse.applied) && - Objects.equals(this.errorMessage, autoUnstripResponse.errorMessage); + Objects.equals(this.errorMessage, autoUnstripResponse.errorMessage)&& + Objects.equals(this.additionalProperties, autoUnstripResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -234,7 +279,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(progress, status, totalTime, matches, applied, errorMessage); + return Objects.hash(progress, status, totalTime, matches, applied, errorMessage, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -254,6 +299,7 @@ public String toString() { sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); sb.append(" applied: ").append(toIndentedString(applied)).append("\n"); sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -293,14 +339,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in AutoUnstripResponse is not found in the empty JSON string", AutoUnstripResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!AutoUnstripResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `AutoUnstripResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString())); @@ -339,6 +377,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, AutoUnstripResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +406,28 @@ public void write(JsonWriter out, AutoUnstripResponse value) throws IOException public AutoUnstripResponse 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 + AutoUnstripResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponse.java b/src/main/java/ai/reveng/model/BaseResponse.java index 1ff572a..a56c27d 100644 --- a/src/main/java/ai/reveng/model/BaseResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponse instance itself + */ + public BaseResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponse.data) && Objects.equals(this.message, baseResponse.message) && Objects.equals(this.errors, baseResponse.errors) && - Objects.equals(this.meta, baseResponse.meta); + Objects.equals(this.meta, baseResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponse is not found in the empty JSON string", BaseResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponse value) throws IOException { public BaseResponse 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 + BaseResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java index a9eaafa..9ded3d3 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisCreateResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisCreateResponse instance itself + */ + public BaseResponseAnalysisCreateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisCreateResponse.data) && Objects.equals(this.message, baseResponseAnalysisCreateResponse.message) && Objects.equals(this.errors, baseResponseAnalysisCreateResponse.errors) && - Objects.equals(this.meta, baseResponseAnalysisCreateResponse.meta); + Objects.equals(this.meta, baseResponseAnalysisCreateResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisCreateResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisCreateResponse is not found in the empty JSON string", BaseResponseAnalysisCreateResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisCreateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisCreateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisCreateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisCreateResponse value) thro public BaseResponseAnalysisCreateResponse 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 + BaseResponseAnalysisCreateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java index 98bf54d..83ec3ca 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisDetailResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisDetailResponse instance itself + */ + public BaseResponseAnalysisDetailResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisDetailResponse.data) && Objects.equals(this.message, baseResponseAnalysisDetailResponse.message) && Objects.equals(this.errors, baseResponseAnalysisDetailResponse.errors) && - Objects.equals(this.meta, baseResponseAnalysisDetailResponse.meta); + Objects.equals(this.meta, baseResponseAnalysisDetailResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisDetailResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisDetailResponse is not found in the empty JSON string", BaseResponseAnalysisDetailResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisDetailResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisDetailResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisDetailResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisDetailResponse value) thro public BaseResponseAnalysisDetailResponse 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 + BaseResponseAnalysisDetailResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java index 7539f19..4ed5632 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctionMapping.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisFunctionMapping instance itself + */ + public BaseResponseAnalysisFunctionMapping putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisFunctionMapping.data) && Objects.equals(this.message, baseResponseAnalysisFunctionMapping.message) && Objects.equals(this.errors, baseResponseAnalysisFunctionMapping.errors) && - Objects.equals(this.meta, baseResponseAnalysisFunctionMapping.meta); + Objects.equals(this.meta, baseResponseAnalysisFunctionMapping.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisFunctionMapping.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctionMapping is not found in the empty JSON string", BaseResponseAnalysisFunctionMapping.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisFunctionMapping.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisFunctionMapping` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisFunctionMapping value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisFunctionMapping value) thr public BaseResponseAnalysisFunctionMapping 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 + BaseResponseAnalysisFunctionMapping instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java index a2881e4..a3357de 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisFunctions.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisFunctions instance itself + */ + public BaseResponseAnalysisFunctions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisFunctions.data) && Objects.equals(this.message, baseResponseAnalysisFunctions.message) && Objects.equals(this.errors, baseResponseAnalysisFunctions.errors) && - Objects.equals(this.meta, baseResponseAnalysisFunctions.meta); + Objects.equals(this.meta, baseResponseAnalysisFunctions.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisFunctions.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisFunctions is not found in the empty JSON string", BaseResponseAnalysisFunctions.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisFunctions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisFunctions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisFunctions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisFunctions value) throws IO public BaseResponseAnalysisFunctions 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 + BaseResponseAnalysisFunctions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java index 588e35a..f013e11 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisStringsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisStringsResponse instance itself + */ + public BaseResponseAnalysisStringsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisStringsResponse.data) && Objects.equals(this.message, baseResponseAnalysisStringsResponse.message) && Objects.equals(this.errors, baseResponseAnalysisStringsResponse.errors) && - Objects.equals(this.meta, baseResponseAnalysisStringsResponse.meta); + Objects.equals(this.meta, baseResponseAnalysisStringsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisStringsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisStringsResponse is not found in the empty JSON string", BaseResponseAnalysisStringsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisStringsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisStringsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisStringsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisStringsResponse value) thr public BaseResponseAnalysisStringsResponse 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 + BaseResponseAnalysisStringsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java index a0fab52..921e906 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisTags.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisTags instance itself + */ + public BaseResponseAnalysisTags putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisTags.data) && Objects.equals(this.message, baseResponseAnalysisTags.message) && Objects.equals(this.errors, baseResponseAnalysisTags.errors) && - Objects.equals(this.meta, baseResponseAnalysisTags.meta); + Objects.equals(this.meta, baseResponseAnalysisTags.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisTags.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisTags is not found in the empty JSON string", BaseResponseAnalysisTags.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisTags.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisTags` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisTags value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisTags value) throws IOExcep public BaseResponseAnalysisTags 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 + BaseResponseAnalysisTags instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java b/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java index d3bf1da..d3fb9ed 100644 --- a/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseAnalysisUpdateTagsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseAnalysisUpdateTagsResponse instance itself + */ + public BaseResponseAnalysisUpdateTagsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseAnalysisUpdateTagsResponse.data) && Objects.equals(this.message, baseResponseAnalysisUpdateTagsResponse.message) && Objects.equals(this.errors, baseResponseAnalysisUpdateTagsResponse.errors) && - Objects.equals(this.meta, baseResponseAnalysisUpdateTagsResponse.meta); + Objects.equals(this.meta, baseResponseAnalysisUpdateTagsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseAnalysisUpdateTagsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseAnalysisUpdateTagsResponse is not found in the empty JSON string", BaseResponseAnalysisUpdateTagsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseAnalysisUpdateTagsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseAnalysisUpdateTagsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseAnalysisUpdateTagsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseAnalysisUpdateTagsResponse value) public BaseResponseAnalysisUpdateTagsResponse 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 + BaseResponseAnalysisUpdateTagsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBasic.java b/src/main/java/ai/reveng/model/BaseResponseBasic.java index 7caa3e0..ed3a710 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBasic.java +++ b/src/main/java/ai/reveng/model/BaseResponseBasic.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBasic instance itself + */ + public BaseResponseBasic putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBasic.data) && Objects.equals(this.message, baseResponseBasic.message) && Objects.equals(this.errors, baseResponseBasic.errors) && - Objects.equals(this.meta, baseResponseBasic.meta); + Objects.equals(this.meta, baseResponseBasic.meta)&& + Objects.equals(this.additionalProperties, baseResponseBasic.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBasic is not found in the empty JSON string", BaseResponseBasic.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBasic.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBasic` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBasic value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBasic value) throws IOException { public BaseResponseBasic 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 + BaseResponseBasic instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java index 0986bce..80d59f2 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryAdditionalResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBinaryAdditionalResponse instance itself + */ + public BaseResponseBinaryAdditionalResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBinaryAdditionalResponse.data) && Objects.equals(this.message, baseResponseBinaryAdditionalResponse.message) && Objects.equals(this.errors, baseResponseBinaryAdditionalResponse.errors) && - Objects.equals(this.meta, baseResponseBinaryAdditionalResponse.meta); + Objects.equals(this.meta, baseResponseBinaryAdditionalResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBinaryAdditionalResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryAdditionalResponse is not found in the empty JSON string", BaseResponseBinaryAdditionalResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBinaryAdditionalResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBinaryAdditionalResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBinaryAdditionalResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBinaryAdditionalResponse value) th public BaseResponseBinaryAdditionalResponse 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 + BaseResponseBinaryAdditionalResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryAnnListResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryAnnListResponse.java index 83ab57a..88b967f 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryAnnListResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryAnnListResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBinaryAnnListResponse instance itself + */ + public BaseResponseBinaryAnnListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBinaryAnnListResponse.data) && Objects.equals(this.message, baseResponseBinaryAnnListResponse.message) && Objects.equals(this.errors, baseResponseBinaryAnnListResponse.errors) && - Objects.equals(this.meta, baseResponseBinaryAnnListResponse.meta); + Objects.equals(this.meta, baseResponseBinaryAnnListResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBinaryAnnListResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryAnnListResponse is not found in the empty JSON string", BaseResponseBinaryAnnListResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBinaryAnnListResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBinaryAnnListResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBinaryAnnListResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBinaryAnnListResponse value) throw public BaseResponseBinaryAnnListResponse 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 + BaseResponseBinaryAnnListResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java index 941ca5b..51b4ae7 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryDetailsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBinaryDetailsResponse instance itself + */ + public BaseResponseBinaryDetailsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBinaryDetailsResponse.data) && Objects.equals(this.message, baseResponseBinaryDetailsResponse.message) && Objects.equals(this.errors, baseResponseBinaryDetailsResponse.errors) && - Objects.equals(this.meta, baseResponseBinaryDetailsResponse.meta); + Objects.equals(this.meta, baseResponseBinaryDetailsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBinaryDetailsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryDetailsResponse is not found in the empty JSON string", BaseResponseBinaryDetailsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBinaryDetailsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBinaryDetailsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBinaryDetailsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBinaryDetailsResponse value) throw public BaseResponseBinaryDetailsResponse 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 + BaseResponseBinaryDetailsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java index 8e39e36..4ebd1ee 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinaryExternalsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBinaryExternalsResponse instance itself + */ + public BaseResponseBinaryExternalsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBinaryExternalsResponse.data) && Objects.equals(this.message, baseResponseBinaryExternalsResponse.message) && Objects.equals(this.errors, baseResponseBinaryExternalsResponse.errors) && - Objects.equals(this.meta, baseResponseBinaryExternalsResponse.meta); + Objects.equals(this.meta, baseResponseBinaryExternalsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBinaryExternalsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinaryExternalsResponse is not found in the empty JSON string", BaseResponseBinaryExternalsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBinaryExternalsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBinaryExternalsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBinaryExternalsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBinaryExternalsResponse value) thr public BaseResponseBinaryExternalsResponse 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 + BaseResponseBinaryExternalsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java index 83393da..2cf219d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBinarySearchResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBinarySearchResponse instance itself + */ + public BaseResponseBinarySearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBinarySearchResponse.data) && Objects.equals(this.message, baseResponseBinarySearchResponse.message) && Objects.equals(this.errors, baseResponseBinarySearchResponse.errors) && - Objects.equals(this.meta, baseResponseBinarySearchResponse.meta); + Objects.equals(this.meta, baseResponseBinarySearchResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBinarySearchResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBinarySearchResponse is not found in the empty JSON string", BaseResponseBinarySearchResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBinarySearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBinarySearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBinarySearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBinarySearchResponse value) throws public BaseResponseBinarySearchResponse 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 + BaseResponseBinarySearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBlockCommentsGenerationForFunctionResponse.java b/src/main/java/ai/reveng/model/BaseResponseBlockCommentsGenerationForFunctionResponse.java index 630b5e5..e89794b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBlockCommentsGenerationForFunctionResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBlockCommentsGenerationForFunctionResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBlockCommentsGenerationForFunctionResponse instance itself + */ + public BaseResponseBlockCommentsGenerationForFunctionResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBlockCommentsGenerationForFunctionResponse.data) && Objects.equals(this.message, baseResponseBlockCommentsGenerationForFunctionResponse.message) && Objects.equals(this.errors, baseResponseBlockCommentsGenerationForFunctionResponse.errors) && - Objects.equals(this.meta, baseResponseBlockCommentsGenerationForFunctionResponse.meta); + Objects.equals(this.meta, baseResponseBlockCommentsGenerationForFunctionResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBlockCommentsGenerationForFunctionResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBlockCommentsGenerationForFunctionResponse is not found in the empty JSON string", BaseResponseBlockCommentsGenerationForFunctionResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBlockCommentsGenerationForFunctionResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBlockCommentsGenerationForFunctionResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBlockCommentsGenerationForFunctionResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBlockCommentsGenerationForFunction public BaseResponseBlockCommentsGenerationForFunctionResponse 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 + BaseResponseBlockCommentsGenerationForFunctionResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBlockCommentsOverviewGenerationResponse.java b/src/main/java/ai/reveng/model/BaseResponseBlockCommentsOverviewGenerationResponse.java index 613f016..f52c972 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBlockCommentsOverviewGenerationResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseBlockCommentsOverviewGenerationResponse.java @@ -186,6 +186,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBlockCommentsOverviewGenerationResponse instance itself + */ + public BaseResponseBlockCommentsOverviewGenerationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -201,7 +245,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBlockCommentsOverviewGenerationResponse.data) && Objects.equals(this.message, baseResponseBlockCommentsOverviewGenerationResponse.message) && Objects.equals(this.errors, baseResponseBlockCommentsOverviewGenerationResponse.errors) && - Objects.equals(this.meta, baseResponseBlockCommentsOverviewGenerationResponse.meta); + Objects.equals(this.meta, baseResponseBlockCommentsOverviewGenerationResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseBlockCommentsOverviewGenerationResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -210,7 +255,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -229,6 +274,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBlockCommentsOverviewGenerationResponse is not found in the empty JSON string", BaseResponseBlockCommentsOverviewGenerationResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBlockCommentsOverviewGenerationResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBlockCommentsOverviewGenerationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); @@ -315,6 +353,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBlockCommentsOverviewGenerationResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -322,7 +382,28 @@ public void write(JsonWriter out, BaseResponseBlockCommentsOverviewGenerationRes public BaseResponseBlockCommentsOverviewGenerationResponse 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 + BaseResponseBlockCommentsOverviewGenerationResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBool.java b/src/main/java/ai/reveng/model/BaseResponseBool.java index 9d06351..7e32b66 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBool.java +++ b/src/main/java/ai/reveng/model/BaseResponseBool.java @@ -186,6 +186,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBool instance itself + */ + public BaseResponseBool putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -201,7 +245,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBool.data) && Objects.equals(this.message, baseResponseBool.message) && Objects.equals(this.errors, baseResponseBool.errors) && - Objects.equals(this.meta, baseResponseBool.meta); + Objects.equals(this.meta, baseResponseBool.meta)&& + Objects.equals(this.additionalProperties, baseResponseBool.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -210,7 +255,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -229,6 +274,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBool is not found in the empty JSON string", BaseResponseBool.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBool.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBool` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); @@ -315,6 +353,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBool value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -322,7 +382,28 @@ public void write(JsonWriter out, BaseResponseBool value) throws IOException { public BaseResponseBool 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 + BaseResponseBool instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseBoxPlotConfidence.java b/src/main/java/ai/reveng/model/BaseResponseBoxPlotConfidence.java index 2bb91c6..c5213fb 100644 --- a/src/main/java/ai/reveng/model/BaseResponseBoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/BaseResponseBoxPlotConfidence.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseBoxPlotConfidence instance itself + */ + public BaseResponseBoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseBoxPlotConfidence.data) && Objects.equals(this.message, baseResponseBoxPlotConfidence.message) && Objects.equals(this.errors, baseResponseBoxPlotConfidence.errors) && - Objects.equals(this.meta, baseResponseBoxPlotConfidence.meta); + Objects.equals(this.meta, baseResponseBoxPlotConfidence.meta)&& + Objects.equals(this.additionalProperties, baseResponseBoxPlotConfidence.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseBoxPlotConfidence is not found in the empty JSON string", BaseResponseBoxPlotConfidence.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseBoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseBoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseBoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseBoxPlotConfidence value) throws IO public BaseResponseBoxPlotConfidence 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 + BaseResponseBoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java b/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java index cab0a8c..e3b1291 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCalleesCallerFunctionsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCalleesCallerFunctionsResponse instance itself + */ + public BaseResponseCalleesCallerFunctionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCalleesCallerFunctionsResponse.data) && Objects.equals(this.message, baseResponseCalleesCallerFunctionsResponse.message) && Objects.equals(this.errors, baseResponseCalleesCallerFunctionsResponse.errors) && - Objects.equals(this.meta, baseResponseCalleesCallerFunctionsResponse.meta); + Objects.equals(this.meta, baseResponseCalleesCallerFunctionsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCalleesCallerFunctionsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCalleesCallerFunctionsResponse is not found in the empty JSON string", BaseResponseCalleesCallerFunctionsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCalleesCallerFunctionsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCalleesCallerFunctionsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCalleesCallerFunctionsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCalleesCallerFunctionsResponse val public BaseResponseCalleesCallerFunctionsResponse 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 + BaseResponseCalleesCallerFunctionsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCapabilities.java b/src/main/java/ai/reveng/model/BaseResponseCapabilities.java index 314e620..05e116b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCapabilities.java +++ b/src/main/java/ai/reveng/model/BaseResponseCapabilities.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCapabilities instance itself + */ + public BaseResponseCapabilities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCapabilities.data) && Objects.equals(this.message, baseResponseCapabilities.message) && Objects.equals(this.errors, baseResponseCapabilities.errors) && - Objects.equals(this.meta, baseResponseCapabilities.meta); + Objects.equals(this.meta, baseResponseCapabilities.meta)&& + Objects.equals(this.additionalProperties, baseResponseCapabilities.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCapabilities is not found in the empty JSON string", BaseResponseCapabilities.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCapabilities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCapabilities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCapabilities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCapabilities value) throws IOExcep public BaseResponseCapabilities 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 + BaseResponseCapabilities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCheckSecurityChecksTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseCheckSecurityChecksTaskResponse.java index 591387f..67ef7de 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCheckSecurityChecksTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCheckSecurityChecksTaskResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCheckSecurityChecksTaskResponse instance itself + */ + public BaseResponseCheckSecurityChecksTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCheckSecurityChecksTaskResponse.data) && Objects.equals(this.message, baseResponseCheckSecurityChecksTaskResponse.message) && Objects.equals(this.errors, baseResponseCheckSecurityChecksTaskResponse.errors) && - Objects.equals(this.meta, baseResponseCheckSecurityChecksTaskResponse.meta); + Objects.equals(this.meta, baseResponseCheckSecurityChecksTaskResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCheckSecurityChecksTaskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCheckSecurityChecksTaskResponse is not found in the empty JSON string", BaseResponseCheckSecurityChecksTaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCheckSecurityChecksTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCheckSecurityChecksTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCheckSecurityChecksTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCheckSecurityChecksTaskResponse va public BaseResponseCheckSecurityChecksTaskResponse 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 + BaseResponseCheckSecurityChecksTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java b/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java index 40282e0..09c25d6 100644 --- a/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseChildBinariesResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseChildBinariesResponse instance itself + */ + public BaseResponseChildBinariesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseChildBinariesResponse.data) && Objects.equals(this.message, baseResponseChildBinariesResponse.message) && Objects.equals(this.errors, baseResponseChildBinariesResponse.errors) && - Objects.equals(this.meta, baseResponseChildBinariesResponse.meta); + Objects.equals(this.meta, baseResponseChildBinariesResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseChildBinariesResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseChildBinariesResponse is not found in the empty JSON string", BaseResponseChildBinariesResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseChildBinariesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseChildBinariesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseChildBinariesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseChildBinariesResponse value) throw public BaseResponseChildBinariesResponse 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 + BaseResponseChildBinariesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java index a20e40b..a61096e 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionBinariesUpdateResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCollectionBinariesUpdateResponse instance itself + */ + public BaseResponseCollectionBinariesUpdateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCollectionBinariesUpdateResponse.data) && Objects.equals(this.message, baseResponseCollectionBinariesUpdateResponse.message) && Objects.equals(this.errors, baseResponseCollectionBinariesUpdateResponse.errors) && - Objects.equals(this.meta, baseResponseCollectionBinariesUpdateResponse.meta); + Objects.equals(this.meta, baseResponseCollectionBinariesUpdateResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCollectionBinariesUpdateResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionBinariesUpdateResponse is not found in the empty JSON string", BaseResponseCollectionBinariesUpdateResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCollectionBinariesUpdateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCollectionBinariesUpdateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCollectionBinariesUpdateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCollectionBinariesUpdateResponse v public BaseResponseCollectionBinariesUpdateResponse 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 + BaseResponseCollectionBinariesUpdateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java index 4d3e82e..710f913 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCollectionResponse instance itself + */ + public BaseResponseCollectionResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCollectionResponse.data) && Objects.equals(this.message, baseResponseCollectionResponse.message) && Objects.equals(this.errors, baseResponseCollectionResponse.errors) && - Objects.equals(this.meta, baseResponseCollectionResponse.meta); + Objects.equals(this.meta, baseResponseCollectionResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCollectionResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionResponse is not found in the empty JSON string", BaseResponseCollectionResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCollectionResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCollectionResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCollectionResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCollectionResponse value) throws I public BaseResponseCollectionResponse 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 + BaseResponseCollectionResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java index 4164d5c..e9921b9 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionSearchResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCollectionSearchResponse instance itself + */ + public BaseResponseCollectionSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCollectionSearchResponse.data) && Objects.equals(this.message, baseResponseCollectionSearchResponse.message) && Objects.equals(this.errors, baseResponseCollectionSearchResponse.errors) && - Objects.equals(this.meta, baseResponseCollectionSearchResponse.meta); + Objects.equals(this.meta, baseResponseCollectionSearchResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCollectionSearchResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionSearchResponse is not found in the empty JSON string", BaseResponseCollectionSearchResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCollectionSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCollectionSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCollectionSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCollectionSearchResponse value) th public BaseResponseCollectionSearchResponse 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 + BaseResponseCollectionSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java b/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java index eb58cb9..91cc3d0 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCollectionTagsUpdateResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCollectionTagsUpdateResponse instance itself + */ + public BaseResponseCollectionTagsUpdateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCollectionTagsUpdateResponse.data) && Objects.equals(this.message, baseResponseCollectionTagsUpdateResponse.message) && Objects.equals(this.errors, baseResponseCollectionTagsUpdateResponse.errors) && - Objects.equals(this.meta, baseResponseCollectionTagsUpdateResponse.meta); + Objects.equals(this.meta, baseResponseCollectionTagsUpdateResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCollectionTagsUpdateResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCollectionTagsUpdateResponse is not found in the empty JSON string", BaseResponseCollectionTagsUpdateResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCollectionTagsUpdateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCollectionTagsUpdateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCollectionTagsUpdateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCollectionTagsUpdateResponse value public BaseResponseCollectionTagsUpdateResponse 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 + BaseResponseCollectionTagsUpdateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java b/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java index 0e4e9bf..d50848d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseCommentResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCommentResponse instance itself + */ + public BaseResponseCommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCommentResponse.data) && Objects.equals(this.message, baseResponseCommentResponse.message) && Objects.equals(this.errors, baseResponseCommentResponse.errors) && - Objects.equals(this.meta, baseResponseCommentResponse.meta); + Objects.equals(this.meta, baseResponseCommentResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseCommentResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCommentResponse is not found in the empty JSON string", BaseResponseCommentResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCommentResponse value) throws IOEx public BaseResponseCommentResponse 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 + BaseResponseCommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCommunities.java b/src/main/java/ai/reveng/model/BaseResponseCommunities.java index 0f67efd..90f82ca 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCommunities.java +++ b/src/main/java/ai/reveng/model/BaseResponseCommunities.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCommunities instance itself + */ + public BaseResponseCommunities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCommunities.data) && Objects.equals(this.message, baseResponseCommunities.message) && Objects.equals(this.errors, baseResponseCommunities.errors) && - Objects.equals(this.meta, baseResponseCommunities.meta); + Objects.equals(this.meta, baseResponseCommunities.meta)&& + Objects.equals(this.additionalProperties, baseResponseCommunities.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCommunities is not found in the empty JSON string", BaseResponseCommunities.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCommunities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCommunities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCommunities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCommunities value) throws IOExcept public BaseResponseCommunities 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 + BaseResponseCommunities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseCreated.java b/src/main/java/ai/reveng/model/BaseResponseCreated.java index eaffa8d..0b1597a 100644 --- a/src/main/java/ai/reveng/model/BaseResponseCreated.java +++ b/src/main/java/ai/reveng/model/BaseResponseCreated.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseCreated instance itself + */ + public BaseResponseCreated putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseCreated.data) && Objects.equals(this.message, baseResponseCreated.message) && Objects.equals(this.errors, baseResponseCreated.errors) && - Objects.equals(this.meta, baseResponseCreated.meta); + Objects.equals(this.meta, baseResponseCreated.meta)&& + Objects.equals(this.additionalProperties, baseResponseCreated.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseCreated is not found in the empty JSON string", BaseResponseCreated.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseCreated.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseCreated` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseCreated value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseCreated value) throws IOException public BaseResponseCreated 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 + BaseResponseCreated instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseDecompilationResponse.java b/src/main/java/ai/reveng/model/BaseResponseDecompilationResponse.java index 80d9380..c8e3c1b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseDecompilationResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseDecompilationResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseDecompilationResponse instance itself + */ + public BaseResponseDecompilationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseDecompilationResponse.data) && Objects.equals(this.message, baseResponseDecompilationResponse.message) && Objects.equals(this.errors, baseResponseDecompilationResponse.errors) && - Objects.equals(this.meta, baseResponseDecompilationResponse.meta); + Objects.equals(this.meta, baseResponseDecompilationResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseDecompilationResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseDecompilationResponse is not found in the empty JSON string", BaseResponseDecompilationResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseDecompilationResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseDecompilationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseDecompilationResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseDecompilationResponse value) throw public BaseResponseDecompilationResponse 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 + BaseResponseDecompilationResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseDict.java b/src/main/java/ai/reveng/model/BaseResponseDict.java index e9e5c3d..bccf072 100644 --- a/src/main/java/ai/reveng/model/BaseResponseDict.java +++ b/src/main/java/ai/reveng/model/BaseResponseDict.java @@ -196,6 +196,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseDict instance itself + */ + public BaseResponseDict putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -211,7 +255,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseDict.data) && Objects.equals(this.message, baseResponseDict.message) && Objects.equals(this.errors, baseResponseDict.errors) && - Objects.equals(this.meta, baseResponseDict.meta); + Objects.equals(this.meta, baseResponseDict.meta)&& + Objects.equals(this.additionalProperties, baseResponseDict.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -220,7 +265,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -239,6 +284,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -278,14 +324,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseDict is not found in the empty JSON string", BaseResponseDict.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseDict.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseDict` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); @@ -325,6 +363,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseDict value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -332,7 +392,28 @@ public void write(JsonWriter out, BaseResponseDict value) throws IOException { public BaseResponseDict 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 + BaseResponseDict instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseDynamicExecutionStatus.java b/src/main/java/ai/reveng/model/BaseResponseDynamicExecutionStatus.java index 5e6c2ca..098b3c5 100644 --- a/src/main/java/ai/reveng/model/BaseResponseDynamicExecutionStatus.java +++ b/src/main/java/ai/reveng/model/BaseResponseDynamicExecutionStatus.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseDynamicExecutionStatus instance itself + */ + public BaseResponseDynamicExecutionStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseDynamicExecutionStatus.data) && Objects.equals(this.message, baseResponseDynamicExecutionStatus.message) && Objects.equals(this.errors, baseResponseDynamicExecutionStatus.errors) && - Objects.equals(this.meta, baseResponseDynamicExecutionStatus.meta); + Objects.equals(this.meta, baseResponseDynamicExecutionStatus.meta)&& + Objects.equals(this.additionalProperties, baseResponseDynamicExecutionStatus.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseDynamicExecutionStatus is not found in the empty JSON string", BaseResponseDynamicExecutionStatus.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseDynamicExecutionStatus.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseDynamicExecutionStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseDynamicExecutionStatus value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseDynamicExecutionStatus value) thro public BaseResponseDynamicExecutionStatus 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 + BaseResponseDynamicExecutionStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java b/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java index cc5f1ff..3abbe04 100644 --- a/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseExternalResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseExternalResponse instance itself + */ + public BaseResponseExternalResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseExternalResponse.data) && Objects.equals(this.message, baseResponseExternalResponse.message) && Objects.equals(this.errors, baseResponseExternalResponse.errors) && - Objects.equals(this.meta, baseResponseExternalResponse.meta); + Objects.equals(this.meta, baseResponseExternalResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseExternalResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseExternalResponse is not found in the empty JSON string", BaseResponseExternalResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseExternalResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseExternalResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseExternalResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseExternalResponse value) throws IOE public BaseResponseExternalResponse 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 + BaseResponseExternalResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java index 518ec69..faf99ec 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionBlocksResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionBlocksResponse instance itself + */ + public BaseResponseFunctionBlocksResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionBlocksResponse.data) && Objects.equals(this.message, baseResponseFunctionBlocksResponse.message) && Objects.equals(this.errors, baseResponseFunctionBlocksResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionBlocksResponse.meta); + Objects.equals(this.meta, baseResponseFunctionBlocksResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionBlocksResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionBlocksResponse is not found in the empty JSON string", BaseResponseFunctionBlocksResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionBlocksResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionBlocksResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionBlocksResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionBlocksResponse value) thro public BaseResponseFunctionBlocksResponse 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 + BaseResponseFunctionBlocksResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java index 7fcde5a..c42f4cf 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionCapabilityResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionCapabilityResponse instance itself + */ + public BaseResponseFunctionCapabilityResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionCapabilityResponse.data) && Objects.equals(this.message, baseResponseFunctionCapabilityResponse.message) && Objects.equals(this.errors, baseResponseFunctionCapabilityResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionCapabilityResponse.meta); + Objects.equals(this.meta, baseResponseFunctionCapabilityResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionCapabilityResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionCapabilityResponse is not found in the empty JSON string", BaseResponseFunctionCapabilityResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionCapabilityResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionCapabilityResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionCapabilityResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionCapabilityResponse value) public BaseResponseFunctionCapabilityResponse 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 + BaseResponseFunctionCapabilityResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java index 7b55f77..3f9b0b8 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypes.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionDataTypes instance itself + */ + public BaseResponseFunctionDataTypes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionDataTypes.data) && Objects.equals(this.message, baseResponseFunctionDataTypes.message) && Objects.equals(this.errors, baseResponseFunctionDataTypes.errors) && - Objects.equals(this.meta, baseResponseFunctionDataTypes.meta); + Objects.equals(this.meta, baseResponseFunctionDataTypes.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionDataTypes.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypes is not found in the empty JSON string", BaseResponseFunctionDataTypes.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionDataTypes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionDataTypes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionDataTypes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionDataTypes value) throws IO public BaseResponseFunctionDataTypes 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 + BaseResponseFunctionDataTypes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java index 5f76d59..bb11676 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionDataTypesList.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionDataTypesList instance itself + */ + public BaseResponseFunctionDataTypesList putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionDataTypesList.data) && Objects.equals(this.message, baseResponseFunctionDataTypesList.message) && Objects.equals(this.errors, baseResponseFunctionDataTypesList.errors) && - Objects.equals(this.meta, baseResponseFunctionDataTypesList.meta); + Objects.equals(this.meta, baseResponseFunctionDataTypesList.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionDataTypesList.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionDataTypesList is not found in the empty JSON string", BaseResponseFunctionDataTypesList.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionDataTypesList.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionDataTypesList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionDataTypesList value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionDataTypesList value) throw public BaseResponseFunctionDataTypesList 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 + BaseResponseFunctionDataTypesList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java index 0c2c81e..6f68df0 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionSearchResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionSearchResponse instance itself + */ + public BaseResponseFunctionSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionSearchResponse.data) && Objects.equals(this.message, baseResponseFunctionSearchResponse.message) && Objects.equals(this.errors, baseResponseFunctionSearchResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionSearchResponse.meta); + Objects.equals(this.meta, baseResponseFunctionSearchResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionSearchResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionSearchResponse is not found in the empty JSON string", BaseResponseFunctionSearchResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionSearchResponse value) thro public BaseResponseFunctionSearchResponse 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 + BaseResponseFunctionSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java index 7ec6e5a..7bd5f4f 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionStringsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionStringsResponse instance itself + */ + public BaseResponseFunctionStringsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionStringsResponse.data) && Objects.equals(this.message, baseResponseFunctionStringsResponse.message) && Objects.equals(this.errors, baseResponseFunctionStringsResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionStringsResponse.meta); + Objects.equals(this.meta, baseResponseFunctionStringsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionStringsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionStringsResponse is not found in the empty JSON string", BaseResponseFunctionStringsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionStringsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionStringsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionStringsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionStringsResponse value) thr public BaseResponseFunctionStringsResponse 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 + BaseResponseFunctionStringsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java index 306d685..705a5c8 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionTaskResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionTaskResponse instance itself + */ + public BaseResponseFunctionTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionTaskResponse.data) && Objects.equals(this.message, baseResponseFunctionTaskResponse.message) && Objects.equals(this.errors, baseResponseFunctionTaskResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionTaskResponse.meta); + Objects.equals(this.meta, baseResponseFunctionTaskResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionTaskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionTaskResponse is not found in the empty JSON string", BaseResponseFunctionTaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionTaskResponse value) throws public BaseResponseFunctionTaskResponse 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 + BaseResponseFunctionTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java b/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java index 76574fd..553493a 100644 --- a/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseFunctionsDetailResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseFunctionsDetailResponse instance itself + */ + public BaseResponseFunctionsDetailResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseFunctionsDetailResponse.data) && Objects.equals(this.message, baseResponseFunctionsDetailResponse.message) && Objects.equals(this.errors, baseResponseFunctionsDetailResponse.errors) && - Objects.equals(this.meta, baseResponseFunctionsDetailResponse.meta); + Objects.equals(this.meta, baseResponseFunctionsDetailResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseFunctionsDetailResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseFunctionsDetailResponse is not found in the empty JSON string", BaseResponseFunctionsDetailResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseFunctionsDetailResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseFunctionsDetailResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseFunctionsDetailResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseFunctionsDetailResponse value) thr public BaseResponseFunctionsDetailResponse 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 + BaseResponseFunctionsDetailResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java b/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java index 7836bfd..b60e671 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/BaseResponseGenerateFunctionDataTypes.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGenerateFunctionDataTypes instance itself + */ + public BaseResponseGenerateFunctionDataTypes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGenerateFunctionDataTypes.data) && Objects.equals(this.message, baseResponseGenerateFunctionDataTypes.message) && Objects.equals(this.errors, baseResponseGenerateFunctionDataTypes.errors) && - Objects.equals(this.meta, baseResponseGenerateFunctionDataTypes.meta); + Objects.equals(this.meta, baseResponseGenerateFunctionDataTypes.meta)&& + Objects.equals(this.additionalProperties, baseResponseGenerateFunctionDataTypes.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGenerateFunctionDataTypes is not found in the empty JSON string", BaseResponseGenerateFunctionDataTypes.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGenerateFunctionDataTypes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGenerateFunctionDataTypes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGenerateFunctionDataTypes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGenerateFunctionDataTypes value) t public BaseResponseGenerateFunctionDataTypes 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 + BaseResponseGenerateFunctionDataTypes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java b/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java index f3b3667..7526558 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java +++ b/src/main/java/ai/reveng/model/BaseResponseGenerationStatusList.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGenerationStatusList instance itself + */ + public BaseResponseGenerationStatusList putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGenerationStatusList.data) && Objects.equals(this.message, baseResponseGenerationStatusList.message) && Objects.equals(this.errors, baseResponseGenerationStatusList.errors) && - Objects.equals(this.meta, baseResponseGenerationStatusList.meta); + Objects.equals(this.meta, baseResponseGenerationStatusList.meta)&& + Objects.equals(this.additionalProperties, baseResponseGenerationStatusList.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGenerationStatusList is not found in the empty JSON string", BaseResponseGenerationStatusList.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGenerationStatusList.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGenerationStatusList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGenerationStatusList value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGenerationStatusList value) throws public BaseResponseGenerationStatusList 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 + BaseResponseGenerationStatusList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationRatingResponse.java b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationRatingResponse.java index 80b599e..ef00520 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationRatingResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationRatingResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGetAiDecompilationRatingResponse instance itself + */ + public BaseResponseGetAiDecompilationRatingResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGetAiDecompilationRatingResponse.data) && Objects.equals(this.message, baseResponseGetAiDecompilationRatingResponse.message) && Objects.equals(this.errors, baseResponseGetAiDecompilationRatingResponse.errors) && - Objects.equals(this.meta, baseResponseGetAiDecompilationRatingResponse.meta); + Objects.equals(this.meta, baseResponseGetAiDecompilationRatingResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseGetAiDecompilationRatingResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetAiDecompilationRatingResponse is not found in the empty JSON string", BaseResponseGetAiDecompilationRatingResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGetAiDecompilationRatingResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGetAiDecompilationRatingResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGetAiDecompilationRatingResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGetAiDecompilationRatingResponse v public BaseResponseGetAiDecompilationRatingResponse 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 + BaseResponseGetAiDecompilationRatingResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java index d6799cc..8269dbd 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetAiDecompilationTask.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGetAiDecompilationTask instance itself + */ + public BaseResponseGetAiDecompilationTask putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGetAiDecompilationTask.data) && Objects.equals(this.message, baseResponseGetAiDecompilationTask.message) && Objects.equals(this.errors, baseResponseGetAiDecompilationTask.errors) && - Objects.equals(this.meta, baseResponseGetAiDecompilationTask.meta); + Objects.equals(this.meta, baseResponseGetAiDecompilationTask.meta)&& + Objects.equals(this.additionalProperties, baseResponseGetAiDecompilationTask.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetAiDecompilationTask is not found in the empty JSON string", BaseResponseGetAiDecompilationTask.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGetAiDecompilationTask.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGetAiDecompilationTask` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGetAiDecompilationTask value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGetAiDecompilationTask value) thro public BaseResponseGetAiDecompilationTask 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 + BaseResponseGetAiDecompilationTask instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java b/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java index 2682428..96c7320 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetPublicUserResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGetPublicUserResponse instance itself + */ + public BaseResponseGetPublicUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGetPublicUserResponse.data) && Objects.equals(this.message, baseResponseGetPublicUserResponse.message) && Objects.equals(this.errors, baseResponseGetPublicUserResponse.errors) && - Objects.equals(this.meta, baseResponseGetPublicUserResponse.meta); + Objects.equals(this.meta, baseResponseGetPublicUserResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseGetPublicUserResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetPublicUserResponse is not found in the empty JSON string", BaseResponseGetPublicUserResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGetPublicUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGetPublicUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGetPublicUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGetPublicUserResponse value) throw public BaseResponseGetPublicUserResponse 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 + BaseResponseGetPublicUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseGetUserResponse.java b/src/main/java/ai/reveng/model/BaseResponseGetUserResponse.java index 3292174..ee3cf3b 100644 --- a/src/main/java/ai/reveng/model/BaseResponseGetUserResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseGetUserResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseGetUserResponse instance itself + */ + public BaseResponseGetUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseGetUserResponse.data) && Objects.equals(this.message, baseResponseGetUserResponse.message) && Objects.equals(this.errors, baseResponseGetUserResponse.errors) && - Objects.equals(this.meta, baseResponseGetUserResponse.meta); + Objects.equals(this.meta, baseResponseGetUserResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseGetUserResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseGetUserResponse is not found in the empty JSON string", BaseResponseGetUserResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseGetUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseGetUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseGetUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseGetUserResponse value) throws IOEx public BaseResponseGetUserResponse 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 + BaseResponseGetUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java b/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java index 93f9e9f..5d649d4 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java +++ b/src/main/java/ai/reveng/model/BaseResponseListCollectionResults.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListCollectionResults instance itself + */ + public BaseResponseListCollectionResults putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListCollectionResults.data) && Objects.equals(this.message, baseResponseListCollectionResults.message) && Objects.equals(this.errors, baseResponseListCollectionResults.errors) && - Objects.equals(this.meta, baseResponseListCollectionResults.meta); + Objects.equals(this.meta, baseResponseListCollectionResults.meta)&& + Objects.equals(this.additionalProperties, baseResponseListCollectionResults.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListCollectionResults is not found in the empty JSON string", BaseResponseListCollectionResults.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListCollectionResults.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListCollectionResults` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListCollectionResults value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseListCollectionResults value) throw public BaseResponseListCollectionResults 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 + BaseResponseListCollectionResults instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java b/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java index 086187d..ca78a05 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListCommentResponse.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListCommentResponse instance itself + */ + public BaseResponseListCommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListCommentResponse.data) && Objects.equals(this.message, baseResponseListCommentResponse.message) && Objects.equals(this.errors, baseResponseListCommentResponse.errors) && - Objects.equals(this.meta, baseResponseListCommentResponse.meta); + Objects.equals(this.meta, baseResponseListCommentResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseListCommentResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListCommentResponse is not found in the empty JSON string", BaseResponseListCommentResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListCommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListCommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListCommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListCommentResponse value) throws public BaseResponseListCommentResponse 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 + BaseResponseListCommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java index 00e9c32..71405ce 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java +++ b/src/main/java/ai/reveng/model/BaseResponseListDieMatch.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListDieMatch instance itself + */ + public BaseResponseListDieMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListDieMatch.data) && Objects.equals(this.message, baseResponseListDieMatch.message) && Objects.equals(this.errors, baseResponseListDieMatch.errors) && - Objects.equals(this.meta, baseResponseListDieMatch.meta); + Objects.equals(this.meta, baseResponseListDieMatch.meta)&& + Objects.equals(this.additionalProperties, baseResponseListDieMatch.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListDieMatch is not found in the empty JSON string", BaseResponseListDieMatch.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListDieMatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListDieMatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListDieMatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListDieMatch value) throws IOExcep public BaseResponseListDieMatch 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 + BaseResponseListDieMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListFunctionBoxPlotConfidence.java b/src/main/java/ai/reveng/model/BaseResponseListFunctionBoxPlotConfidence.java index 8dcb079..85a6f59 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListFunctionBoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/BaseResponseListFunctionBoxPlotConfidence.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListFunctionBoxPlotConfidence instance itself + */ + public BaseResponseListFunctionBoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListFunctionBoxPlotConfidence.data) && Objects.equals(this.message, baseResponseListFunctionBoxPlotConfidence.message) && Objects.equals(this.errors, baseResponseListFunctionBoxPlotConfidence.errors) && - Objects.equals(this.meta, baseResponseListFunctionBoxPlotConfidence.meta); + Objects.equals(this.meta, baseResponseListFunctionBoxPlotConfidence.meta)&& + Objects.equals(this.additionalProperties, baseResponseListFunctionBoxPlotConfidence.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListFunctionBoxPlotConfidence is not found in the empty JSON string", BaseResponseListFunctionBoxPlotConfidence.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListFunctionBoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListFunctionBoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListFunctionBoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListFunctionBoxPlotConfidence valu public BaseResponseListFunctionBoxPlotConfidence 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 + BaseResponseListFunctionBoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java b/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java index 51bc904..5ec665d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java +++ b/src/main/java/ai/reveng/model/BaseResponseListFunctionNameHistory.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListFunctionNameHistory instance itself + */ + public BaseResponseListFunctionNameHistory putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListFunctionNameHistory.data) && Objects.equals(this.message, baseResponseListFunctionNameHistory.message) && Objects.equals(this.errors, baseResponseListFunctionNameHistory.errors) && - Objects.equals(this.meta, baseResponseListFunctionNameHistory.meta); + Objects.equals(this.meta, baseResponseListFunctionNameHistory.meta)&& + Objects.equals(this.additionalProperties, baseResponseListFunctionNameHistory.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListFunctionNameHistory is not found in the empty JSON string", BaseResponseListFunctionNameHistory.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListFunctionNameHistory.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListFunctionNameHistory` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListFunctionNameHistory value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListFunctionNameHistory value) thr public BaseResponseListFunctionNameHistory 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 + BaseResponseListFunctionNameHistory instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListSBOM.java b/src/main/java/ai/reveng/model/BaseResponseListSBOM.java index c9cf511..83be98e 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListSBOM.java +++ b/src/main/java/ai/reveng/model/BaseResponseListSBOM.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListSBOM instance itself + */ + public BaseResponseListSBOM putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListSBOM.data) && Objects.equals(this.message, baseResponseListSBOM.message) && Objects.equals(this.errors, baseResponseListSBOM.errors) && - Objects.equals(this.meta, baseResponseListSBOM.meta); + Objects.equals(this.meta, baseResponseListSBOM.meta)&& + Objects.equals(this.additionalProperties, baseResponseListSBOM.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListSBOM is not found in the empty JSON string", BaseResponseListSBOM.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListSBOM.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListSBOM` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListSBOM value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListSBOM value) throws IOException public BaseResponseListSBOM 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 + BaseResponseListSBOM instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListSimilarFunctionsResponse.java b/src/main/java/ai/reveng/model/BaseResponseListSimilarFunctionsResponse.java index 45ffa40..39589d6 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListSimilarFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListSimilarFunctionsResponse.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListSimilarFunctionsResponse instance itself + */ + public BaseResponseListSimilarFunctionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListSimilarFunctionsResponse.data) && Objects.equals(this.message, baseResponseListSimilarFunctionsResponse.message) && Objects.equals(this.errors, baseResponseListSimilarFunctionsResponse.errors) && - Objects.equals(this.meta, baseResponseListSimilarFunctionsResponse.meta); + Objects.equals(this.meta, baseResponseListSimilarFunctionsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseListSimilarFunctionsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListSimilarFunctionsResponse is not found in the empty JSON string", BaseResponseListSimilarFunctionsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListSimilarFunctionsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListSimilarFunctionsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListSimilarFunctionsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListSimilarFunctionsResponse value public BaseResponseListSimilarFunctionsResponse 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 + BaseResponseListSimilarFunctionsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListTagOriginBoxPlotConfidence.java b/src/main/java/ai/reveng/model/BaseResponseListTagOriginBoxPlotConfidence.java index 68c18c5..7667f01 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListTagOriginBoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/BaseResponseListTagOriginBoxPlotConfidence.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListTagOriginBoxPlotConfidence instance itself + */ + public BaseResponseListTagOriginBoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListTagOriginBoxPlotConfidence.data) && Objects.equals(this.message, baseResponseListTagOriginBoxPlotConfidence.message) && Objects.equals(this.errors, baseResponseListTagOriginBoxPlotConfidence.errors) && - Objects.equals(this.meta, baseResponseListTagOriginBoxPlotConfidence.meta); + Objects.equals(this.meta, baseResponseListTagOriginBoxPlotConfidence.meta)&& + Objects.equals(this.additionalProperties, baseResponseListTagOriginBoxPlotConfidence.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListTagOriginBoxPlotConfidence is not found in the empty JSON string", BaseResponseListTagOriginBoxPlotConfidence.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListTagOriginBoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListTagOriginBoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListTagOriginBoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListTagOriginBoxPlotConfidence val public BaseResponseListTagOriginBoxPlotConfidence 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 + BaseResponseListTagOriginBoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java b/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java index 2fb0f97..8fa08f0 100644 --- a/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseListUserActivityResponse.java @@ -195,6 +195,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseListUserActivityResponse instance itself + */ + public BaseResponseListUserActivityResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -210,7 +254,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseListUserActivityResponse.data) && Objects.equals(this.message, baseResponseListUserActivityResponse.message) && Objects.equals(this.errors, baseResponseListUserActivityResponse.errors) && - Objects.equals(this.meta, baseResponseListUserActivityResponse.meta); + Objects.equals(this.meta, baseResponseListUserActivityResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseListUserActivityResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -219,7 +264,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -238,6 +283,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -277,14 +323,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseListUserActivityResponse is not found in the empty JSON string", BaseResponseListUserActivityResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseListUserActivityResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseListUserActivityResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); @@ -338,6 +376,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseListUserActivityResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -345,7 +405,28 @@ public void write(JsonWriter out, BaseResponseListUserActivityResponse value) th public BaseResponseListUserActivityResponse 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 + BaseResponseListUserActivityResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseLoginResponse.java b/src/main/java/ai/reveng/model/BaseResponseLoginResponse.java index a8f60c4..58d2b9d 100644 --- a/src/main/java/ai/reveng/model/BaseResponseLoginResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseLoginResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseLoginResponse instance itself + */ + public BaseResponseLoginResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseLoginResponse.data) && Objects.equals(this.message, baseResponseLoginResponse.message) && Objects.equals(this.errors, baseResponseLoginResponse.errors) && - Objects.equals(this.meta, baseResponseLoginResponse.meta); + Objects.equals(this.meta, baseResponseLoginResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseLoginResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseLoginResponse is not found in the empty JSON string", BaseResponseLoginResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseLoginResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseLoginResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseLoginResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseLoginResponse value) throws IOExce public BaseResponseLoginResponse 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 + BaseResponseLoginResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseLogs.java b/src/main/java/ai/reveng/model/BaseResponseLogs.java index 4f5fe2a..368045c 100644 --- a/src/main/java/ai/reveng/model/BaseResponseLogs.java +++ b/src/main/java/ai/reveng/model/BaseResponseLogs.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseLogs instance itself + */ + public BaseResponseLogs putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseLogs.data) && Objects.equals(this.message, baseResponseLogs.message) && Objects.equals(this.errors, baseResponseLogs.errors) && - Objects.equals(this.meta, baseResponseLogs.meta); + Objects.equals(this.meta, baseResponseLogs.meta)&& + Objects.equals(this.additionalProperties, baseResponseLogs.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseLogs is not found in the empty JSON string", BaseResponseLogs.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseLogs.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseLogs` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseLogs value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseLogs value) throws IOException { public BaseResponseLogs 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 + BaseResponseLogs instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java b/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java index 071cbfa..15c6c70 100644 --- a/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseModelsResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseModelsResponse instance itself + */ + public BaseResponseModelsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseModelsResponse.data) && Objects.equals(this.message, baseResponseModelsResponse.message) && Objects.equals(this.errors, baseResponseModelsResponse.errors) && - Objects.equals(this.meta, baseResponseModelsResponse.meta); + Objects.equals(this.meta, baseResponseModelsResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseModelsResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseModelsResponse is not found in the empty JSON string", BaseResponseModelsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseModelsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseModelsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseModelsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseModelsResponse value) throws IOExc public BaseResponseModelsResponse 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 + BaseResponseModelsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseNearestNeighborAnalysis.java b/src/main/java/ai/reveng/model/BaseResponseNearestNeighborAnalysis.java index 24e3302..01550d2 100644 --- a/src/main/java/ai/reveng/model/BaseResponseNearestNeighborAnalysis.java +++ b/src/main/java/ai/reveng/model/BaseResponseNearestNeighborAnalysis.java @@ -197,6 +197,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseNearestNeighborAnalysis instance itself + */ + public BaseResponseNearestNeighborAnalysis putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -212,7 +256,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseNearestNeighborAnalysis.data) && Objects.equals(this.message, baseResponseNearestNeighborAnalysis.message) && Objects.equals(this.errors, baseResponseNearestNeighborAnalysis.errors) && - Objects.equals(this.meta, baseResponseNearestNeighborAnalysis.meta); + Objects.equals(this.meta, baseResponseNearestNeighborAnalysis.meta)&& + Objects.equals(this.additionalProperties, baseResponseNearestNeighborAnalysis.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -221,7 +266,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -240,6 +285,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -279,14 +325,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseNearestNeighborAnalysis is not found in the empty JSON string", BaseResponseNearestNeighborAnalysis.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseNearestNeighborAnalysis.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseNearestNeighborAnalysis` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); @@ -326,6 +364,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseNearestNeighborAnalysis value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -333,7 +393,28 @@ public void write(JsonWriter out, BaseResponseNearestNeighborAnalysis value) thr public BaseResponseNearestNeighborAnalysis 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 + BaseResponseNearestNeighborAnalysis instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseNetworkOverviewResponse.java b/src/main/java/ai/reveng/model/BaseResponseNetworkOverviewResponse.java index 341eaa5..ed9053e 100644 --- a/src/main/java/ai/reveng/model/BaseResponseNetworkOverviewResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseNetworkOverviewResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseNetworkOverviewResponse instance itself + */ + public BaseResponseNetworkOverviewResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseNetworkOverviewResponse.data) && Objects.equals(this.message, baseResponseNetworkOverviewResponse.message) && Objects.equals(this.errors, baseResponseNetworkOverviewResponse.errors) && - Objects.equals(this.meta, baseResponseNetworkOverviewResponse.meta); + Objects.equals(this.meta, baseResponseNetworkOverviewResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseNetworkOverviewResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseNetworkOverviewResponse is not found in the empty JSON string", BaseResponseNetworkOverviewResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseNetworkOverviewResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseNetworkOverviewResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseNetworkOverviewResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseNetworkOverviewResponse value) thr public BaseResponseNetworkOverviewResponse 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 + BaseResponseNetworkOverviewResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseParams.java b/src/main/java/ai/reveng/model/BaseResponseParams.java index 5f049c7..74533aa 100644 --- a/src/main/java/ai/reveng/model/BaseResponseParams.java +++ b/src/main/java/ai/reveng/model/BaseResponseParams.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseParams instance itself + */ + public BaseResponseParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseParams.data) && Objects.equals(this.message, baseResponseParams.message) && Objects.equals(this.errors, baseResponseParams.errors) && - Objects.equals(this.meta, baseResponseParams.meta); + Objects.equals(this.meta, baseResponseParams.meta)&& + Objects.equals(this.additionalProperties, baseResponseParams.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseParams is not found in the empty JSON string", BaseResponseParams.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseParams value) throws IOException { public BaseResponseParams 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 + BaseResponseParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseProcessDumps.java b/src/main/java/ai/reveng/model/BaseResponseProcessDumps.java index 55cf5e9..395f68a 100644 --- a/src/main/java/ai/reveng/model/BaseResponseProcessDumps.java +++ b/src/main/java/ai/reveng/model/BaseResponseProcessDumps.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseProcessDumps instance itself + */ + public BaseResponseProcessDumps putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseProcessDumps.data) && Objects.equals(this.message, baseResponseProcessDumps.message) && Objects.equals(this.errors, baseResponseProcessDumps.errors) && - Objects.equals(this.meta, baseResponseProcessDumps.meta); + Objects.equals(this.meta, baseResponseProcessDumps.meta)&& + Objects.equals(this.additionalProperties, baseResponseProcessDumps.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseProcessDumps is not found in the empty JSON string", BaseResponseProcessDumps.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseProcessDumps.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseProcessDumps` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseProcessDumps value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseProcessDumps value) throws IOExcep public BaseResponseProcessDumps 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 + BaseResponseProcessDumps instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseProcessRegistry.java b/src/main/java/ai/reveng/model/BaseResponseProcessRegistry.java index 714d151..e399fcb 100644 --- a/src/main/java/ai/reveng/model/BaseResponseProcessRegistry.java +++ b/src/main/java/ai/reveng/model/BaseResponseProcessRegistry.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseProcessRegistry instance itself + */ + public BaseResponseProcessRegistry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseProcessRegistry.data) && Objects.equals(this.message, baseResponseProcessRegistry.message) && Objects.equals(this.errors, baseResponseProcessRegistry.errors) && - Objects.equals(this.meta, baseResponseProcessRegistry.meta); + Objects.equals(this.meta, baseResponseProcessRegistry.meta)&& + Objects.equals(this.additionalProperties, baseResponseProcessRegistry.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseProcessRegistry is not found in the empty JSON string", BaseResponseProcessRegistry.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseProcessRegistry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseProcessRegistry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseProcessRegistry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseProcessRegistry value) throws IOEx public BaseResponseProcessRegistry 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 + BaseResponseProcessRegistry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseProcessTree.java b/src/main/java/ai/reveng/model/BaseResponseProcessTree.java index 1c71836..0022833 100644 --- a/src/main/java/ai/reveng/model/BaseResponseProcessTree.java +++ b/src/main/java/ai/reveng/model/BaseResponseProcessTree.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseProcessTree instance itself + */ + public BaseResponseProcessTree putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseProcessTree.data) && Objects.equals(this.message, baseResponseProcessTree.message) && Objects.equals(this.errors, baseResponseProcessTree.errors) && - Objects.equals(this.meta, baseResponseProcessTree.meta); + Objects.equals(this.meta, baseResponseProcessTree.meta)&& + Objects.equals(this.additionalProperties, baseResponseProcessTree.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseProcessTree is not found in the empty JSON string", BaseResponseProcessTree.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseProcessTree.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseProcessTree` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseProcessTree value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseProcessTree value) throws IOExcept public BaseResponseProcessTree 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 + BaseResponseProcessTree instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseQueuedSecurityChecksTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseQueuedSecurityChecksTaskResponse.java index 0730b8e..0582c84 100644 --- a/src/main/java/ai/reveng/model/BaseResponseQueuedSecurityChecksTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseQueuedSecurityChecksTaskResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseQueuedSecurityChecksTaskResponse instance itself + */ + public BaseResponseQueuedSecurityChecksTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseQueuedSecurityChecksTaskResponse.data) && Objects.equals(this.message, baseResponseQueuedSecurityChecksTaskResponse.message) && Objects.equals(this.errors, baseResponseQueuedSecurityChecksTaskResponse.errors) && - Objects.equals(this.meta, baseResponseQueuedSecurityChecksTaskResponse.meta); + Objects.equals(this.meta, baseResponseQueuedSecurityChecksTaskResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseQueuedSecurityChecksTaskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseQueuedSecurityChecksTaskResponse is not found in the empty JSON string", BaseResponseQueuedSecurityChecksTaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseQueuedSecurityChecksTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseQueuedSecurityChecksTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseQueuedSecurityChecksTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseQueuedSecurityChecksTaskResponse v public BaseResponseQueuedSecurityChecksTaskResponse 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 + BaseResponseQueuedSecurityChecksTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseRecent.java b/src/main/java/ai/reveng/model/BaseResponseRecent.java index b1c828e..c2c2297 100644 --- a/src/main/java/ai/reveng/model/BaseResponseRecent.java +++ b/src/main/java/ai/reveng/model/BaseResponseRecent.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseRecent instance itself + */ + public BaseResponseRecent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseRecent.data) && Objects.equals(this.message, baseResponseRecent.message) && Objects.equals(this.errors, baseResponseRecent.errors) && - Objects.equals(this.meta, baseResponseRecent.meta); + Objects.equals(this.meta, baseResponseRecent.meta)&& + Objects.equals(this.additionalProperties, baseResponseRecent.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseRecent is not found in the empty JSON string", BaseResponseRecent.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseRecent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseRecent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseRecent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseRecent value) throws IOException { public BaseResponseRecent 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 + BaseResponseRecent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseSecurityChecksResponse.java b/src/main/java/ai/reveng/model/BaseResponseSecurityChecksResponse.java index e77eb34..10d8a1f 100644 --- a/src/main/java/ai/reveng/model/BaseResponseSecurityChecksResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseSecurityChecksResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseSecurityChecksResponse instance itself + */ + public BaseResponseSecurityChecksResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseSecurityChecksResponse.data) && Objects.equals(this.message, baseResponseSecurityChecksResponse.message) && Objects.equals(this.errors, baseResponseSecurityChecksResponse.errors) && - Objects.equals(this.meta, baseResponseSecurityChecksResponse.meta); + Objects.equals(this.meta, baseResponseSecurityChecksResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseSecurityChecksResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseSecurityChecksResponse is not found in the empty JSON string", BaseResponseSecurityChecksResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseSecurityChecksResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseSecurityChecksResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseSecurityChecksResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseSecurityChecksResponse value) thro public BaseResponseSecurityChecksResponse 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 + BaseResponseSecurityChecksResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseStatus.java b/src/main/java/ai/reveng/model/BaseResponseStatus.java index 5373971..e2a6c67 100644 --- a/src/main/java/ai/reveng/model/BaseResponseStatus.java +++ b/src/main/java/ai/reveng/model/BaseResponseStatus.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseStatus instance itself + */ + public BaseResponseStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseStatus.data) && Objects.equals(this.message, baseResponseStatus.message) && Objects.equals(this.errors, baseResponseStatus.errors) && - Objects.equals(this.meta, baseResponseStatus.meta); + Objects.equals(this.meta, baseResponseStatus.meta)&& + Objects.equals(this.additionalProperties, baseResponseStatus.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseStatus is not found in the empty JSON string", BaseResponseStatus.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseStatus.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseStatus value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseStatus value) throws IOException { public BaseResponseStatus 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 + BaseResponseStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseStr.java b/src/main/java/ai/reveng/model/BaseResponseStr.java index 3d26ebb..7f05af0 100644 --- a/src/main/java/ai/reveng/model/BaseResponseStr.java +++ b/src/main/java/ai/reveng/model/BaseResponseStr.java @@ -186,6 +186,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseStr instance itself + */ + public BaseResponseStr putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -201,7 +245,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseStr.data) && Objects.equals(this.message, baseResponseStr.message) && Objects.equals(this.errors, baseResponseStr.errors) && - Objects.equals(this.meta, baseResponseStr.meta); + Objects.equals(this.meta, baseResponseStr.meta)&& + Objects.equals(this.additionalProperties, baseResponseStr.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -210,7 +255,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -229,6 +274,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseStr is not found in the empty JSON string", BaseResponseStr.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseStr.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseStr` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) && !jsonObj.get("data").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be a primitive type in the JSON string but got `%s`", jsonObj.get("data").toString())); @@ -318,6 +356,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseStr value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -325,7 +385,28 @@ public void write(JsonWriter out, BaseResponseStr value) throws IOException { public BaseResponseStr 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 + BaseResponseStr instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseTTPS.java b/src/main/java/ai/reveng/model/BaseResponseTTPS.java index 973b444..563fe20 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTTPS.java +++ b/src/main/java/ai/reveng/model/BaseResponseTTPS.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseTTPS instance itself + */ + public BaseResponseTTPS putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseTTPS.data) && Objects.equals(this.message, baseResponseTTPS.message) && Objects.equals(this.errors, baseResponseTTPS.errors) && - Objects.equals(this.meta, baseResponseTTPS.meta); + Objects.equals(this.meta, baseResponseTTPS.meta)&& + Objects.equals(this.additionalProperties, baseResponseTTPS.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTTPS is not found in the empty JSON string", BaseResponseTTPS.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseTTPS.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseTTPS` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseTTPS value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseTTPS value) throws IOException { public BaseResponseTTPS 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 + BaseResponseTTPS instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java b/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java index 6b03b48..27ee3a7 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTagSearchResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseTagSearchResponse instance itself + */ + public BaseResponseTagSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseTagSearchResponse.data) && Objects.equals(this.message, baseResponseTagSearchResponse.message) && Objects.equals(this.errors, baseResponseTagSearchResponse.errors) && - Objects.equals(this.meta, baseResponseTagSearchResponse.meta); + Objects.equals(this.meta, baseResponseTagSearchResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseTagSearchResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTagSearchResponse is not found in the empty JSON string", BaseResponseTagSearchResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseTagSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseTagSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseTagSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseTagSearchResponse value) throws IO public BaseResponseTagSearchResponse 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 + BaseResponseTagSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java b/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java index f55b446..a6a5305 100644 --- a/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseTaskResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseTaskResponse instance itself + */ + public BaseResponseTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseTaskResponse.data) && Objects.equals(this.message, baseResponseTaskResponse.message) && Objects.equals(this.errors, baseResponseTaskResponse.errors) && - Objects.equals(this.meta, baseResponseTaskResponse.meta); + Objects.equals(this.meta, baseResponseTaskResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseTaskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseTaskResponse is not found in the empty JSON string", BaseResponseTaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseTaskResponse value) throws IOExcep public BaseResponseTaskResponse 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 + BaseResponseTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java b/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java index 876d57d..13cde3f 100644 --- a/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java +++ b/src/main/java/ai/reveng/model/BaseResponseUploadResponse.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseUploadResponse instance itself + */ + public BaseResponseUploadResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseUploadResponse.data) && Objects.equals(this.message, baseResponseUploadResponse.message) && Objects.equals(this.errors, baseResponseUploadResponse.errors) && - Objects.equals(this.meta, baseResponseUploadResponse.meta); + Objects.equals(this.meta, baseResponseUploadResponse.meta)&& + Objects.equals(this.additionalProperties, baseResponseUploadResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseUploadResponse is not found in the empty JSON string", BaseResponseUploadResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseUploadResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseUploadResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseUploadResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseUploadResponse value) throws IOExc public BaseResponseUploadResponse 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 + BaseResponseUploadResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java b/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java index 379d781..c84c118 100644 --- a/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java +++ b/src/main/java/ai/reveng/model/BaseResponseVulnerabilities.java @@ -187,6 +187,50 @@ public void setMeta(@javax.annotation.Nullable MetaModel meta) { this.meta = meta; } + /** + * 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 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 BaseResponseVulnerabilities instance itself + */ + public BaseResponseVulnerabilities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -202,7 +246,8 @@ public boolean equals(Object o) { Objects.equals(this.data, baseResponseVulnerabilities.data) && Objects.equals(this.message, baseResponseVulnerabilities.message) && Objects.equals(this.errors, baseResponseVulnerabilities.errors) && - Objects.equals(this.meta, baseResponseVulnerabilities.meta); + Objects.equals(this.meta, baseResponseVulnerabilities.meta)&& + Objects.equals(this.additionalProperties, baseResponseVulnerabilities.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -211,7 +256,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, data, message, errors, meta); + return Objects.hash(status, data, message, errors, meta, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -230,6 +275,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BaseResponseVulnerabilities is not found in the empty JSON string", BaseResponseVulnerabilities.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BaseResponseVulnerabilities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BaseResponseVulnerabilities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `data` if (jsonObj.get("data") != null && !jsonObj.get("data").isJsonNull()) { @@ -320,6 +358,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BaseResponseVulnerabilities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -327,7 +387,28 @@ public void write(JsonWriter out, BaseResponseVulnerabilities value) throws IOEx public BaseResponseVulnerabilities 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 + BaseResponseVulnerabilities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Basic.java b/src/main/java/ai/reveng/model/Basic.java index 300d767..9f3b929 100644 --- a/src/main/java/ai/reveng/model/Basic.java +++ b/src/main/java/ai/reveng/model/Basic.java @@ -342,6 +342,50 @@ public void setBaseAddress(@javax.annotation.Nullable Integer baseAddress) { this.baseAddress = baseAddress; } + /** + * 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 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 Basic instance itself + */ + public Basic putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -364,12 +408,13 @@ public boolean equals(Object o) { Objects.equals(this.debug, basic.debug) && Objects.equals(this.functionCount, basic.functionCount) && Objects.equals(this.isAdvanced, basic.isAdvanced) && - Objects.equals(this.baseAddress, basic.baseAddress); + Objects.equals(this.baseAddress, basic.baseAddress)&& + Objects.equals(this.additionalProperties, basic.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryName, binarySize, creation, sha256Hash, modelName, ownerUsername, analysisScope, isOwner, debug, functionCount, isAdvanced, baseAddress); + return Objects.hash(binaryName, binarySize, creation, sha256Hash, modelName, ownerUsername, analysisScope, isOwner, debug, functionCount, isAdvanced, baseAddress, additionalProperties); } @Override @@ -388,6 +433,7 @@ public String toString() { sb.append(" functionCount: ").append(toIndentedString(functionCount)).append("\n"); sb.append(" isAdvanced: ").append(toIndentedString(isAdvanced)).append("\n"); sb.append(" baseAddress: ").append(toIndentedString(baseAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -428,14 +474,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Basic.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Basic` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Basic.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -475,6 +513,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Basic value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -482,7 +542,28 @@ public void write(JsonWriter out, Basic value) throws IOException { public Basic 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 + Basic instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java b/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java index 3c6ec76..10feedb 100644 --- a/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java +++ b/src/main/java/ai/reveng/model/BinaryAdditionalDetailsDataResponse.java @@ -129,6 +129,50 @@ public void setElf(@javax.annotation.Nullable ELFModel elf) { this.elf = elf; } + /** + * 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 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 BinaryAdditionalDetailsDataResponse instance itself + */ + public BinaryAdditionalDetailsDataResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -142,7 +186,8 @@ public boolean equals(Object o) { BinaryAdditionalDetailsDataResponse binaryAdditionalDetailsDataResponse = (BinaryAdditionalDetailsDataResponse) o; return Objects.equals(this._file, binaryAdditionalDetailsDataResponse._file) && Objects.equals(this.pe, binaryAdditionalDetailsDataResponse.pe) && - Objects.equals(this.elf, binaryAdditionalDetailsDataResponse.elf); + Objects.equals(this.elf, binaryAdditionalDetailsDataResponse.elf)&& + Objects.equals(this.additionalProperties, binaryAdditionalDetailsDataResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -151,7 +196,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(_file, pe, elf); + return Objects.hash(_file, pe, elf, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -168,6 +213,7 @@ public String toString() { sb.append(" _file: ").append(toIndentedString(_file)).append("\n"); sb.append(" pe: ").append(toIndentedString(pe)).append("\n"); sb.append(" elf: ").append(toIndentedString(elf)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -208,14 +254,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryAdditionalDetailsDataResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryAdditionalDetailsDataResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryAdditionalDetailsDataResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -250,6 +288,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryAdditionalDetailsDataResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -257,7 +317,28 @@ public void write(JsonWriter out, BinaryAdditionalDetailsDataResponse value) thr public BinaryAdditionalDetailsDataResponse 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 + BinaryAdditionalDetailsDataResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java b/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java index 6c8e64d..73f21fe 100644 --- a/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java +++ b/src/main/java/ai/reveng/model/BinaryAdditionalResponse.java @@ -128,6 +128,50 @@ public void setCreation(@javax.annotation.Nullable OffsetDateTime creation) { this.creation = creation; } + /** + * 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 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 BinaryAdditionalResponse instance itself + */ + public BinaryAdditionalResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -141,7 +185,8 @@ public boolean equals(Object o) { BinaryAdditionalResponse binaryAdditionalResponse = (BinaryAdditionalResponse) o; return Objects.equals(this.binaryId, binaryAdditionalResponse.binaryId) && Objects.equals(this.details, binaryAdditionalResponse.details) && - Objects.equals(this.creation, binaryAdditionalResponse.creation); + Objects.equals(this.creation, binaryAdditionalResponse.creation)&& + Objects.equals(this.additionalProperties, binaryAdditionalResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -150,7 +195,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(binaryId, details, creation); + return Objects.hash(binaryId, details, creation, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -167,6 +212,7 @@ public String toString() { sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" details: ").append(toIndentedString(details)).append("\n"); sb.append(" creation: ").append(toIndentedString(creation)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -207,14 +253,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryAdditionalResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryAdditionalResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryAdditionalResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -241,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryAdditionalResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -248,7 +308,28 @@ public void write(JsonWriter out, BinaryAdditionalResponse value) throws IOExcep public BinaryAdditionalResponse 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 + BinaryAdditionalResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryAnnForm.java b/src/main/java/ai/reveng/model/BinaryAnnForm.java index 7b02aca..a07e523 100644 --- a/src/main/java/ai/reveng/model/BinaryAnnForm.java +++ b/src/main/java/ai/reveng/model/BinaryAnnForm.java @@ -172,6 +172,50 @@ public void setBinaryIds(@javax.annotation.Nullable List binaryIds) { this.binaryIds = binaryIds; } + /** + * 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 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 BinaryAnnForm instance itself + */ + public BinaryAnnForm putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -186,12 +230,13 @@ public boolean equals(Object o) { return Objects.equals(this.confidence, binaryAnnForm.confidence) && Objects.equals(this.nns, binaryAnnForm.nns) && Objects.equals(this.collectionIds, binaryAnnForm.collectionIds) && - Objects.equals(this.binaryIds, binaryAnnForm.binaryIds); + Objects.equals(this.binaryIds, binaryAnnForm.binaryIds)&& + Objects.equals(this.additionalProperties, binaryAnnForm.additionalProperties); } @Override public int hashCode() { - return Objects.hash(confidence, nns, collectionIds, binaryIds); + return Objects.hash(confidence, nns, collectionIds, binaryIds, additionalProperties); } @Override @@ -202,6 +247,7 @@ public String toString() { sb.append(" nns: ").append(toIndentedString(nns)).append("\n"); sb.append(" collectionIds: ").append(toIndentedString(collectionIds)).append("\n"); sb.append(" binaryIds: ").append(toIndentedString(binaryIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -241,14 +287,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryAnnForm is not found in the empty JSON string", BinaryAnnForm.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryAnnForm.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryAnnForm` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("collection_ids") != null && !jsonObj.get("collection_ids").isJsonNull() && !jsonObj.get("collection_ids").isJsonArray()) { @@ -275,6 +313,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryAnnForm value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -282,7 +342,28 @@ public void write(JsonWriter out, BinaryAnnForm value) throws IOException { public BinaryAnnForm 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 + BinaryAnnForm instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryAnnListResponse.java b/src/main/java/ai/reveng/model/BinaryAnnListResponse.java index b5adc62..7d2a146 100644 --- a/src/main/java/ai/reveng/model/BinaryAnnListResponse.java +++ b/src/main/java/ai/reveng/model/BinaryAnnListResponse.java @@ -88,6 +88,50 @@ public void setList(@javax.annotation.Nonnull List _lis this._list = _list; } + /** + * 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 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 BinaryAnnListResponse instance itself + */ + public BinaryAnnListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } BinaryAnnListResponse binaryAnnListResponse = (BinaryAnnListResponse) o; - return Objects.equals(this._list, binaryAnnListResponse._list); + return Objects.equals(this._list, binaryAnnListResponse._list)&& + Objects.equals(this.additionalProperties, binaryAnnListResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(_list); + return Objects.hash(_list, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BinaryAnnListResponse {\n"); sb.append(" _list: ").append(toIndentedString(_list)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryAnnListResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryAnnListResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryAnnListResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryAnnListResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, BinaryAnnListResponse value) throws IOExceptio public BinaryAnnListResponse 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 + BinaryAnnListResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryConfig.java b/src/main/java/ai/reveng/model/BinaryConfig.java index 7440c73..840f606 100644 --- a/src/main/java/ai/reveng/model/BinaryConfig.java +++ b/src/main/java/ai/reveng/model/BinaryConfig.java @@ -129,6 +129,50 @@ public void setFileFormat(@javax.annotation.Nullable FileFormat fileFormat) { this.fileFormat = fileFormat; } + /** + * 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 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 BinaryConfig instance itself + */ + public BinaryConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -142,7 +186,8 @@ public boolean equals(Object o) { BinaryConfig binaryConfig = (BinaryConfig) o; return Objects.equals(this.isa, binaryConfig.isa) && Objects.equals(this.platform, binaryConfig.platform) && - Objects.equals(this.fileFormat, binaryConfig.fileFormat); + Objects.equals(this.fileFormat, binaryConfig.fileFormat)&& + Objects.equals(this.additionalProperties, binaryConfig.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -151,7 +196,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(isa, platform, fileFormat); + return Objects.hash(isa, platform, fileFormat, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -168,6 +213,7 @@ public String toString() { sb.append(" isa: ").append(toIndentedString(isa)).append("\n"); sb.append(" platform: ").append(toIndentedString(platform)).append("\n"); sb.append(" fileFormat: ").append(toIndentedString(fileFormat)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -207,14 +253,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in BinaryConfig is not found in the empty JSON string", BinaryConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `isa` if (jsonObj.get("isa") != null && !jsonObj.get("isa").isJsonNull()) { @@ -245,6 +283,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryConfig value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -252,7 +312,28 @@ public void write(JsonWriter out, BinaryConfig value) throws IOException { public BinaryConfig 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 + BinaryConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java index 198d65a..c3ffac1 100644 --- a/src/main/java/ai/reveng/model/BinaryDetailsResponse.java +++ b/src/main/java/ai/reveng/model/BinaryDetailsResponse.java @@ -535,6 +535,50 @@ public void setFirstSeen(@javax.annotation.Nonnull OffsetDateTime firstSeen) { this.firstSeen = firstSeen; } + /** + * 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 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 BinaryDetailsResponse instance itself + */ + public BinaryDetailsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -565,12 +609,13 @@ public boolean equals(Object o) { Objects.equals(this.tlsh, binaryDetailsResponse.tlsh) && Objects.equals(this.type, binaryDetailsResponse.type) && Objects.equals(this.debug, binaryDetailsResponse.debug) && - Objects.equals(this.firstSeen, binaryDetailsResponse.firstSeen); + Objects.equals(this.firstSeen, binaryDetailsResponse.firstSeen)&& + Objects.equals(this.additionalProperties, binaryDetailsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(arch, bits, crc32, propertyClass, entropy, fileSize, language, md5, machine, os, sha1, sha256, ssdeep, _static, stripped, subSys, tlsh, type, debug, firstSeen); + return Objects.hash(arch, bits, crc32, propertyClass, entropy, fileSize, language, md5, machine, os, sha1, sha256, ssdeep, _static, stripped, subSys, tlsh, type, debug, firstSeen, additionalProperties); } @Override @@ -597,6 +642,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" debug: ").append(toIndentedString(debug)).append("\n"); sb.append(" firstSeen: ").append(toIndentedString(firstSeen)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -637,14 +683,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryDetailsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryDetailsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryDetailsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -708,6 +746,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryDetailsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -715,7 +775,28 @@ public void write(JsonWriter out, BinaryDetailsResponse value) throws IOExceptio public BinaryDetailsResponse 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 + BinaryDetailsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinaryExternalsResponse.java b/src/main/java/ai/reveng/model/BinaryExternalsResponse.java index 26d698c..c30be21 100644 --- a/src/main/java/ai/reveng/model/BinaryExternalsResponse.java +++ b/src/main/java/ai/reveng/model/BinaryExternalsResponse.java @@ -192,6 +192,50 @@ public void setMbLastUpdated(@javax.annotation.Nonnull OffsetDateTime mbLastUpda this.mbLastUpdated = mbLastUpdated; } + /** + * 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 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 BinaryExternalsResponse instance itself + */ + public BinaryExternalsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -207,12 +251,13 @@ public boolean equals(Object o) { Objects.equals(this.vt, binaryExternalsResponse.vt) && Objects.equals(this.vtLastUpdated, binaryExternalsResponse.vtLastUpdated) && Objects.equals(this.mb, binaryExternalsResponse.mb) && - Objects.equals(this.mbLastUpdated, binaryExternalsResponse.mbLastUpdated); + Objects.equals(this.mbLastUpdated, binaryExternalsResponse.mbLastUpdated)&& + Objects.equals(this.additionalProperties, binaryExternalsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sha256Hash, vt, vtLastUpdated, mb, mbLastUpdated); + return Objects.hash(sha256Hash, vt, vtLastUpdated, mb, mbLastUpdated, additionalProperties); } @Override @@ -224,6 +269,7 @@ public String toString() { sb.append(" vtLastUpdated: ").append(toIndentedString(vtLastUpdated)).append("\n"); sb.append(" mb: ").append(toIndentedString(mb)).append("\n"); sb.append(" mbLastUpdated: ").append(toIndentedString(mbLastUpdated)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -264,14 +310,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinaryExternalsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinaryExternalsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinaryExternalsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -299,6 +337,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinaryExternalsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -306,7 +366,28 @@ public void write(JsonWriter out, BinaryExternalsResponse value) throws IOExcept public BinaryExternalsResponse 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 + BinaryExternalsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinarySearchResponse.java b/src/main/java/ai/reveng/model/BinarySearchResponse.java index c91c510..1c85c46 100644 --- a/src/main/java/ai/reveng/model/BinarySearchResponse.java +++ b/src/main/java/ai/reveng/model/BinarySearchResponse.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List result this.results = results; } + /** + * 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 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 BinarySearchResponse instance itself + */ + public BinarySearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } BinarySearchResponse binarySearchResponse = (BinarySearchResponse) o; - return Objects.equals(this.results, binarySearchResponse.results); + return Objects.equals(this.results, binarySearchResponse.results)&& + Objects.equals(this.additionalProperties, binarySearchResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BinarySearchResponse {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinarySearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinarySearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinarySearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinarySearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, BinarySearchResponse value) throws IOException public BinarySearchResponse 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 + BinarySearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BinarySearchResult.java b/src/main/java/ai/reveng/model/BinarySearchResult.java index c1bc1fb..0357c66 100644 --- a/src/main/java/ai/reveng/model/BinarySearchResult.java +++ b/src/main/java/ai/reveng/model/BinarySearchResult.java @@ -280,6 +280,50 @@ public void setOwnedBy(@javax.annotation.Nonnull String ownedBy) { this.ownedBy = ownedBy; } + /** + * 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 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 BinarySearchResult instance itself + */ + public BinarySearchResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -299,12 +343,13 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, binarySearchResult.createdAt) && Objects.equals(this.modelId, binarySearchResult.modelId) && Objects.equals(this.modelName, binarySearchResult.modelName) && - Objects.equals(this.ownedBy, binarySearchResult.ownedBy); + Objects.equals(this.ownedBy, binarySearchResult.ownedBy)&& + Objects.equals(this.additionalProperties, binarySearchResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryId, binaryName, analysisId, sha256Hash, tags, createdAt, modelId, modelName, ownedBy); + return Objects.hash(binaryId, binaryName, analysisId, sha256Hash, tags, createdAt, modelId, modelName, ownedBy, additionalProperties); } @Override @@ -320,6 +365,7 @@ public String toString() { sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -360,14 +406,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BinarySearchResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BinarySearchResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BinarySearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -410,6 +448,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BinarySearchResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -417,7 +477,28 @@ public void write(JsonWriter out, BinarySearchResult value) throws IOException { public BinarySearchResult 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 + BinarySearchResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Block.java b/src/main/java/ai/reveng/model/Block.java index 093fdc4..fb88d50 100644 --- a/src/main/java/ai/reveng/model/Block.java +++ b/src/main/java/ai/reveng/model/Block.java @@ -77,6 +77,50 @@ public void setVirtualAddress(@javax.annotation.Nonnull Integer virtualAddress) this.virtualAddress = virtualAddress; } + /** + * 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 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 Block instance itself + */ + public Block putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } Block block = (Block) o; - return Objects.equals(this.virtualAddress, block.virtualAddress); + return Objects.equals(this.virtualAddress, block.virtualAddress)&& + Objects.equals(this.additionalProperties, block.additionalProperties); } @Override public int hashCode() { - return Objects.hash(virtualAddress); + return Objects.hash(virtualAddress, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Block {\n"); sb.append(" virtualAddress: ").append(toIndentedString(virtualAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Block.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Block` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Block.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -173,6 +211,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Block value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -180,7 +240,28 @@ public void write(JsonWriter out, Block value) throws IOException { public Block 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 + Block instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BlockCommentsGenerationForFunctionResponse.java b/src/main/java/ai/reveng/model/BlockCommentsGenerationForFunctionResponse.java index 770d437..ff20a07 100644 --- a/src/main/java/ai/reveng/model/BlockCommentsGenerationForFunctionResponse.java +++ b/src/main/java/ai/reveng/model/BlockCommentsGenerationForFunctionResponse.java @@ -77,6 +77,50 @@ public void setUpdatedBlocks(@javax.annotation.Nonnull Integer updatedBlocks) { this.updatedBlocks = updatedBlocks; } + /** + * 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 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 BlockCommentsGenerationForFunctionResponse instance itself + */ + public BlockCommentsGenerationForFunctionResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } BlockCommentsGenerationForFunctionResponse blockCommentsGenerationForFunctionResponse = (BlockCommentsGenerationForFunctionResponse) o; - return Objects.equals(this.updatedBlocks, blockCommentsGenerationForFunctionResponse.updatedBlocks); + return Objects.equals(this.updatedBlocks, blockCommentsGenerationForFunctionResponse.updatedBlocks)&& + Objects.equals(this.additionalProperties, blockCommentsGenerationForFunctionResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(updatedBlocks); + return Objects.hash(updatedBlocks, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class BlockCommentsGenerationForFunctionResponse {\n"); sb.append(" updatedBlocks: ").append(toIndentedString(updatedBlocks)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BlockCommentsGenerationForFunctionResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BlockCommentsGenerationForFunctionResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BlockCommentsGenerationForFunctionResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -173,6 +211,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BlockCommentsGenerationForFunctionResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -180,7 +240,28 @@ public void write(JsonWriter out, BlockCommentsGenerationForFunctionResponse val public BlockCommentsGenerationForFunctionResponse 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 + BlockCommentsGenerationForFunctionResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/BoxPlotConfidence.java b/src/main/java/ai/reveng/model/BoxPlotConfidence.java index 82e5012..6dc3e5f 100644 --- a/src/main/java/ai/reveng/model/BoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/BoxPlotConfidence.java @@ -222,6 +222,50 @@ public void setNegativeCount(@javax.annotation.Nonnull Integer negativeCount) { this.negativeCount = negativeCount; } + /** + * 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 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 BoxPlotConfidence instance itself + */ + public BoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.upperQuartile, boxPlotConfidence.upperQuartile) && Objects.equals(this.lowerQuartile, boxPlotConfidence.lowerQuartile) && Objects.equals(this.positiveCount, boxPlotConfidence.positiveCount) && - Objects.equals(this.negativeCount, boxPlotConfidence.negativeCount); + Objects.equals(this.negativeCount, boxPlotConfidence.negativeCount)&& + Objects.equals(this.additionalProperties, boxPlotConfidence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(min, max, average, upperQuartile, lowerQuartile, positiveCount, negativeCount); + return Objects.hash(min, max, average, upperQuartile, lowerQuartile, positiveCount, negativeCount, additionalProperties); } @Override @@ -258,6 +303,7 @@ public String toString() { sb.append(" lowerQuartile: ").append(toIndentedString(lowerQuartile)).append("\n"); sb.append(" positiveCount: ").append(toIndentedString(positiveCount)).append("\n"); sb.append(" negativeCount: ").append(toIndentedString(negativeCount)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -298,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!BoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `BoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : BoxPlotConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -330,6 +368,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, BoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -337,7 +397,28 @@ public void write(JsonWriter out, BoxPlotConfidence value) throws IOException { public BoxPlotConfidence 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 + BoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CalleeFunctionInfo.java b/src/main/java/ai/reveng/model/CalleeFunctionInfo.java index 955e9e1..9828550 100644 --- a/src/main/java/ai/reveng/model/CalleeFunctionInfo.java +++ b/src/main/java/ai/reveng/model/CalleeFunctionInfo.java @@ -197,6 +197,50 @@ public void setCalleeVaddr(@javax.annotation.Nonnull String calleeVaddr) { this.calleeVaddr = calleeVaddr; } + /** + * 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 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 CalleeFunctionInfo instance itself + */ + public CalleeFunctionInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -213,12 +257,13 @@ public boolean equals(Object o) { Objects.equals(this.dashboardUrl, calleeFunctionInfo.dashboardUrl) && Objects.equals(this.isExternal, calleeFunctionInfo.isExternal) && Objects.equals(this.calleeName, calleeFunctionInfo.calleeName) && - Objects.equals(this.calleeVaddr, calleeFunctionInfo.calleeVaddr); + Objects.equals(this.calleeVaddr, calleeFunctionInfo.calleeVaddr)&& + Objects.equals(this.additionalProperties, calleeFunctionInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, matchedFunctionId, dashboardUrl, isExternal, calleeName, calleeVaddr); + return Objects.hash(functionId, matchedFunctionId, dashboardUrl, isExternal, calleeName, calleeVaddr, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" calleeName: ").append(toIndentedString(calleeName)).append("\n"); sb.append(" calleeVaddr: ").append(toIndentedString(calleeVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CalleeFunctionInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CalleeFunctionInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CalleeFunctionInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -312,6 +350,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CalleeFunctionInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -319,7 +379,28 @@ public void write(JsonWriter out, CalleeFunctionInfo value) throws IOException { public CalleeFunctionInfo 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 + CalleeFunctionInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java b/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java index ffe429a..225521d 100644 --- a/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/CalleesCallerFunctionsResponse.java @@ -145,6 +145,50 @@ public void setCallers(@javax.annotation.Nonnull List caller this.callers = callers; } + /** + * 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 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 CalleesCallerFunctionsResponse instance itself + */ + public CalleesCallerFunctionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -158,12 +202,13 @@ public boolean equals(Object o) { CalleesCallerFunctionsResponse calleesCallerFunctionsResponse = (CalleesCallerFunctionsResponse) o; return Objects.equals(this.baseAddress, calleesCallerFunctionsResponse.baseAddress) && Objects.equals(this.callees, calleesCallerFunctionsResponse.callees) && - Objects.equals(this.callers, calleesCallerFunctionsResponse.callers); + Objects.equals(this.callers, calleesCallerFunctionsResponse.callers)&& + Objects.equals(this.additionalProperties, calleesCallerFunctionsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(baseAddress, callees, callers); + return Objects.hash(baseAddress, callees, callers, additionalProperties); } @Override @@ -173,6 +218,7 @@ public String toString() { sb.append(" baseAddress: ").append(toIndentedString(baseAddress)).append("\n"); sb.append(" callees: ").append(toIndentedString(callees)).append("\n"); sb.append(" callers: ").append(toIndentedString(callers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -213,14 +259,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CalleesCallerFunctionsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CalleesCallerFunctionsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CalleesCallerFunctionsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -265,6 +303,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CalleesCallerFunctionsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -272,7 +332,28 @@ public void write(JsonWriter out, CalleesCallerFunctionsResponse value) throws I public CalleesCallerFunctionsResponse 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 + CalleesCallerFunctionsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CallerFunctionInfo.java b/src/main/java/ai/reveng/model/CallerFunctionInfo.java index ff7b133..94c08f3 100644 --- a/src/main/java/ai/reveng/model/CallerFunctionInfo.java +++ b/src/main/java/ai/reveng/model/CallerFunctionInfo.java @@ -197,6 +197,50 @@ public void setCallerVaddr(@javax.annotation.Nonnull String callerVaddr) { this.callerVaddr = callerVaddr; } + /** + * 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 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 CallerFunctionInfo instance itself + */ + public CallerFunctionInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -213,12 +257,13 @@ public boolean equals(Object o) { Objects.equals(this.dashboardUrl, callerFunctionInfo.dashboardUrl) && Objects.equals(this.isExternal, callerFunctionInfo.isExternal) && Objects.equals(this.callerName, callerFunctionInfo.callerName) && - Objects.equals(this.callerVaddr, callerFunctionInfo.callerVaddr); + Objects.equals(this.callerVaddr, callerFunctionInfo.callerVaddr)&& + Objects.equals(this.additionalProperties, callerFunctionInfo.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, matchedFunctionId, dashboardUrl, isExternal, callerName, callerVaddr); + return Objects.hash(functionId, matchedFunctionId, dashboardUrl, isExternal, callerName, callerVaddr, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); sb.append(" callerName: ").append(toIndentedString(callerName)).append("\n"); sb.append(" callerVaddr: ").append(toIndentedString(callerVaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CallerFunctionInfo.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CallerFunctionInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CallerFunctionInfo.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -312,6 +350,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CallerFunctionInfo value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -319,7 +379,28 @@ public void write(JsonWriter out, CallerFunctionInfo value) throws IOException { public CallerFunctionInfo 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 + CallerFunctionInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Capabilities.java b/src/main/java/ai/reveng/model/Capabilities.java index 5d6fcf7..1225ba5 100644 --- a/src/main/java/ai/reveng/model/Capabilities.java +++ b/src/main/java/ai/reveng/model/Capabilities.java @@ -88,6 +88,50 @@ public void setCapabilities(@javax.annotation.Nonnull List capabilit this.capabilities = capabilities; } + /** + * 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 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 Capabilities instance itself + */ + public Capabilities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } Capabilities capabilities = (Capabilities) o; - return Objects.equals(this.capabilities, capabilities.capabilities); + return Objects.equals(this.capabilities, capabilities.capabilities)&& + Objects.equals(this.additionalProperties, capabilities.additionalProperties); } @Override public int hashCode() { - return Objects.hash(capabilities); + return Objects.hash(capabilities, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Capabilities {\n"); sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Capabilities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Capabilities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Capabilities.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Capabilities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, Capabilities value) throws IOException { public Capabilities 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 + Capabilities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Capability.java b/src/main/java/ai/reveng/model/Capability.java index e1f0c49..95ef182 100644 --- a/src/main/java/ai/reveng/model/Capability.java +++ b/src/main/java/ai/reveng/model/Capability.java @@ -135,6 +135,50 @@ public void setCapabilities(@javax.annotation.Nonnull List capabilities) this.capabilities = capabilities; } + /** + * 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 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 Capability instance itself + */ + public Capability putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -148,12 +192,13 @@ public boolean equals(Object o) { Capability capability = (Capability) o; return Objects.equals(this.functionName, capability.functionName) && Objects.equals(this.functionVaddr, capability.functionVaddr) && - Objects.equals(this.capabilities, capability.capabilities); + Objects.equals(this.capabilities, capability.capabilities)&& + Objects.equals(this.additionalProperties, capability.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionName, functionVaddr, capabilities); + return Objects.hash(functionName, functionVaddr, capabilities, additionalProperties); } @Override @@ -163,6 +208,7 @@ public String toString() { sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -203,14 +249,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Capability.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Capability` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Capability.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -244,6 +282,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Capability value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -251,7 +311,28 @@ public void write(JsonWriter out, Capability value) throws IOException { public Capability 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 + Capability instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CheckSecurityChecksTaskResponse.java b/src/main/java/ai/reveng/model/CheckSecurityChecksTaskResponse.java index 6c3fc72..2c5fc1f 100644 --- a/src/main/java/ai/reveng/model/CheckSecurityChecksTaskResponse.java +++ b/src/main/java/ai/reveng/model/CheckSecurityChecksTaskResponse.java @@ -78,6 +78,50 @@ public void setStatus(@javax.annotation.Nonnull BinaryTaskStatus status) { this.status = status; } + /** + * 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 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 CheckSecurityChecksTaskResponse instance itself + */ + public CheckSecurityChecksTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -89,12 +133,13 @@ public boolean equals(Object o) { return false; } CheckSecurityChecksTaskResponse checkSecurityChecksTaskResponse = (CheckSecurityChecksTaskResponse) o; - return Objects.equals(this.status, checkSecurityChecksTaskResponse.status); + return Objects.equals(this.status, checkSecurityChecksTaskResponse.status)&& + Objects.equals(this.additionalProperties, checkSecurityChecksTaskResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(status); + return Objects.hash(status, additionalProperties); } @Override @@ -102,6 +147,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CheckSecurityChecksTaskResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -142,14 +188,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CheckSecurityChecksTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CheckSecurityChecksTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CheckSecurityChecksTaskResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CheckSecurityChecksTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, CheckSecurityChecksTaskResponse value) throws public CheckSecurityChecksTaskResponse 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 + CheckSecurityChecksTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ChildBinariesResponse.java b/src/main/java/ai/reveng/model/ChildBinariesResponse.java index c568062..1c8f551 100644 --- a/src/main/java/ai/reveng/model/ChildBinariesResponse.java +++ b/src/main/java/ai/reveng/model/ChildBinariesResponse.java @@ -113,6 +113,50 @@ public void setParent(@javax.annotation.Nullable RelativeBinaryResponse parent) this.parent = parent; } + /** + * 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 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 ChildBinariesResponse instance itself + */ + public ChildBinariesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -125,7 +169,8 @@ public boolean equals(Object o) { } ChildBinariesResponse childBinariesResponse = (ChildBinariesResponse) o; return Objects.equals(this.children, childBinariesResponse.children) && - Objects.equals(this.parent, childBinariesResponse.parent); + Objects.equals(this.parent, childBinariesResponse.parent)&& + Objects.equals(this.additionalProperties, childBinariesResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -134,7 +179,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(children, parent); + return Objects.hash(children, parent, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -150,6 +195,7 @@ public String toString() { sb.append("class ChildBinariesResponse {\n"); sb.append(" children: ").append(toIndentedString(children)).append("\n"); sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -190,14 +236,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ChildBinariesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ChildBinariesResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ChildBinariesResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -236,6 +274,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ChildBinariesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -243,7 +303,28 @@ public void write(JsonWriter out, ChildBinariesResponse value) throws IOExceptio public ChildBinariesResponse 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 + ChildBinariesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CodeSignatureModel.java b/src/main/java/ai/reveng/model/CodeSignatureModel.java index 5f6476b..6703ff2 100644 --- a/src/main/java/ai/reveng/model/CodeSignatureModel.java +++ b/src/main/java/ai/reveng/model/CodeSignatureModel.java @@ -136,6 +136,50 @@ public void setSignatures(@javax.annotation.Nonnull List 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 CodeSignatureModel instance itself + */ + public CodeSignatureModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { CodeSignatureModel codeSignatureModel = (CodeSignatureModel) o; return Objects.equals(this.signed, codeSignatureModel.signed) && Objects.equals(this.validSignature, codeSignatureModel.validSignature) && - Objects.equals(this.signatures, codeSignatureModel.signatures); + Objects.equals(this.signatures, codeSignatureModel.signatures)&& + Objects.equals(this.additionalProperties, codeSignatureModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(signed, validSignature, signatures); + return Objects.hash(signed, validSignature, signatures, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" signed: ").append(toIndentedString(signed)).append("\n"); sb.append(" validSignature: ").append(toIndentedString(validSignature)).append("\n"); sb.append(" signatures: ").append(toIndentedString(signatures)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CodeSignatureModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CodeSignatureModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CodeSignatureModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -246,6 +284,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CodeSignatureModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -253,7 +313,28 @@ public void write(JsonWriter out, CodeSignatureModel value) throws IOException { public CodeSignatureModel 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 + CodeSignatureModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java index e0b34be..4c950dd 100644 --- a/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionBinariesUpdateRequest.java @@ -87,6 +87,50 @@ public void setBinaries(@javax.annotation.Nonnull List binaries) { this.binaries = binaries; } + /** + * 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 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 CollectionBinariesUpdateRequest instance itself + */ + public CollectionBinariesUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } CollectionBinariesUpdateRequest collectionBinariesUpdateRequest = (CollectionBinariesUpdateRequest) o; - return Objects.equals(this.binaries, collectionBinariesUpdateRequest.binaries); + return Objects.equals(this.binaries, collectionBinariesUpdateRequest.binaries)&& + Objects.equals(this.additionalProperties, collectionBinariesUpdateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CollectionBinariesUpdateRequest {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionBinariesUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionBinariesUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinariesUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionBinariesUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, CollectionBinariesUpdateRequest value) throws public CollectionBinariesUpdateRequest 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 + CollectionBinariesUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java b/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java index e16af1d..97760cc 100644 --- a/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java +++ b/src/main/java/ai/reveng/model/CollectionBinariesUpdateResponse.java @@ -88,6 +88,50 @@ public void setBinaries(@javax.annotation.Nonnull List this.binaries = binaries; } + /** + * 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 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 CollectionBinariesUpdateResponse instance itself + */ + public CollectionBinariesUpdateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } CollectionBinariesUpdateResponse collectionBinariesUpdateResponse = (CollectionBinariesUpdateResponse) o; - return Objects.equals(this.binaries, collectionBinariesUpdateResponse.binaries); + return Objects.equals(this.binaries, collectionBinariesUpdateResponse.binaries)&& + Objects.equals(this.additionalProperties, collectionBinariesUpdateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaries); + return Objects.hash(binaries, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CollectionBinariesUpdateResponse {\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionBinariesUpdateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionBinariesUpdateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinariesUpdateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionBinariesUpdateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, CollectionBinariesUpdateResponse value) throws public CollectionBinariesUpdateResponse 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 + CollectionBinariesUpdateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionBinaryResponse.java b/src/main/java/ai/reveng/model/CollectionBinaryResponse.java index 5bc3963..67999fb 100644 --- a/src/main/java/ai/reveng/model/CollectionBinaryResponse.java +++ b/src/main/java/ai/reveng/model/CollectionBinaryResponse.java @@ -198,6 +198,50 @@ public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { this.createdAt = createdAt; } + /** + * 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 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 CollectionBinaryResponse instance itself + */ + public CollectionBinaryResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -214,12 +258,13 @@ public boolean equals(Object o) { Objects.equals(this.binaryName, collectionBinaryResponse.binaryName) && Objects.equals(this.ownerId, collectionBinaryResponse.ownerId) && Objects.equals(this.sha256Hash, collectionBinaryResponse.sha256Hash) && - Objects.equals(this.createdAt, collectionBinaryResponse.createdAt); + Objects.equals(this.createdAt, collectionBinaryResponse.createdAt)&& + Objects.equals(this.additionalProperties, collectionBinaryResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, binaryName, ownerId, sha256Hash, createdAt); + return Objects.hash(analysisId, binaryId, binaryName, ownerId, sha256Hash, createdAt, additionalProperties); } @Override @@ -232,6 +277,7 @@ public String toString() { sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -272,14 +318,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionBinaryResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionBinaryResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionBinaryResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -310,6 +348,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionBinaryResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -317,7 +377,28 @@ public void write(JsonWriter out, CollectionBinaryResponse value) throws IOExcep public CollectionBinaryResponse 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 + CollectionBinaryResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionCreateRequest.java b/src/main/java/ai/reveng/model/CollectionCreateRequest.java index 51e08e7..767b14a 100644 --- a/src/main/java/ai/reveng/model/CollectionCreateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionCreateRequest.java @@ -217,6 +217,50 @@ public void setModelId(@javax.annotation.Nonnull Integer modelId) { this.modelId = modelId; } + /** + * 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 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 CollectionCreateRequest instance itself + */ + public CollectionCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -233,7 +277,8 @@ public boolean equals(Object o) { Objects.equals(this.collectionScope, collectionCreateRequest.collectionScope) && Objects.equals(this.tags, collectionCreateRequest.tags) && Objects.equals(this.binaries, collectionCreateRequest.binaries) && - Objects.equals(this.modelId, collectionCreateRequest.modelId); + Objects.equals(this.modelId, collectionCreateRequest.modelId)&& + Objects.equals(this.additionalProperties, collectionCreateRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -242,7 +287,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(collectionName, description, collectionScope, tags, binaries, modelId); + return Objects.hash(collectionName, description, collectionScope, tags, binaries, modelId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -262,6 +307,7 @@ public String toString() { sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -302,14 +348,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionCreateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionCreateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -352,6 +390,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionCreateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -359,7 +419,28 @@ public void write(JsonWriter out, CollectionCreateRequest value) throws IOExcept public CollectionCreateRequest 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 + CollectionCreateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionListItem.java b/src/main/java/ai/reveng/model/CollectionListItem.java index 2a7b528..4ce5538 100644 --- a/src/main/java/ai/reveng/model/CollectionListItem.java +++ b/src/main/java/ai/reveng/model/CollectionListItem.java @@ -329,6 +329,50 @@ public void setTeamId(@javax.annotation.Nullable Integer teamId) { this.teamId = teamId; } + /** + * 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 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 CollectionListItem instance itself + */ + public CollectionListItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -350,7 +394,8 @@ public boolean equals(Object o) { Objects.equals(this.collectionId, collectionListItem.collectionId) && Objects.equals(this.creation, collectionListItem.creation) && Objects.equals(this.modelName, collectionListItem.modelName) && - Objects.equals(this.teamId, collectionListItem.teamId); + Objects.equals(this.teamId, collectionListItem.teamId)&& + Objects.equals(this.additionalProperties, collectionListItem.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -359,7 +404,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(collectionName, description, collectionScope, collectionOwner, officialCollection, collectionTags, collectionSize, collectionId, creation, modelName, teamId); + return Objects.hash(collectionName, description, collectionScope, collectionOwner, officialCollection, collectionTags, collectionSize, collectionId, creation, modelName, teamId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -384,6 +429,7 @@ public String toString() { sb.append(" creation: ").append(toIndentedString(creation)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -424,14 +470,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionListItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionListItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionListItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -475,6 +513,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionListItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -482,7 +542,28 @@ public void write(JsonWriter out, CollectionListItem value) throws IOException { public CollectionListItem 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 + CollectionListItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionResponse.java b/src/main/java/ai/reveng/model/CollectionResponse.java index f3582bd..2be1309 100644 --- a/src/main/java/ai/reveng/model/CollectionResponse.java +++ b/src/main/java/ai/reveng/model/CollectionResponse.java @@ -339,6 +339,50 @@ public void setBinaries(@javax.annotation.Nullable List 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 CollectionResponse instance itself + */ + public CollectionResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -360,7 +404,8 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, collectionResponse.createdAt) && Objects.equals(this.updatedAt, collectionResponse.updatedAt) && Objects.equals(this.tags, collectionResponse.tags) && - Objects.equals(this.binaries, collectionResponse.binaries); + Objects.equals(this.binaries, collectionResponse.binaries)&& + Objects.equals(this.additionalProperties, collectionResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -369,7 +414,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(collectionId, collectionName, description, modelId, userId, teamId, collectionScope, createdAt, updatedAt, tags, binaries); + return Objects.hash(collectionId, collectionName, description, modelId, userId, teamId, collectionScope, createdAt, updatedAt, tags, binaries, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -394,6 +439,7 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" binaries: ").append(toIndentedString(binaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -434,14 +480,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -492,6 +530,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -499,7 +559,28 @@ public void write(JsonWriter out, CollectionResponse value) throws IOException { public CollectionResponse 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 + CollectionResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionSearchResponse.java b/src/main/java/ai/reveng/model/CollectionSearchResponse.java index 1080d08..7413d6a 100644 --- a/src/main/java/ai/reveng/model/CollectionSearchResponse.java +++ b/src/main/java/ai/reveng/model/CollectionSearchResponse.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List re this.results = results; } + /** + * 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 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 CollectionSearchResponse instance itself + */ + public CollectionSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } CollectionSearchResponse collectionSearchResponse = (CollectionSearchResponse) o; - return Objects.equals(this.results, collectionSearchResponse.results); + return Objects.equals(this.results, collectionSearchResponse.results)&& + Objects.equals(this.additionalProperties, collectionSearchResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CollectionSearchResponse {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, CollectionSearchResponse value) throws IOExcep public CollectionSearchResponse 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 + CollectionSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionSearchResult.java b/src/main/java/ai/reveng/model/CollectionSearchResult.java index 4596d77..1f6f802 100644 --- a/src/main/java/ai/reveng/model/CollectionSearchResult.java +++ b/src/main/java/ai/reveng/model/CollectionSearchResult.java @@ -353,6 +353,50 @@ public void setTeamId(@javax.annotation.Nullable Integer teamId) { this.teamId = teamId; } + /** + * 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 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 CollectionSearchResult instance itself + */ + public CollectionSearchResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -375,7 +419,8 @@ public boolean equals(Object o) { Objects.equals(this.tags, collectionSearchResult.tags) && Objects.equals(this.size, collectionSearchResult.size) && Objects.equals(this.description, collectionSearchResult.description) && - Objects.equals(this.teamId, collectionSearchResult.teamId); + Objects.equals(this.teamId, collectionSearchResult.teamId)&& + Objects.equals(this.additionalProperties, collectionSearchResult.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -384,7 +429,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(collectionId, collectionName, scope, lastUpdatedAt, createdAt, modelId, modelName, ownedBy, tags, size, description, teamId); + return Objects.hash(collectionId, collectionName, scope, lastUpdatedAt, createdAt, modelId, modelName, ownedBy, tags, size, description, teamId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -410,6 +455,7 @@ public String toString() { sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" teamId: ").append(toIndentedString(teamId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -450,14 +496,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionSearchResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionSearchResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -501,6 +539,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionSearchResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -508,7 +568,28 @@ public void write(JsonWriter out, CollectionSearchResult value) throws IOExcepti public CollectionSearchResult 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 + CollectionSearchResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java index 50be31d..294ced6 100644 --- a/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionTagsUpdateRequest.java @@ -87,6 +87,50 @@ public void setTags(@javax.annotation.Nonnull List tags) { this.tags = tags; } + /** + * 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 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 CollectionTagsUpdateRequest instance itself + */ + public CollectionTagsUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } CollectionTagsUpdateRequest collectionTagsUpdateRequest = (CollectionTagsUpdateRequest) o; - return Objects.equals(this.tags, collectionTagsUpdateRequest.tags); + return Objects.equals(this.tags, collectionTagsUpdateRequest.tags)&& + Objects.equals(this.additionalProperties, collectionTagsUpdateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CollectionTagsUpdateRequest {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionTagsUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionTagsUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionTagsUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionTagsUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, CollectionTagsUpdateRequest value) throws IOEx public CollectionTagsUpdateRequest 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 + CollectionTagsUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java b/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java index a47a79d..d32aa9b 100644 --- a/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java +++ b/src/main/java/ai/reveng/model/CollectionTagsUpdateResponse.java @@ -87,6 +87,50 @@ public void setTags(@javax.annotation.Nonnull List tags) { this.tags = tags; } + /** + * 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 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 CollectionTagsUpdateResponse instance itself + */ + public CollectionTagsUpdateResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } CollectionTagsUpdateResponse collectionTagsUpdateResponse = (CollectionTagsUpdateResponse) o; - return Objects.equals(this.tags, collectionTagsUpdateResponse.tags); + return Objects.equals(this.tags, collectionTagsUpdateResponse.tags)&& + Objects.equals(this.additionalProperties, collectionTagsUpdateResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CollectionTagsUpdateResponse {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionTagsUpdateResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionTagsUpdateResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CollectionTagsUpdateResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionTagsUpdateResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, CollectionTagsUpdateResponse value) throws IOE public CollectionTagsUpdateResponse 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 + CollectionTagsUpdateResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CollectionUpdateRequest.java b/src/main/java/ai/reveng/model/CollectionUpdateRequest.java index d2f7ace..6983ead 100644 --- a/src/main/java/ai/reveng/model/CollectionUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CollectionUpdateRequest.java @@ -127,6 +127,50 @@ public void setCollectionScope(@javax.annotation.Nullable CollectionScope collec this.collectionScope = collectionScope; } + /** + * 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 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 CollectionUpdateRequest instance itself + */ + public CollectionUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -140,7 +184,8 @@ public boolean equals(Object o) { CollectionUpdateRequest collectionUpdateRequest = (CollectionUpdateRequest) o; return Objects.equals(this.collectionName, collectionUpdateRequest.collectionName) && Objects.equals(this.description, collectionUpdateRequest.description) && - Objects.equals(this.collectionScope, collectionUpdateRequest.collectionScope); + Objects.equals(this.collectionScope, collectionUpdateRequest.collectionScope)&& + Objects.equals(this.additionalProperties, collectionUpdateRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -149,7 +194,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(collectionName, description, collectionScope); + return Objects.hash(collectionName, description, collectionScope, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -166,6 +211,7 @@ public String toString() { sb.append(" collectionName: ").append(toIndentedString(collectionName)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" collectionScope: ").append(toIndentedString(collectionScope)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,14 +251,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CollectionUpdateRequest is not found in the empty JSON string", CollectionUpdateRequest.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CollectionUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CollectionUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("collection_name") != null && !jsonObj.get("collection_name").isJsonNull()) && !jsonObj.get("collection_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `collection_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("collection_name").toString())); @@ -241,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CollectionUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -248,7 +308,28 @@ public void write(JsonWriter out, CollectionUpdateRequest value) throws IOExcept public CollectionUpdateRequest 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 + CollectionUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CommentBase.java b/src/main/java/ai/reveng/model/CommentBase.java index 7bf76d5..74d5773 100644 --- a/src/main/java/ai/reveng/model/CommentBase.java +++ b/src/main/java/ai/reveng/model/CommentBase.java @@ -77,6 +77,50 @@ public void setContent(@javax.annotation.Nonnull String content) { this.content = content; } + /** + * 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 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 CommentBase instance itself + */ + public CommentBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } CommentBase commentBase = (CommentBase) o; - return Objects.equals(this.content, commentBase.content); + return Objects.equals(this.content, commentBase.content)&& + Objects.equals(this.additionalProperties, commentBase.additionalProperties); } @Override public int hashCode() { - return Objects.hash(content); + return Objects.hash(content, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CommentBase {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentBase.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentBase` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentBase.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentBase value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, CommentBase value) throws IOException { public CommentBase 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 + CommentBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CommentResponse.java b/src/main/java/ai/reveng/model/CommentResponse.java index 857c9bc..2886234 100644 --- a/src/main/java/ai/reveng/model/CommentResponse.java +++ b/src/main/java/ai/reveng/model/CommentResponse.java @@ -248,6 +248,50 @@ public void setUpdatedAt(@javax.annotation.Nonnull OffsetDateTime updatedAt) { this.updatedAt = updatedAt; } + /** + * 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 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 CommentResponse instance itself + */ + public CommentResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -266,7 +310,8 @@ public boolean equals(Object o) { Objects.equals(this.resourceId, commentResponse.resourceId) && Objects.equals(this.context, commentResponse.context) && Objects.equals(this.createdAt, commentResponse.createdAt) && - Objects.equals(this.updatedAt, commentResponse.updatedAt); + Objects.equals(this.updatedAt, commentResponse.updatedAt)&& + Objects.equals(this.additionalProperties, commentResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -275,7 +320,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(content, id, userId, resourceType, resourceId, context, createdAt, updatedAt); + return Objects.hash(content, id, userId, resourceType, resourceId, context, createdAt, updatedAt, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -297,6 +342,7 @@ public String toString() { sb.append(" context: ").append(toIndentedString(context)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -337,14 +383,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -382,6 +420,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -389,7 +449,28 @@ public void write(JsonWriter out, CommentResponse value) throws IOException { public CommentResponse 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 + CommentResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CommentUpdateRequest.java b/src/main/java/ai/reveng/model/CommentUpdateRequest.java index 0d57629..3354927 100644 --- a/src/main/java/ai/reveng/model/CommentUpdateRequest.java +++ b/src/main/java/ai/reveng/model/CommentUpdateRequest.java @@ -77,6 +77,50 @@ public void setContent(@javax.annotation.Nonnull String content) { this.content = content; } + /** + * 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 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 CommentUpdateRequest instance itself + */ + public CommentUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } CommentUpdateRequest commentUpdateRequest = (CommentUpdateRequest) o; - return Objects.equals(this.content, commentUpdateRequest.content); + return Objects.equals(this.content, commentUpdateRequest.content)&& + Objects.equals(this.additionalProperties, commentUpdateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(content); + return Objects.hash(content, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CommentUpdateRequest {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommentUpdateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommentUpdateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommentUpdateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommentUpdateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, CommentUpdateRequest value) throws IOException public CommentUpdateRequest 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 + CommentUpdateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Communities.java b/src/main/java/ai/reveng/model/Communities.java index 2204bb6..c16eec1 100644 --- a/src/main/java/ai/reveng/model/Communities.java +++ b/src/main/java/ai/reveng/model/Communities.java @@ -169,6 +169,50 @@ public void setTopComponents(@javax.annotation.Nonnull List> this.topComponents = topComponents; } + /** + * 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 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 Communities instance itself + */ + public Communities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -183,12 +227,13 @@ public boolean equals(Object o) { return Objects.equals(this.totalFunctions, communities.totalFunctions) && Objects.equals(this.totalMatchedFunctions, communities.totalMatchedFunctions) && Objects.equals(this.directCommunityMatchPercentages, communities.directCommunityMatchPercentages) && - Objects.equals(this.topComponents, communities.topComponents); + Objects.equals(this.topComponents, communities.topComponents)&& + Objects.equals(this.additionalProperties, communities.additionalProperties); } @Override public int hashCode() { - return Objects.hash(totalFunctions, totalMatchedFunctions, directCommunityMatchPercentages, topComponents); + return Objects.hash(totalFunctions, totalMatchedFunctions, directCommunityMatchPercentages, topComponents, additionalProperties); } @Override @@ -199,6 +244,7 @@ public String toString() { sb.append(" totalMatchedFunctions: ").append(toIndentedString(totalMatchedFunctions)).append("\n"); sb.append(" directCommunityMatchPercentages: ").append(toIndentedString(directCommunityMatchPercentages)).append("\n"); sb.append(" topComponents: ").append(toIndentedString(topComponents)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -239,14 +285,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Communities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Communities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Communities.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -287,6 +325,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Communities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -294,7 +354,28 @@ public void write(JsonWriter out, Communities value) throws IOException { public Communities 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 + Communities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/CommunityMatchPercentages.java b/src/main/java/ai/reveng/model/CommunityMatchPercentages.java index e31b1bb..02731ff 100644 --- a/src/main/java/ai/reveng/model/CommunityMatchPercentages.java +++ b/src/main/java/ai/reveng/model/CommunityMatchPercentages.java @@ -150,6 +150,50 @@ public void setUnmatchedCommunitiesPercent(@javax.annotation.Nonnull BigDecimal this.unmatchedCommunitiesPercent = unmatchedCommunitiesPercent; } + /** + * 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 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 CommunityMatchPercentages instance itself + */ + public CommunityMatchPercentages putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -164,12 +208,13 @@ public boolean equals(Object o) { return Objects.equals(this.binaryName, communityMatchPercentages.binaryName) && Objects.equals(this.binaryId, communityMatchPercentages.binaryId) && Objects.equals(this.matchedCommunitiesPercent, communityMatchPercentages.matchedCommunitiesPercent) && - Objects.equals(this.unmatchedCommunitiesPercent, communityMatchPercentages.unmatchedCommunitiesPercent); + Objects.equals(this.unmatchedCommunitiesPercent, communityMatchPercentages.unmatchedCommunitiesPercent)&& + Objects.equals(this.additionalProperties, communityMatchPercentages.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryName, binaryId, matchedCommunitiesPercent, unmatchedCommunitiesPercent); + return Objects.hash(binaryName, binaryId, matchedCommunitiesPercent, unmatchedCommunitiesPercent, additionalProperties); } @Override @@ -180,6 +225,7 @@ public String toString() { sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" matchedCommunitiesPercent: ").append(toIndentedString(matchedCommunitiesPercent)).append("\n"); sb.append(" unmatchedCommunitiesPercent: ").append(toIndentedString(unmatchedCommunitiesPercent)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -220,14 +266,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CommunityMatchPercentages.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `CommunityMatchPercentages` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CommunityMatchPercentages.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -255,6 +293,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, CommunityMatchPercentages value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -262,7 +322,28 @@ public void write(JsonWriter out, CommunityMatchPercentages value) throws IOExce public CommunityMatchPercentages 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 + CommunityMatchPercentages instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Created.java b/src/main/java/ai/reveng/model/Created.java index 461ec08..7c41999 100644 --- a/src/main/java/ai/reveng/model/Created.java +++ b/src/main/java/ai/reveng/model/Created.java @@ -130,6 +130,50 @@ public void setReference(@javax.annotation.Nonnull String reference) { this.reference = reference; } + /** + * 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 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 Created instance itself + */ + public Created putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -143,12 +187,13 @@ public boolean equals(Object o) { Created created = (Created) o; return Objects.equals(this.analysisId, created.analysisId) && Objects.equals(this.binaryId, created.binaryId) && - Objects.equals(this.reference, created.reference); + Objects.equals(this.reference, created.reference)&& + Objects.equals(this.additionalProperties, created.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, reference); + return Objects.hash(analysisId, binaryId, reference, additionalProperties); } @Override @@ -158,6 +203,7 @@ public String toString() { sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -198,14 +244,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Created.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Created` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Created.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -233,6 +271,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Created value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -240,7 +300,28 @@ public void write(JsonWriter out, Created value) throws IOException { public Created 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 + Created instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/DecompilationCommentContext.java b/src/main/java/ai/reveng/model/DecompilationCommentContext.java index 26a98c0..460dcca 100644 --- a/src/main/java/ai/reveng/model/DecompilationCommentContext.java +++ b/src/main/java/ai/reveng/model/DecompilationCommentContext.java @@ -101,6 +101,50 @@ public void setEndLine(@javax.annotation.Nullable Integer endLine) { this.endLine = endLine; } + /** + * 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 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 DecompilationCommentContext instance itself + */ + public DecompilationCommentContext putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } DecompilationCommentContext decompilationCommentContext = (DecompilationCommentContext) o; return Objects.equals(this.startLine, decompilationCommentContext.startLine) && - Objects.equals(this.endLine, decompilationCommentContext.endLine); + Objects.equals(this.endLine, decompilationCommentContext.endLine)&& + Objects.equals(this.additionalProperties, decompilationCommentContext.additionalProperties); } @Override public int hashCode() { - return Objects.hash(startLine, endLine); + return Objects.hash(startLine, endLine, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class DecompilationCommentContext {\n"); sb.append(" startLine: ").append(toIndentedString(startLine)).append("\n"); sb.append(" endLine: ").append(toIndentedString(endLine)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DecompilationCommentContext.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompilationCommentContext` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompilationCommentContext.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -199,6 +237,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompilationCommentContext value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -206,7 +266,28 @@ public void write(JsonWriter out, DecompilationCommentContext value) throws IOEx public DecompilationCommentContext 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 + DecompilationCommentContext instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/DecompilationResponse.java b/src/main/java/ai/reveng/model/DecompilationResponse.java index c8aeeee..c63bd90 100644 --- a/src/main/java/ai/reveng/model/DecompilationResponse.java +++ b/src/main/java/ai/reveng/model/DecompilationResponse.java @@ -125,6 +125,50 @@ public void setCallingConvention(@javax.annotation.Nonnull String callingConvent this.callingConvention = callingConvention; } + /** + * 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 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 DecompilationResponse instance itself + */ + public DecompilationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { DecompilationResponse decompilationResponse = (DecompilationResponse) o; return Objects.equals(this.functionId, decompilationResponse.functionId) && Objects.equals(this.decompilation, decompilationResponse.decompilation) && - Objects.equals(this.callingConvention, decompilationResponse.callingConvention); + Objects.equals(this.callingConvention, decompilationResponse.callingConvention)&& + Objects.equals(this.additionalProperties, decompilationResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, decompilation, callingConvention); + return Objects.hash(functionId, decompilation, callingConvention, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" decompilation: ").append(toIndentedString(decompilation)).append("\n"); sb.append(" callingConvention: ").append(toIndentedString(callingConvention)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DecompilationResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DecompilationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DecompilationResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DecompilationResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, DecompilationResponse value) throws IOExceptio public DecompilationResponse 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 + DecompilationResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/DieMatch.java b/src/main/java/ai/reveng/model/DieMatch.java index 2758b94..f55813b 100644 --- a/src/main/java/ai/reveng/model/DieMatch.java +++ b/src/main/java/ai/reveng/model/DieMatch.java @@ -149,6 +149,50 @@ public void setVersion(@javax.annotation.Nonnull String version) { this.version = version; } + /** + * 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 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 DieMatch instance itself + */ + public DieMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.name, dieMatch.name) && Objects.equals(this.type, dieMatch.type) && Objects.equals(this.display, dieMatch.display) && - Objects.equals(this.version, dieMatch.version); + Objects.equals(this.version, dieMatch.version)&& + Objects.equals(this.additionalProperties, dieMatch.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, type, display, version); + return Objects.hash(name, type, display, version, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" display: ").append(toIndentedString(display)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -219,14 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!DieMatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `DieMatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : DieMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -263,6 +301,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, DieMatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -270,7 +330,28 @@ public void write(JsonWriter out, DieMatch value) throws IOException { public DieMatch 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 + DieMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFImportModel.java b/src/main/java/ai/reveng/model/ELFImportModel.java index a5229ac..7642fb9 100644 --- a/src/main/java/ai/reveng/model/ELFImportModel.java +++ b/src/main/java/ai/reveng/model/ELFImportModel.java @@ -111,6 +111,50 @@ public void setImports(@javax.annotation.Nonnull List imports) { this.imports = imports; } + /** + * 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 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 ELFImportModel instance itself + */ + public ELFImportModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -123,12 +167,13 @@ public boolean equals(Object o) { } ELFImportModel elFImportModel = (ELFImportModel) o; return Objects.equals(this.numberOfImports, elFImportModel.numberOfImports) && - Objects.equals(this.imports, elFImportModel.imports); + Objects.equals(this.imports, elFImportModel.imports)&& + Objects.equals(this.additionalProperties, elFImportModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(numberOfImports, imports); + return Objects.hash(numberOfImports, imports, additionalProperties); } @Override @@ -137,6 +182,7 @@ public String toString() { sb.append("class ELFImportModel {\n"); sb.append(" numberOfImports: ").append(toIndentedString(numberOfImports)).append("\n"); sb.append(" imports: ").append(toIndentedString(imports)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -177,14 +223,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFImportModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFImportModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFImportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -215,6 +253,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFImportModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -222,7 +282,28 @@ public void write(JsonWriter out, ELFImportModel value) throws IOException { public ELFImportModel 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 + ELFImportModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFModel.java b/src/main/java/ai/reveng/model/ELFModel.java index d8a941c..914a1af 100644 --- a/src/main/java/ai/reveng/model/ELFModel.java +++ b/src/main/java/ai/reveng/model/ELFModel.java @@ -624,6 +624,50 @@ public void setVersionInfo(@javax.annotation.Nonnull Map version this.versionInfo = versionInfo; } + /** + * 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 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 ELFModel instance itself + */ + public ELFModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -654,12 +698,13 @@ public boolean equals(Object o) { Objects.equals(this.dynamicEntries, elFModel.dynamicEntries) && Objects.equals(this.notes, elFModel.notes) && Objects.equals(this.debugInfo, elFModel.debugInfo) && - Objects.equals(this.versionInfo, elFModel.versionInfo); + Objects.equals(this.versionInfo, elFModel.versionInfo)&& + Objects.equals(this.additionalProperties, elFModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(fileType, architecture, endianness, entryPoint, entryPointBytes, importHash, exportHash, buildId, security, sections, segments, symbols, dynamicSymbols, relocations, imports, exportedFunctions, dynamicEntries, notes, debugInfo, versionInfo); + return Objects.hash(fileType, architecture, endianness, entryPoint, entryPointBytes, importHash, exportHash, buildId, security, sections, segments, symbols, dynamicSymbols, relocations, imports, exportedFunctions, dynamicEntries, notes, debugInfo, versionInfo, additionalProperties); } @Override @@ -686,6 +731,7 @@ public String toString() { sb.append(" notes: ").append(toIndentedString(notes)).append("\n"); sb.append(" debugInfo: ").append(toIndentedString(debugInfo)).append("\n"); sb.append(" versionInfo: ").append(toIndentedString(versionInfo)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -726,14 +772,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -855,6 +893,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -862,7 +922,28 @@ public void write(JsonWriter out, ELFModel value) throws IOException { public ELFModel 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 + ELFModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFRelocation.java b/src/main/java/ai/reveng/model/ELFRelocation.java index 82441ba..8b75501 100644 --- a/src/main/java/ai/reveng/model/ELFRelocation.java +++ b/src/main/java/ai/reveng/model/ELFRelocation.java @@ -221,6 +221,50 @@ public void setIsPltgot(@javax.annotation.Nonnull Boolean isPltgot) { this.isPltgot = isPltgot; } + /** + * 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 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 ELFRelocation instance itself + */ + public ELFRelocation putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.addend, elFRelocation.addend) && Objects.equals(this.symbolName, elFRelocation.symbolName) && Objects.equals(this.isDynamic, elFRelocation.isDynamic) && - Objects.equals(this.isPltgot, elFRelocation.isPltgot); + Objects.equals(this.isPltgot, elFRelocation.isPltgot)&& + Objects.equals(this.additionalProperties, elFRelocation.additionalProperties); } @Override public int hashCode() { - return Objects.hash(address, type, size, addend, symbolName, isDynamic, isPltgot); + return Objects.hash(address, type, size, addend, symbolName, isDynamic, isPltgot, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" symbolName: ").append(toIndentedString(symbolName)).append("\n"); sb.append(" isDynamic: ").append(toIndentedString(isDynamic)).append("\n"); sb.append(" isPltgot: ").append(toIndentedString(isPltgot)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -297,14 +343,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFRelocation.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFRelocation` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFRelocation.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -332,6 +370,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFRelocation value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -339,7 +399,28 @@ public void write(JsonWriter out, ELFRelocation value) throws IOException { public ELFRelocation 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 + ELFRelocation instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFSection.java b/src/main/java/ai/reveng/model/ELFSection.java index fbc6e60..d58d44f 100644 --- a/src/main/java/ai/reveng/model/ELFSection.java +++ b/src/main/java/ai/reveng/model/ELFSection.java @@ -294,6 +294,50 @@ public void setAlignment(@javax.annotation.Nonnull Integer alignment) { this.alignment = alignment; } + /** + * 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 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 ELFSection instance itself + */ + public ELFSection putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -314,12 +358,13 @@ public boolean equals(Object o) { Objects.equals(this.flags, elFSection.flags) && Objects.equals(this.flagsRaw, elFSection.flagsRaw) && Objects.equals(this.entropy, elFSection.entropy) && - Objects.equals(this.alignment, elFSection.alignment); + Objects.equals(this.alignment, elFSection.alignment)&& + Objects.equals(this.additionalProperties, elFSection.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, type, virtualAddress, virtualSize, rawSize, fileOffset, flags, flagsRaw, entropy, alignment); + return Objects.hash(name, type, virtualAddress, virtualSize, rawSize, fileOffset, flags, flagsRaw, entropy, alignment, additionalProperties); } @Override @@ -336,6 +381,7 @@ public String toString() { sb.append(" flagsRaw: ").append(toIndentedString(flagsRaw)).append("\n"); sb.append(" entropy: ").append(toIndentedString(entropy)).append("\n"); sb.append(" alignment: ").append(toIndentedString(alignment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -376,14 +422,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFSection.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFSection` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSection.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -417,6 +455,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFSection value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -424,7 +484,28 @@ public void write(JsonWriter out, ELFSection value) throws IOException { public ELFSection 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 + ELFSection instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFSecurity.java b/src/main/java/ai/reveng/model/ELFSecurity.java index fbab05a..5ca6bb4 100644 --- a/src/main/java/ai/reveng/model/ELFSecurity.java +++ b/src/main/java/ai/reveng/model/ELFSecurity.java @@ -173,6 +173,50 @@ public void setRelo(@javax.annotation.Nonnull Boolean relo) { this.relo = relo; } + /** + * 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 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 ELFSecurity instance itself + */ + public ELFSecurity putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.stripped, elFSecurity.stripped) && Objects.equals(this.canary, elFSecurity.canary) && Objects.equals(this.nx, elFSecurity.nx) && - Objects.equals(this.relo, elFSecurity.relo); + Objects.equals(this.relo, elFSecurity.relo)&& + Objects.equals(this.additionalProperties, elFSecurity.additionalProperties); } @Override public int hashCode() { - return Objects.hash(pie, stripped, canary, nx, relo); + return Objects.hash(pie, stripped, canary, nx, relo, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" canary: ").append(toIndentedString(canary)).append("\n"); sb.append(" nx: ").append(toIndentedString(nx)).append("\n"); sb.append(" relo: ").append(toIndentedString(relo)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -245,14 +291,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFSecurity.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFSecurity` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSecurity.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -277,6 +315,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFSecurity value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -284,7 +344,28 @@ public void write(JsonWriter out, ELFSecurity value) throws IOException { public ELFSecurity 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 + ELFSecurity instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFSegment.java b/src/main/java/ai/reveng/model/ELFSegment.java index 5da6661..6e17958 100644 --- a/src/main/java/ai/reveng/model/ELFSegment.java +++ b/src/main/java/ai/reveng/model/ELFSegment.java @@ -269,6 +269,50 @@ public void setAlignment(@javax.annotation.Nonnull Integer alignment) { this.alignment = alignment; } + /** + * 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 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 ELFSegment instance itself + */ + public ELFSegment putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -288,12 +332,13 @@ public boolean equals(Object o) { Objects.equals(this.fileOffset, elFSegment.fileOffset) && Objects.equals(this.flags, elFSegment.flags) && Objects.equals(this.flagsRaw, elFSegment.flagsRaw) && - Objects.equals(this.alignment, elFSegment.alignment); + Objects.equals(this.alignment, elFSegment.alignment)&& + Objects.equals(this.additionalProperties, elFSegment.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, virtualAddress, virtualSize, physicalAddress, physicalSize, fileOffset, flags, flagsRaw, alignment); + return Objects.hash(type, virtualAddress, virtualSize, physicalAddress, physicalSize, fileOffset, flags, flagsRaw, alignment, additionalProperties); } @Override @@ -309,6 +354,7 @@ public String toString() { sb.append(" flags: ").append(toIndentedString(flags)).append("\n"); sb.append(" flagsRaw: ").append(toIndentedString(flagsRaw)).append("\n"); sb.append(" alignment: ").append(toIndentedString(alignment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -349,14 +395,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFSegment.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFSegment` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSegment.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -387,6 +425,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFSegment value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -394,7 +454,28 @@ public void write(JsonWriter out, ELFSegment value) throws IOException { public ELFSegment 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 + ELFSegment instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ELFSymbol.java b/src/main/java/ai/reveng/model/ELFSymbol.java index d7b3db0..861974f 100644 --- a/src/main/java/ai/reveng/model/ELFSymbol.java +++ b/src/main/java/ai/reveng/model/ELFSymbol.java @@ -221,6 +221,50 @@ public void setSectionIndex(@javax.annotation.Nonnull Integer sectionIndex) { this.sectionIndex = sectionIndex; } + /** + * 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 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 ELFSymbol instance itself + */ + public ELFSymbol putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.type, elFSymbol.type) && Objects.equals(this.binding, elFSymbol.binding) && Objects.equals(this.visibility, elFSymbol.visibility) && - Objects.equals(this.sectionIndex, elFSymbol.sectionIndex); + Objects.equals(this.sectionIndex, elFSymbol.sectionIndex)&& + Objects.equals(this.additionalProperties, elFSymbol.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, value, size, type, binding, visibility, sectionIndex); + return Objects.hash(name, value, size, type, binding, visibility, sectionIndex, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" binding: ").append(toIndentedString(binding)).append("\n"); sb.append(" visibility: ").append(toIndentedString(visibility)).append("\n"); sb.append(" sectionIndex: ").append(toIndentedString(sectionIndex)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -297,14 +343,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ELFSymbol.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ELFSymbol` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ELFSymbol.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -341,6 +379,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ELFSymbol value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -348,7 +408,28 @@ public void write(JsonWriter out, ELFSymbol value) throws IOException { public ELFSymbol 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 + ELFSymbol instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ElfDynamicEntry.java b/src/main/java/ai/reveng/model/ElfDynamicEntry.java index 4f5290f..5da3673 100644 --- a/src/main/java/ai/reveng/model/ElfDynamicEntry.java +++ b/src/main/java/ai/reveng/model/ElfDynamicEntry.java @@ -101,6 +101,50 @@ public void setValue(@javax.annotation.Nonnull Integer value) { this.value = value; } + /** + * 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 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 ElfDynamicEntry instance itself + */ + public ElfDynamicEntry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } ElfDynamicEntry elfDynamicEntry = (ElfDynamicEntry) o; return Objects.equals(this.tag, elfDynamicEntry.tag) && - Objects.equals(this.value, elfDynamicEntry.value); + Objects.equals(this.value, elfDynamicEntry.value)&& + Objects.equals(this.additionalProperties, elfDynamicEntry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tag, value); + return Objects.hash(tag, value, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class ElfDynamicEntry {\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ElfDynamicEntry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ElfDynamicEntry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ElfDynamicEntry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ElfDynamicEntry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, ElfDynamicEntry value) throws IOException { public ElfDynamicEntry 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 + ElfDynamicEntry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/EntrypointModel.java b/src/main/java/ai/reveng/model/EntrypointModel.java index bea9c3a..d30d333 100644 --- a/src/main/java/ai/reveng/model/EntrypointModel.java +++ b/src/main/java/ai/reveng/model/EntrypointModel.java @@ -101,6 +101,50 @@ public void setFirstBytes(@javax.annotation.Nonnull String firstBytes) { this.firstBytes = firstBytes; } + /** + * 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 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 EntrypointModel instance itself + */ + public EntrypointModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } EntrypointModel entrypointModel = (EntrypointModel) o; return Objects.equals(this.address, entrypointModel.address) && - Objects.equals(this.firstBytes, entrypointModel.firstBytes); + Objects.equals(this.firstBytes, entrypointModel.firstBytes)&& + Objects.equals(this.additionalProperties, entrypointModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(address, firstBytes); + return Objects.hash(address, firstBytes, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class EntrypointModel {\n"); sb.append(" address: ").append(toIndentedString(address)).append("\n"); sb.append(" firstBytes: ").append(toIndentedString(firstBytes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EntrypointModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `EntrypointModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : EntrypointModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, EntrypointModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, EntrypointModel value) throws IOException { public EntrypointModel 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 + EntrypointModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Enumeration.java b/src/main/java/ai/reveng/model/Enumeration.java index 6334ca6..8eec78e 100644 --- a/src/main/java/ai/reveng/model/Enumeration.java +++ b/src/main/java/ai/reveng/model/Enumeration.java @@ -160,6 +160,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 Enumeration instance itself + */ + public Enumeration putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -174,7 +218,8 @@ public boolean equals(Object o) { return Objects.equals(this.lastChange, enumeration.lastChange) && Objects.equals(this.name, enumeration.name) && Objects.equals(this.members, enumeration.members) && - Objects.equals(this.artifactType, enumeration.artifactType); + Objects.equals(this.artifactType, enumeration.artifactType)&& + Objects.equals(this.additionalProperties, enumeration.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -183,7 +228,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, name, members, artifactType); + return Objects.hash(lastChange, name, members, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -201,6 +246,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" members: ").append(toIndentedString(members)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -241,14 +287,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Enumeration.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Enumeration` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Enumeration.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -282,6 +320,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Enumeration value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -289,7 +349,28 @@ public void write(JsonWriter out, Enumeration value) throws IOException { public Enumeration 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 + Enumeration instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ErrorModel.java b/src/main/java/ai/reveng/model/ErrorModel.java index a693fee..b048324 100644 --- a/src/main/java/ai/reveng/model/ErrorModel.java +++ b/src/main/java/ai/reveng/model/ErrorModel.java @@ -101,6 +101,50 @@ public void setMessage(@javax.annotation.Nonnull String message) { this.message = message; } + /** + * 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 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 ErrorModel instance itself + */ + public ErrorModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } ErrorModel errorModel = (ErrorModel) o; return Objects.equals(this.code, errorModel.code) && - Objects.equals(this.message, errorModel.message); + Objects.equals(this.message, errorModel.message)&& + Objects.equals(this.additionalProperties, errorModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(code, message); + return Objects.hash(code, message, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class ErrorModel {\n"); sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ErrorModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ErrorModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ErrorModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ErrorModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, ErrorModel value) throws IOException { public ErrorModel 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 + ErrorModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ExportModel.java b/src/main/java/ai/reveng/model/ExportModel.java index 211d1f5..11583c8 100644 --- a/src/main/java/ai/reveng/model/ExportModel.java +++ b/src/main/java/ai/reveng/model/ExportModel.java @@ -112,6 +112,50 @@ public void setExports(@javax.annotation.Nonnull List> expo this.exports = exports; } + /** + * 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 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 ExportModel instance itself + */ + public ExportModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } ExportModel exportModel = (ExportModel) o; return Objects.equals(this.numberOfExports, exportModel.numberOfExports) && - Objects.equals(this.exports, exportModel.exports); + Objects.equals(this.exports, exportModel.exports)&& + Objects.equals(this.additionalProperties, exportModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(numberOfExports, exports); + return Objects.hash(numberOfExports, exports, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class ExportModel {\n"); sb.append(" numberOfExports: ").append(toIndentedString(numberOfExports)).append("\n"); sb.append(" exports: ").append(toIndentedString(exports)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ExportModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ExportModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -216,6 +254,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ExportModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -223,7 +283,28 @@ public void write(JsonWriter out, ExportModel value) throws IOException { public ExportModel 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 + ExportModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ExportedBinaryAnnResult.java b/src/main/java/ai/reveng/model/ExportedBinaryAnnResult.java index 63dd0f8..9eb1d69 100644 --- a/src/main/java/ai/reveng/model/ExportedBinaryAnnResult.java +++ b/src/main/java/ai/reveng/model/ExportedBinaryAnnResult.java @@ -297,6 +297,50 @@ public void setTags(@javax.annotation.Nullable List 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 ExportedBinaryAnnResult instance itself + */ + public ExportedBinaryAnnResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -316,12 +360,13 @@ public boolean equals(Object o) { Objects.equals(this.embedding3d, exportedBinaryAnnResult.embedding3d) && Objects.equals(this.embedding1d, exportedBinaryAnnResult.embedding1d) && Objects.equals(this.confidence, exportedBinaryAnnResult.confidence) && - Objects.equals(this.tags, exportedBinaryAnnResult.tags); + Objects.equals(this.tags, exportedBinaryAnnResult.tags)&& + Objects.equals(this.additionalProperties, exportedBinaryAnnResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, binaryId, binaryName, sha256Hash, analysisScope, embedding3d, embedding1d, confidence, tags); + return Objects.hash(analysisId, binaryId, binaryName, sha256Hash, analysisScope, embedding3d, embedding1d, confidence, tags, additionalProperties); } @Override @@ -337,6 +382,7 @@ public String toString() { sb.append(" embedding1d: ").append(toIndentedString(embedding1d)).append("\n"); sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -377,14 +423,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ExportedBinaryAnnResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ExportedBinaryAnnResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExportedBinaryAnnResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -444,6 +482,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ExportedBinaryAnnResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -451,7 +511,28 @@ public void write(JsonWriter out, ExportedBinaryAnnResult value) throws IOExcept public ExportedBinaryAnnResult 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 + ExportedBinaryAnnResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ExternalResponse.java b/src/main/java/ai/reveng/model/ExternalResponse.java index fe6f8f9..b1c1915 100644 --- a/src/main/java/ai/reveng/model/ExternalResponse.java +++ b/src/main/java/ai/reveng/model/ExternalResponse.java @@ -136,6 +136,50 @@ public void setLastUpdated(@javax.annotation.Nonnull OffsetDateTime lastUpdated) this.lastUpdated = lastUpdated; } + /** + * 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 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 ExternalResponse instance itself + */ + public ExternalResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { ExternalResponse externalResponse = (ExternalResponse) o; return Objects.equals(this.sha256Hash, externalResponse.sha256Hash) && Objects.equals(this.data, externalResponse.data) && - Objects.equals(this.lastUpdated, externalResponse.lastUpdated); + Objects.equals(this.lastUpdated, externalResponse.lastUpdated)&& + Objects.equals(this.additionalProperties, externalResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sha256Hash, data, lastUpdated); + return Objects.hash(sha256Hash, data, lastUpdated, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); sb.append(" lastUpdated: ").append(toIndentedString(lastUpdated)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ExternalResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ExternalResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ExternalResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -239,6 +277,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ExternalResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -246,7 +306,28 @@ public void write(JsonWriter out, ExternalResponse value) throws IOException { public ExternalResponse 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 + ExternalResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FileHashes.java b/src/main/java/ai/reveng/model/FileHashes.java index 15427d3..53e4328 100644 --- a/src/main/java/ai/reveng/model/FileHashes.java +++ b/src/main/java/ai/reveng/model/FileHashes.java @@ -245,6 +245,50 @@ public void setSha3512(@javax.annotation.Nullable String sha3512) { this.sha3512 = sha3512; } + /** + * 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 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 FileHashes instance itself + */ + public FileHashes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -263,12 +307,13 @@ public boolean equals(Object o) { Objects.equals(this.sha3224, fileHashes.sha3224) && Objects.equals(this.sha3256, fileHashes.sha3256) && Objects.equals(this.sha3384, fileHashes.sha3384) && - Objects.equals(this.sha3512, fileHashes.sha3512); + Objects.equals(this.sha3512, fileHashes.sha3512)&& + Objects.equals(this.additionalProperties, fileHashes.additionalProperties); } @Override public int hashCode() { - return Objects.hash(md5, sha1, sha256, sha512, sha3224, sha3256, sha3384, sha3512); + return Objects.hash(md5, sha1, sha256, sha512, sha3224, sha3256, sha3384, sha3512, additionalProperties); } @Override @@ -283,6 +328,7 @@ public String toString() { sb.append(" sha3256: ").append(toIndentedString(sha3256)).append("\n"); sb.append(" sha3384: ").append(toIndentedString(sha3384)).append("\n"); sb.append(" sha3512: ").append(toIndentedString(sha3512)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -323,14 +369,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FileHashes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FileHashes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileHashes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -379,6 +417,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FileHashes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -386,7 +446,28 @@ public void write(JsonWriter out, FileHashes value) throws IOException { public FileHashes 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 + FileHashes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FileMetadata.java b/src/main/java/ai/reveng/model/FileMetadata.java index 490c7db..d4cf37f 100644 --- a/src/main/java/ai/reveng/model/FileMetadata.java +++ b/src/main/java/ai/reveng/model/FileMetadata.java @@ -151,6 +151,50 @@ public void setHashes(@javax.annotation.Nonnull FileHashes hashes) { this.hashes = hashes; } + /** + * 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 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 FileMetadata instance itself + */ + public FileMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -165,12 +209,13 @@ public boolean equals(Object o) { return Objects.equals(this.size, fileMetadata.size) && Objects.equals(this.friendlySize, fileMetadata.friendlySize) && Objects.equals(this.entropy, fileMetadata.entropy) && - Objects.equals(this.hashes, fileMetadata.hashes); + Objects.equals(this.hashes, fileMetadata.hashes)&& + Objects.equals(this.additionalProperties, fileMetadata.additionalProperties); } @Override public int hashCode() { - return Objects.hash(size, friendlySize, entropy, hashes); + return Objects.hash(size, friendlySize, entropy, hashes, additionalProperties); } @Override @@ -181,6 +226,7 @@ public String toString() { sb.append(" friendlySize: ").append(toIndentedString(friendlySize)).append("\n"); sb.append(" entropy: ").append(toIndentedString(entropy)).append("\n"); sb.append(" hashes: ").append(toIndentedString(hashes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -221,14 +267,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FileMetadata.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FileMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FileMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -258,6 +296,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FileMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -265,7 +325,28 @@ public void write(JsonWriter out, FileMetadata value) throws IOException { public FileMetadata 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 + FileMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java b/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java index 397c6fb..e32e311 100644 --- a/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlockDestinationResponse.java @@ -125,6 +125,50 @@ public void setVaddr(@javax.annotation.Nonnull String vaddr) { this.vaddr = vaddr; } + /** + * 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 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 FunctionBlockDestinationResponse instance itself + */ + public FunctionBlockDestinationResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { FunctionBlockDestinationResponse functionBlockDestinationResponse = (FunctionBlockDestinationResponse) o; return Objects.equals(this.destinationBlockId, functionBlockDestinationResponse.destinationBlockId) && Objects.equals(this.flowtype, functionBlockDestinationResponse.flowtype) && - Objects.equals(this.vaddr, functionBlockDestinationResponse.vaddr); + Objects.equals(this.vaddr, functionBlockDestinationResponse.vaddr)&& + Objects.equals(this.additionalProperties, functionBlockDestinationResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(destinationBlockId, flowtype, vaddr); + return Objects.hash(destinationBlockId, flowtype, vaddr, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" destinationBlockId: ").append(toIndentedString(destinationBlockId)).append("\n"); sb.append(" flowtype: ").append(toIndentedString(flowtype)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionBlockDestinationResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionBlockDestinationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlockDestinationResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionBlockDestinationResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, FunctionBlockDestinationResponse value) throws public FunctionBlockDestinationResponse 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 + FunctionBlockDestinationResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionBlockResponse.java b/src/main/java/ai/reveng/model/FunctionBlockResponse.java index e1b7fdc..b77075d 100644 --- a/src/main/java/ai/reveng/model/FunctionBlockResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlockResponse.java @@ -217,6 +217,50 @@ public void setComment(@javax.annotation.Nullable String comment) { this.comment = comment; } + /** + * 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 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 FunctionBlockResponse instance itself + */ + public FunctionBlockResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -233,7 +277,8 @@ public boolean equals(Object o) { Objects.equals(this.minAddr, functionBlockResponse.minAddr) && Objects.equals(this.maxAddr, functionBlockResponse.maxAddr) && Objects.equals(this.destinations, functionBlockResponse.destinations) && - Objects.equals(this.comment, functionBlockResponse.comment); + Objects.equals(this.comment, functionBlockResponse.comment)&& + Objects.equals(this.additionalProperties, functionBlockResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -242,7 +287,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(asm, id, minAddr, maxAddr, destinations, comment); + return Objects.hash(asm, id, minAddr, maxAddr, destinations, comment, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -262,6 +307,7 @@ public String toString() { sb.append(" maxAddr: ").append(toIndentedString(maxAddr)).append("\n"); sb.append(" destinations: ").append(toIndentedString(destinations)).append("\n"); sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -302,14 +348,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionBlockResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionBlockResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlockResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -353,6 +391,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionBlockResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -360,7 +420,28 @@ public void write(JsonWriter out, FunctionBlockResponse value) throws IOExceptio public FunctionBlockResponse 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 + FunctionBlockResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionBlocksResponse.java b/src/main/java/ai/reveng/model/FunctionBlocksResponse.java index e35035d..2810064 100644 --- a/src/main/java/ai/reveng/model/FunctionBlocksResponse.java +++ b/src/main/java/ai/reveng/model/FunctionBlocksResponse.java @@ -178,6 +178,50 @@ public void setOverviewComment(@javax.annotation.Nullable String overviewComment this.overviewComment = overviewComment; } + /** + * 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 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 FunctionBlocksResponse instance itself + */ + public FunctionBlocksResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -192,12 +236,13 @@ public boolean equals(Object o) { return Objects.equals(this.blocks, functionBlocksResponse.blocks) && Objects.equals(this.localVariables, functionBlocksResponse.localVariables) && Objects.equals(this.params, functionBlocksResponse.params) && - Objects.equals(this.overviewComment, functionBlocksResponse.overviewComment); + Objects.equals(this.overviewComment, functionBlocksResponse.overviewComment)&& + Objects.equals(this.additionalProperties, functionBlocksResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(blocks, localVariables, params, overviewComment); + return Objects.hash(blocks, localVariables, params, overviewComment, additionalProperties); } @Override @@ -208,6 +253,7 @@ public String toString() { sb.append(" localVariables: ").append(toIndentedString(localVariables)).append("\n"); sb.append(" params: ").append(toIndentedString(params)).append("\n"); sb.append(" overviewComment: ").append(toIndentedString(overviewComment)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -248,14 +294,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionBlocksResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionBlocksResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBlocksResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -313,6 +351,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionBlocksResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -320,7 +380,28 @@ public void write(JsonWriter out, FunctionBlocksResponse value) throws IOExcepti public FunctionBlocksResponse 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 + FunctionBlocksResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionBoundary.java b/src/main/java/ai/reveng/model/FunctionBoundary.java index 2de814b..b703424 100644 --- a/src/main/java/ai/reveng/model/FunctionBoundary.java +++ b/src/main/java/ai/reveng/model/FunctionBoundary.java @@ -125,6 +125,50 @@ public void setEndAddress(@javax.annotation.Nonnull Long endAddress) { this.endAddress = endAddress; } + /** + * 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 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 FunctionBoundary instance itself + */ + public FunctionBoundary putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { FunctionBoundary functionBoundary = (FunctionBoundary) o; return Objects.equals(this.mangledName, functionBoundary.mangledName) && Objects.equals(this.startAddress, functionBoundary.startAddress) && - Objects.equals(this.endAddress, functionBoundary.endAddress); + Objects.equals(this.endAddress, functionBoundary.endAddress)&& + Objects.equals(this.additionalProperties, functionBoundary.additionalProperties); } @Override public int hashCode() { - return Objects.hash(mangledName, startAddress, endAddress); + return Objects.hash(mangledName, startAddress, endAddress, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" mangledName: ").append(toIndentedString(mangledName)).append("\n"); sb.append(" startAddress: ").append(toIndentedString(startAddress)).append("\n"); sb.append(" endAddress: ").append(toIndentedString(endAddress)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionBoundary.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionBoundary` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBoundary.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -228,6 +266,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionBoundary value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -235,7 +295,28 @@ public void write(JsonWriter out, FunctionBoundary value) throws IOException { public FunctionBoundary 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 + FunctionBoundary instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionBoxPlotConfidence.java b/src/main/java/ai/reveng/model/FunctionBoxPlotConfidence.java index c45bf39..9aa9d81 100644 --- a/src/main/java/ai/reveng/model/FunctionBoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/FunctionBoxPlotConfidence.java @@ -102,6 +102,50 @@ public void setBoxPlot(@javax.annotation.Nonnull BoxPlotConfidence boxPlot) { this.boxPlot = boxPlot; } + /** + * 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 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 FunctionBoxPlotConfidence instance itself + */ + public FunctionBoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } FunctionBoxPlotConfidence functionBoxPlotConfidence = (FunctionBoxPlotConfidence) o; return Objects.equals(this.functionId, functionBoxPlotConfidence.functionId) && - Objects.equals(this.boxPlot, functionBoxPlotConfidence.boxPlot); + Objects.equals(this.boxPlot, functionBoxPlotConfidence.boxPlot)&& + Objects.equals(this.additionalProperties, functionBoxPlotConfidence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, boxPlot); + return Objects.hash(functionId, boxPlot, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class FunctionBoxPlotConfidence {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" boxPlot: ").append(toIndentedString(boxPlot)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionBoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionBoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionBoxPlotConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionBoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, FunctionBoxPlotConfidence value) throws IOExce public FunctionBoxPlotConfidence 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 + FunctionBoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java b/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java index fd06642..0f07b69 100644 --- a/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java +++ b/src/main/java/ai/reveng/model/FunctionCapabilityResponse.java @@ -87,6 +87,50 @@ public void setCapabilities(@javax.annotation.Nonnull List capabilities) this.capabilities = capabilities; } + /** + * 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 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 FunctionCapabilityResponse instance itself + */ + public FunctionCapabilityResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } FunctionCapabilityResponse functionCapabilityResponse = (FunctionCapabilityResponse) o; - return Objects.equals(this.capabilities, functionCapabilityResponse.capabilities); + return Objects.equals(this.capabilities, functionCapabilityResponse.capabilities)&& + Objects.equals(this.additionalProperties, functionCapabilityResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(capabilities); + return Objects.hash(capabilities, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FunctionCapabilityResponse {\n"); sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionCapabilityResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionCapabilityResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionCapabilityResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionCapabilityResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, FunctionCapabilityResponse value) throws IOExc public FunctionCapabilityResponse 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 + FunctionCapabilityResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java b/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java index 7990bb2..0565d02 100644 --- a/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java +++ b/src/main/java/ai/reveng/model/FunctionCommentCreateRequest.java @@ -102,6 +102,50 @@ public void setContext(@javax.annotation.Nullable DecompilationCommentContext co this.context = context; } + /** + * 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 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 FunctionCommentCreateRequest instance itself + */ + public FunctionCommentCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } FunctionCommentCreateRequest functionCommentCreateRequest = (FunctionCommentCreateRequest) o; return Objects.equals(this.content, functionCommentCreateRequest.content) && - Objects.equals(this.context, functionCommentCreateRequest.context); + Objects.equals(this.context, functionCommentCreateRequest.context)&& + Objects.equals(this.additionalProperties, functionCommentCreateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(content, context); + return Objects.hash(content, context, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class FunctionCommentCreateRequest {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionCommentCreateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionCommentCreateRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionCommentCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -207,6 +245,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionCommentCreateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -214,7 +274,28 @@ public void write(JsonWriter out, FunctionCommentCreateRequest value) throws IOE public FunctionCommentCreateRequest 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 + FunctionCommentCreateRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionDataTypes.java b/src/main/java/ai/reveng/model/FunctionDataTypes.java index 111bf0f..93804fe 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypes.java @@ -151,6 +151,50 @@ public void setDataTypesVersion(@javax.annotation.Nullable Integer dataTypesVers this.dataTypesVersion = dataTypesVersion; } + /** + * 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 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 FunctionDataTypes instance itself + */ + public FunctionDataTypes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -165,7 +209,8 @@ public boolean equals(Object o) { return Objects.equals(this.completed, functionDataTypes.completed) && Objects.equals(this.status, functionDataTypes.status) && Objects.equals(this.dataTypes, functionDataTypes.dataTypes) && - Objects.equals(this.dataTypesVersion, functionDataTypes.dataTypesVersion); + Objects.equals(this.dataTypesVersion, functionDataTypes.dataTypesVersion)&& + Objects.equals(this.additionalProperties, functionDataTypes.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -174,7 +219,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(completed, status, dataTypes, dataTypesVersion); + return Objects.hash(completed, status, dataTypes, dataTypesVersion, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -192,6 +237,7 @@ public String toString() { sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); sb.append(" dataTypesVersion: ").append(toIndentedString(dataTypesVersion)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -232,14 +278,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataTypes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataTypes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -271,6 +309,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataTypes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -278,7 +338,28 @@ public void write(JsonWriter out, FunctionDataTypes value) throws IOException { public FunctionDataTypes 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 + FunctionDataTypes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesList.java b/src/main/java/ai/reveng/model/FunctionDataTypesList.java index 3b6dd6f..316dc24 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesList.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesList.java @@ -136,6 +136,50 @@ public void setItems(@javax.annotation.Nonnull List i this.items = items; } + /** + * 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 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 FunctionDataTypesList instance itself + */ + public FunctionDataTypesList putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { FunctionDataTypesList functionDataTypesList = (FunctionDataTypesList) o; return Objects.equals(this.totalCount, functionDataTypesList.totalCount) && Objects.equals(this.totalDataTypesCount, functionDataTypesList.totalDataTypesCount) && - Objects.equals(this.items, functionDataTypesList.items); + Objects.equals(this.items, functionDataTypesList.items)&& + Objects.equals(this.additionalProperties, functionDataTypesList.additionalProperties); } @Override public int hashCode() { - return Objects.hash(totalCount, totalDataTypesCount, items); + return Objects.hash(totalCount, totalDataTypesCount, items, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); sb.append(" totalDataTypesCount: ").append(toIndentedString(totalDataTypesCount)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataTypesList.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataTypesList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesList.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -246,6 +284,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataTypesList value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -253,7 +313,28 @@ public void write(JsonWriter out, FunctionDataTypesList value) throws IOExceptio public FunctionDataTypesList 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 + FunctionDataTypesList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java b/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java index 958b9d2..bb1a08e 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesListItem.java @@ -175,6 +175,50 @@ public void setFunctionId(@javax.annotation.Nonnull Integer functionId) { this.functionId = functionId; } + /** + * 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 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 FunctionDataTypesListItem instance itself + */ + public FunctionDataTypesListItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -190,7 +234,8 @@ public boolean equals(Object o) { Objects.equals(this.status, functionDataTypesListItem.status) && Objects.equals(this.dataTypes, functionDataTypesListItem.dataTypes) && Objects.equals(this.dataTypesVersion, functionDataTypesListItem.dataTypesVersion) && - Objects.equals(this.functionId, functionDataTypesListItem.functionId); + Objects.equals(this.functionId, functionDataTypesListItem.functionId)&& + Objects.equals(this.additionalProperties, functionDataTypesListItem.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -199,7 +244,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(completed, status, dataTypes, dataTypesVersion, functionId); + return Objects.hash(completed, status, dataTypes, dataTypesVersion, functionId, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -218,6 +263,7 @@ public String toString() { sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); sb.append(" dataTypesVersion: ").append(toIndentedString(dataTypesVersion)).append("\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -258,14 +304,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataTypesListItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataTypesListItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesListItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -297,6 +335,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataTypesListItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -304,7 +364,28 @@ public void write(JsonWriter out, FunctionDataTypesListItem value) throws IOExce public FunctionDataTypesListItem 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 + FunctionDataTypesListItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesParams.java b/src/main/java/ai/reveng/model/FunctionDataTypesParams.java index 4a4e815..ff46506 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesParams.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesParams.java @@ -87,6 +87,50 @@ public void setFunctionIds(@javax.annotation.Nonnull List functionIds) this.functionIds = functionIds; } + /** + * 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 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 FunctionDataTypesParams instance itself + */ + public FunctionDataTypesParams putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } FunctionDataTypesParams functionDataTypesParams = (FunctionDataTypesParams) o; - return Objects.equals(this.functionIds, functionDataTypesParams.functionIds); + return Objects.equals(this.functionIds, functionDataTypesParams.functionIds)&& + Objects.equals(this.additionalProperties, functionDataTypesParams.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionIds); + return Objects.hash(functionIds, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FunctionDataTypesParams {\n"); sb.append(" functionIds: ").append(toIndentedString(functionIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataTypesParams.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataTypesParams` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesParams.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataTypesParams value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, FunctionDataTypesParams value) throws IOExcept public FunctionDataTypesParams 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 + FunctionDataTypesParams instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java b/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java index bcb349d..0cd8d8f 100644 --- a/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java +++ b/src/main/java/ai/reveng/model/FunctionDataTypesStatus.java @@ -125,6 +125,50 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } + /** + * 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 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 FunctionDataTypesStatus instance itself + */ + public FunctionDataTypesStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { FunctionDataTypesStatus functionDataTypesStatus = (FunctionDataTypesStatus) o; return Objects.equals(this.functionId, functionDataTypesStatus.functionId) && Objects.equals(this.completed, functionDataTypesStatus.completed) && - Objects.equals(this.status, functionDataTypesStatus.status); + Objects.equals(this.status, functionDataTypesStatus.status)&& + Objects.equals(this.additionalProperties, functionDataTypesStatus.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, completed, status); + return Objects.hash(functionId, completed, status, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" completed: ").append(toIndentedString(completed)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionDataTypesStatus.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionDataTypesStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionDataTypesStatus.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -228,6 +266,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionDataTypesStatus value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -235,7 +295,28 @@ public void write(JsonWriter out, FunctionDataTypesStatus value) throws IOExcept public FunctionDataTypesStatus 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 + FunctionDataTypesStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionHeader.java b/src/main/java/ai/reveng/model/FunctionHeader.java index 561e20d..2b76652 100644 --- a/src/main/java/ai/reveng/model/FunctionHeader.java +++ b/src/main/java/ai/reveng/model/FunctionHeader.java @@ -185,6 +185,50 @@ public void setArgs(@javax.annotation.Nonnull Map args) { this.args = args; } + /** + * 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 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 FunctionHeader instance itself + */ + public FunctionHeader putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -200,7 +244,8 @@ public boolean equals(Object o) { Objects.equals(this.name, functionHeader.name) && Objects.equals(this.addr, functionHeader.addr) && Objects.equals(this.type, functionHeader.type) && - Objects.equals(this.args, functionHeader.args); + Objects.equals(this.args, functionHeader.args)&& + Objects.equals(this.additionalProperties, functionHeader.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -209,7 +254,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, name, addr, type, args); + return Objects.hash(lastChange, name, addr, type, args, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -228,6 +273,7 @@ public String toString() { sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" args: ").append(toIndentedString(args)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionHeader.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionHeader` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionHeader.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,6 +347,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionHeader value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -316,7 +376,28 @@ public void write(JsonWriter out, FunctionHeader value) throws IOException { public FunctionHeader 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 + FunctionHeader instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionInfoInput.java b/src/main/java/ai/reveng/model/FunctionInfoInput.java index 8367b8c..1958b1d 100644 --- a/src/main/java/ai/reveng/model/FunctionInfoInput.java +++ b/src/main/java/ai/reveng/model/FunctionInfoInput.java @@ -114,6 +114,50 @@ public void setFuncDeps(@javax.annotation.Nonnull List 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 FunctionInfoInput instance itself + */ + public FunctionInfoInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -126,7 +170,8 @@ public boolean equals(Object o) { } FunctionInfoInput functionInfoInput = (FunctionInfoInput) o; return Objects.equals(this.funcTypes, functionInfoInput.funcTypes) && - Objects.equals(this.funcDeps, functionInfoInput.funcDeps); + Objects.equals(this.funcDeps, functionInfoInput.funcDeps)&& + Objects.equals(this.additionalProperties, functionInfoInput.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -135,7 +180,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(funcTypes, funcDeps); + return Objects.hash(funcTypes, funcDeps, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -151,6 +196,7 @@ public String toString() { sb.append("class FunctionInfoInput {\n"); sb.append(" funcTypes: ").append(toIndentedString(funcTypes)).append("\n"); sb.append(" funcDeps: ").append(toIndentedString(funcDeps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -191,14 +237,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionInfoInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionInfoInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionInfoInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -237,6 +275,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionInfoInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -244,7 +304,28 @@ public void write(JsonWriter out, FunctionInfoInput value) throws IOException { public FunctionInfoInput 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 + FunctionInfoInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionInfoOutput.java b/src/main/java/ai/reveng/model/FunctionInfoOutput.java index 3a2d9d1..3ea4f78 100644 --- a/src/main/java/ai/reveng/model/FunctionInfoOutput.java +++ b/src/main/java/ai/reveng/model/FunctionInfoOutput.java @@ -114,6 +114,50 @@ public void setFuncDeps(@javax.annotation.Nonnull List 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 FunctionInfoOutput instance itself + */ + public FunctionInfoOutput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -126,7 +170,8 @@ public boolean equals(Object o) { } FunctionInfoOutput functionInfoOutput = (FunctionInfoOutput) o; return Objects.equals(this.funcTypes, functionInfoOutput.funcTypes) && - Objects.equals(this.funcDeps, functionInfoOutput.funcDeps); + Objects.equals(this.funcDeps, functionInfoOutput.funcDeps)&& + Objects.equals(this.additionalProperties, functionInfoOutput.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -135,7 +180,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(funcTypes, funcDeps); + return Objects.hash(funcTypes, funcDeps, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -151,6 +196,7 @@ public String toString() { sb.append("class FunctionInfoOutput {\n"); sb.append(" funcTypes: ").append(toIndentedString(funcTypes)).append("\n"); sb.append(" funcDeps: ").append(toIndentedString(funcDeps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -191,14 +237,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionInfoOutput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionInfoOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionInfoOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -237,6 +275,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionInfoOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -244,7 +304,28 @@ public void write(JsonWriter out, FunctionInfoOutput value) throws IOException { public FunctionInfoOutput 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 + FunctionInfoOutput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java b/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java index 794c5ed..5a25bad 100644 --- a/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java +++ b/src/main/java/ai/reveng/model/FunctionLocalVariableResponse.java @@ -173,6 +173,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * 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 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 FunctionLocalVariableResponse instance itself + */ + public FunctionLocalVariableResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.dType, functionLocalVariableResponse.dType) && Objects.equals(this.size, functionLocalVariableResponse.size) && Objects.equals(this.loc, functionLocalVariableResponse.loc) && - Objects.equals(this.name, functionLocalVariableResponse.name); + Objects.equals(this.name, functionLocalVariableResponse.name)&& + Objects.equals(this.additionalProperties, functionLocalVariableResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(address, dType, size, loc, name); + return Objects.hash(address, dType, size, loc, name, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" loc: ").append(toIndentedString(loc)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -245,14 +291,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionLocalVariableResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionLocalVariableResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionLocalVariableResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -289,6 +327,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionLocalVariableResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -296,7 +356,28 @@ public void write(JsonWriter out, FunctionLocalVariableResponse value) throws IO public FunctionLocalVariableResponse 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 + FunctionLocalVariableResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMapping.java b/src/main/java/ai/reveng/model/FunctionMapping.java index 7104323..09c9600 100644 --- a/src/main/java/ai/reveng/model/FunctionMapping.java +++ b/src/main/java/ai/reveng/model/FunctionMapping.java @@ -151,6 +151,50 @@ public void setNameMap(@javax.annotation.Nonnull Map nameMap) { this.nameMap = nameMap; } + /** + * 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 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 FunctionMapping instance itself + */ + public FunctionMapping putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -164,12 +208,13 @@ public boolean equals(Object o) { FunctionMapping functionMapping = (FunctionMapping) o; return Objects.equals(this.functionMap, functionMapping.functionMap) && Objects.equals(this.inverseFunctionMap, functionMapping.inverseFunctionMap) && - Objects.equals(this.nameMap, functionMapping.nameMap); + Objects.equals(this.nameMap, functionMapping.nameMap)&& + Objects.equals(this.additionalProperties, functionMapping.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionMap, inverseFunctionMap, nameMap); + return Objects.hash(functionMap, inverseFunctionMap, nameMap, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" functionMap: ").append(toIndentedString(functionMap)).append("\n"); sb.append(" inverseFunctionMap: ").append(toIndentedString(inverseFunctionMap)).append("\n"); sb.append(" nameMap: ").append(toIndentedString(nameMap)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -219,14 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMapping.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMapping` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMapping.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -251,6 +289,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMapping value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -258,7 +318,28 @@ public void write(JsonWriter out, FunctionMapping value) throws IOException { public FunctionMapping 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 + FunctionMapping instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMappingFull.java b/src/main/java/ai/reveng/model/FunctionMappingFull.java index b288e2d..61e06c8 100644 --- a/src/main/java/ai/reveng/model/FunctionMappingFull.java +++ b/src/main/java/ai/reveng/model/FunctionMappingFull.java @@ -410,6 +410,50 @@ public void setFields(@javax.annotation.Nonnull Map 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 FunctionMappingFull instance itself + */ + public FunctionMappingFull putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -431,12 +475,13 @@ public boolean equals(Object o) { Objects.equals(this.unmatchedGoToLabels, functionMappingFull.unmatchedGoToLabels) && Objects.equals(this.unmatchedCustomFunctionPointers, functionMappingFull.unmatchedCustomFunctionPointers) && Objects.equals(this.unmatchedVariadicLists, functionMappingFull.unmatchedVariadicLists) && - Objects.equals(this.fields, functionMappingFull.fields); + Objects.equals(this.fields, functionMappingFull.fields)&& + Objects.equals(this.additionalProperties, functionMappingFull.additionalProperties); } @Override public int hashCode() { - return Objects.hash(inverseStringMap, inverseFunctionMap, unmatchedFunctions, unmatchedExternalVars, unmatchedCustomTypes, unmatchedStrings, unmatchedVars, unmatchedGoToLabels, unmatchedCustomFunctionPointers, unmatchedVariadicLists, fields); + return Objects.hash(inverseStringMap, inverseFunctionMap, unmatchedFunctions, unmatchedExternalVars, unmatchedCustomTypes, unmatchedStrings, unmatchedVars, unmatchedGoToLabels, unmatchedCustomFunctionPointers, unmatchedVariadicLists, fields, additionalProperties); } @Override @@ -454,6 +499,7 @@ public String toString() { sb.append(" unmatchedCustomFunctionPointers: ").append(toIndentedString(unmatchedCustomFunctionPointers)).append("\n"); sb.append(" unmatchedVariadicLists: ").append(toIndentedString(unmatchedVariadicLists)).append("\n"); sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -494,14 +540,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMappingFull.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMappingFull` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMappingFull.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -526,6 +564,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMappingFull value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -533,7 +593,28 @@ public void write(JsonWriter out, FunctionMappingFull value) throws IOException public FunctionMappingFull 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 + FunctionMappingFull instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMatchingBatchResponse.java b/src/main/java/ai/reveng/model/FunctionMatchingBatchResponse.java index b43a38e..f213255 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingBatchResponse.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingBatchResponse.java @@ -233,6 +233,50 @@ public void setMatches(@javax.annotation.Nonnull List 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 FunctionMatchingBatchResponse instance itself + */ + public FunctionMatchingBatchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -250,7 +294,8 @@ public boolean equals(Object o) { Objects.equals(this.errorMessage, functionMatchingBatchResponse.errorMessage) && Objects.equals(this.currentPage, functionMatchingBatchResponse.currentPage) && Objects.equals(this.totalPages, functionMatchingBatchResponse.totalPages) && - Objects.equals(this.matches, functionMatchingBatchResponse.matches); + Objects.equals(this.matches, functionMatchingBatchResponse.matches)&& + Objects.equals(this.additionalProperties, functionMatchingBatchResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -259,7 +304,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(progress, status, totalTime, errorMessage, currentPage, totalPages, matches); + return Objects.hash(progress, status, totalTime, errorMessage, currentPage, totalPages, matches, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -280,6 +325,7 @@ public String toString() { sb.append(" currentPage: ").append(toIndentedString(currentPage)).append("\n"); sb.append(" totalPages: ").append(toIndentedString(totalPages)).append("\n"); sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -320,14 +366,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMatchingBatchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMatchingBatchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatchingBatchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -368,6 +406,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMatchingBatchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -375,7 +435,28 @@ public void write(JsonWriter out, FunctionMatchingBatchResponse value) throws IO public FunctionMatchingBatchResponse 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 + FunctionMatchingBatchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMatchingFilters.java b/src/main/java/ai/reveng/model/FunctionMatchingFilters.java index 4d5345e..acfff60 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingFilters.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingFilters.java @@ -237,6 +237,50 @@ public void setDebugTypes(@javax.annotation.Nullable List debugT this.debugTypes = debugTypes; } + /** + * 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 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 FunctionMatchingFilters instance itself + */ + public FunctionMatchingFilters putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -251,12 +295,13 @@ public boolean equals(Object o) { return Objects.equals(this.binaryIds, functionMatchingFilters.binaryIds) && Objects.equals(this.collectionIds, functionMatchingFilters.collectionIds) && Objects.equals(this.functionIds, functionMatchingFilters.functionIds) && - Objects.equals(this.debugTypes, functionMatchingFilters.debugTypes); + Objects.equals(this.debugTypes, functionMatchingFilters.debugTypes)&& + Objects.equals(this.additionalProperties, functionMatchingFilters.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryIds, collectionIds, functionIds, debugTypes); + return Objects.hash(binaryIds, collectionIds, functionIds, debugTypes, additionalProperties); } @Override @@ -267,6 +312,7 @@ public String toString() { sb.append(" collectionIds: ").append(toIndentedString(collectionIds)).append("\n"); sb.append(" functionIds: ").append(toIndentedString(functionIds)).append("\n"); sb.append(" debugTypes: ").append(toIndentedString(debugTypes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -306,14 +352,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionMatchingFilters is not found in the empty JSON string", FunctionMatchingFilters.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMatchingFilters.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMatchingFilters` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("binary_ids") != null && !jsonObj.get("binary_ids").isJsonNull() && !jsonObj.get("binary_ids").isJsonArray()) { @@ -348,6 +386,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMatchingFilters value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -355,7 +415,28 @@ public void write(JsonWriter out, FunctionMatchingFilters value) throws IOExcept public FunctionMatchingFilters 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 + FunctionMatchingFilters instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMatchingRequest.java b/src/main/java/ai/reveng/model/FunctionMatchingRequest.java index 7b4f4a4..9661793 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingRequest.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingRequest.java @@ -241,6 +241,50 @@ public void setPageSize(@javax.annotation.Nullable Integer pageSize) { this.pageSize = pageSize; } + /** + * 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 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 FunctionMatchingRequest instance itself + */ + public FunctionMatchingRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -258,7 +302,8 @@ public boolean equals(Object o) { Objects.equals(this.filters, functionMatchingRequest.filters) && Objects.equals(this.resultsPerFunction, functionMatchingRequest.resultsPerFunction) && Objects.equals(this.page, functionMatchingRequest.page) && - Objects.equals(this.pageSize, functionMatchingRequest.pageSize); + Objects.equals(this.pageSize, functionMatchingRequest.pageSize)&& + Objects.equals(this.additionalProperties, functionMatchingRequest.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -267,7 +312,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(modelId, functionIds, minSimilarity, filters, resultsPerFunction, page, pageSize); + return Objects.hash(modelId, functionIds, minSimilarity, filters, resultsPerFunction, page, pageSize, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -288,6 +333,7 @@ public String toString() { sb.append(" resultsPerFunction: ").append(toIndentedString(resultsPerFunction)).append("\n"); sb.append(" page: ").append(toIndentedString(page)).append("\n"); sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -328,14 +374,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMatchingRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMatchingRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatchingRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -370,6 +408,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMatchingRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -377,7 +437,28 @@ public void write(JsonWriter out, FunctionMatchingRequest value) throws IOExcept public FunctionMatchingRequest 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 + FunctionMatchingRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionMatchingResultWithBestMatch.java b/src/main/java/ai/reveng/model/FunctionMatchingResultWithBestMatch.java index 633d323..88e3170 100644 --- a/src/main/java/ai/reveng/model/FunctionMatchingResultWithBestMatch.java +++ b/src/main/java/ai/reveng/model/FunctionMatchingResultWithBestMatch.java @@ -146,6 +146,50 @@ public void setConfidences(@javax.annotation.Nullable List confi this.confidences = confidences; } + /** + * 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 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 FunctionMatchingResultWithBestMatch instance itself + */ + public FunctionMatchingResultWithBestMatch putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -159,7 +203,8 @@ public boolean equals(Object o) { FunctionMatchingResultWithBestMatch functionMatchingResultWithBestMatch = (FunctionMatchingResultWithBestMatch) o; return Objects.equals(this.functionId, functionMatchingResultWithBestMatch.functionId) && Objects.equals(this.matchedFunctions, functionMatchingResultWithBestMatch.matchedFunctions) && - Objects.equals(this.confidences, functionMatchingResultWithBestMatch.confidences); + Objects.equals(this.confidences, functionMatchingResultWithBestMatch.confidences)&& + Objects.equals(this.additionalProperties, functionMatchingResultWithBestMatch.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -168,7 +213,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(functionId, matchedFunctions, confidences); + return Objects.hash(functionId, matchedFunctions, confidences, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -185,6 +230,7 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" matchedFunctions: ").append(toIndentedString(matchedFunctions)).append("\n"); sb.append(" confidences: ").append(toIndentedString(confidences)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -225,14 +271,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionMatchingResultWithBestMatch.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionMatchingResultWithBestMatch` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionMatchingResultWithBestMatch.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -281,6 +319,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionMatchingResultWithBestMatch value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -288,7 +348,28 @@ public void write(JsonWriter out, FunctionMatchingResultWithBestMatch value) thr public FunctionMatchingResultWithBestMatch 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 + FunctionMatchingResultWithBestMatch instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionNameConfidenceBody.java b/src/main/java/ai/reveng/model/FunctionNameConfidenceBody.java index 7b92d59..727b144 100644 --- a/src/main/java/ai/reveng/model/FunctionNameConfidenceBody.java +++ b/src/main/java/ai/reveng/model/FunctionNameConfidenceBody.java @@ -112,6 +112,50 @@ public void setIsDebug(@javax.annotation.Nullable Boolean isDebug) { this.isDebug = isDebug; } + /** + * 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 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 FunctionNameConfidenceBody instance itself + */ + public FunctionNameConfidenceBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } FunctionNameConfidenceBody functionNameConfidenceBody = (FunctionNameConfidenceBody) o; return Objects.equals(this.functions, functionNameConfidenceBody.functions) && - Objects.equals(this.isDebug, functionNameConfidenceBody.isDebug); + Objects.equals(this.isDebug, functionNameConfidenceBody.isDebug)&& + Objects.equals(this.additionalProperties, functionNameConfidenceBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions, isDebug); + return Objects.hash(functions, isDebug, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class FunctionNameConfidenceBody {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); sb.append(" isDebug: ").append(toIndentedString(isDebug)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -177,14 +223,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionNameConfidenceBody is not found in the empty JSON string", FunctionNameConfidenceBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionNameConfidenceBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionNameConfidenceBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("functions") != null && !jsonObj.get("functions").isJsonNull()) { JsonArray jsonArrayfunctions = jsonObj.getAsJsonArray("functions"); @@ -217,6 +255,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionNameConfidenceBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -224,7 +284,28 @@ public void write(JsonWriter out, FunctionNameConfidenceBody value) throws IOExc public FunctionNameConfidenceBody 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 + FunctionNameConfidenceBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionNameHistory.java b/src/main/java/ai/reveng/model/FunctionNameHistory.java index 5310582..7f56431 100644 --- a/src/main/java/ai/reveng/model/FunctionNameHistory.java +++ b/src/main/java/ai/reveng/model/FunctionNameHistory.java @@ -197,6 +197,50 @@ public void setCreatedAt(@javax.annotation.Nonnull String createdAt) { this.createdAt = createdAt; } + /** + * 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 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 FunctionNameHistory instance itself + */ + public FunctionNameHistory putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -213,12 +257,13 @@ public boolean equals(Object o) { Objects.equals(this.functionName, functionNameHistory.functionName) && Objects.equals(this.isDebug, functionNameHistory.isDebug) && Objects.equals(this.sourceType, functionNameHistory.sourceType) && - Objects.equals(this.createdAt, functionNameHistory.createdAt); + Objects.equals(this.createdAt, functionNameHistory.createdAt)&& + Objects.equals(this.additionalProperties, functionNameHistory.additionalProperties); } @Override public int hashCode() { - return Objects.hash(historyId, changeMadeBy, functionName, isDebug, sourceType, createdAt); + return Objects.hash(historyId, changeMadeBy, functionName, isDebug, sourceType, createdAt, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" isDebug: ").append(toIndentedString(isDebug)).append("\n"); sb.append(" sourceType: ").append(toIndentedString(sourceType)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionNameHistory.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionNameHistory` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionNameHistory.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -315,6 +353,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionNameHistory value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -322,7 +382,28 @@ public void write(JsonWriter out, FunctionNameHistory value) throws IOException public FunctionNameHistory 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 + FunctionNameHistory instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionNameInput.java b/src/main/java/ai/reveng/model/FunctionNameInput.java index 12233c3..e64d4c8 100644 --- a/src/main/java/ai/reveng/model/FunctionNameInput.java +++ b/src/main/java/ai/reveng/model/FunctionNameInput.java @@ -101,6 +101,50 @@ public void setFunctionName(@javax.annotation.Nonnull String functionName) { this.functionName = functionName; } + /** + * 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 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 FunctionNameInput instance itself + */ + public FunctionNameInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } FunctionNameInput functionNameInput = (FunctionNameInput) o; return Objects.equals(this.functionId, functionNameInput.functionId) && - Objects.equals(this.functionName, functionNameInput.functionName); + Objects.equals(this.functionName, functionNameInput.functionName)&& + Objects.equals(this.additionalProperties, functionNameInput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName); + return Objects.hash(functionId, functionName, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class FunctionNameInput {\n"); sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" functionName: ").append(toIndentedString(functionName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionNameInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionNameInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionNameInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionNameInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, FunctionNameInput value) throws IOException { public FunctionNameInput 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 + FunctionNameInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionParamResponse.java b/src/main/java/ai/reveng/model/FunctionParamResponse.java index 3a0bf85..22f776f 100644 --- a/src/main/java/ai/reveng/model/FunctionParamResponse.java +++ b/src/main/java/ai/reveng/model/FunctionParamResponse.java @@ -173,6 +173,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * 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 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 FunctionParamResponse instance itself + */ + public FunctionParamResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -188,12 +232,13 @@ public boolean equals(Object o) { Objects.equals(this.loc, functionParamResponse.loc) && Objects.equals(this.addr, functionParamResponse.addr) && Objects.equals(this.length, functionParamResponse.length) && - Objects.equals(this.name, functionParamResponse.name); + Objects.equals(this.name, functionParamResponse.name)&& + Objects.equals(this.additionalProperties, functionParamResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dType, loc, addr, length, name); + return Objects.hash(dType, loc, addr, length, name, additionalProperties); } @Override @@ -205,6 +250,7 @@ public String toString() { sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); sb.append(" length: ").append(toIndentedString(length)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -245,14 +291,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionParamResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionParamResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionParamResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -289,6 +327,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionParamResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -296,7 +356,28 @@ public void write(JsonWriter out, FunctionParamResponse value) throws IOExceptio public FunctionParamResponse 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 + FunctionParamResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionRename.java b/src/main/java/ai/reveng/model/FunctionRename.java index 3e24705..1500c80 100644 --- a/src/main/java/ai/reveng/model/FunctionRename.java +++ b/src/main/java/ai/reveng/model/FunctionRename.java @@ -102,6 +102,50 @@ public void setNewMangledName(@javax.annotation.Nullable String newMangledName) this.newMangledName = newMangledName; } + /** + * 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 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 FunctionRename instance itself + */ + public FunctionRename putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,7 +158,8 @@ public boolean equals(Object o) { } FunctionRename functionRename = (FunctionRename) o; return Objects.equals(this.newName, functionRename.newName) && - Objects.equals(this.newMangledName, functionRename.newMangledName); + Objects.equals(this.newMangledName, functionRename.newMangledName)&& + Objects.equals(this.additionalProperties, functionRename.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -123,7 +168,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(newName, newMangledName); + return Objects.hash(newName, newMangledName, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -139,6 +184,7 @@ public String toString() { sb.append("class FunctionRename {\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionRename is not found in the empty JSON string", FunctionRename.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionRename.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionRename` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("new_name") != null && !jsonObj.get("new_name").isJsonNull()) && !jsonObj.get("new_name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `new_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("new_name").toString())); @@ -210,6 +248,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionRename value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -217,7 +277,28 @@ public void write(JsonWriter out, FunctionRename value) throws IOException { public FunctionRename 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 + FunctionRename instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionRenameMap.java b/src/main/java/ai/reveng/model/FunctionRenameMap.java index 52744b8..aac2d28 100644 --- a/src/main/java/ai/reveng/model/FunctionRenameMap.java +++ b/src/main/java/ai/reveng/model/FunctionRenameMap.java @@ -126,6 +126,50 @@ public void setNewMangledName(@javax.annotation.Nullable String newMangledName) this.newMangledName = newMangledName; } + /** + * 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 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 FunctionRenameMap instance itself + */ + public FunctionRenameMap putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -139,7 +183,8 @@ public boolean equals(Object o) { FunctionRenameMap functionRenameMap = (FunctionRenameMap) o; return Objects.equals(this.functionId, functionRenameMap.functionId) && Objects.equals(this.newName, functionRenameMap.newName) && - Objects.equals(this.newMangledName, functionRenameMap.newMangledName); + Objects.equals(this.newMangledName, functionRenameMap.newMangledName)&& + Objects.equals(this.additionalProperties, functionRenameMap.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -148,7 +193,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(functionId, newName, newMangledName); + return Objects.hash(functionId, newName, newMangledName, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -165,6 +210,7 @@ public String toString() { sb.append(" functionId: ").append(toIndentedString(functionId)).append("\n"); sb.append(" newName: ").append(toIndentedString(newName)).append("\n"); sb.append(" newMangledName: ").append(toIndentedString(newMangledName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -205,14 +251,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionRenameMap.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionRenameMap` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionRenameMap.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -243,6 +281,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionRenameMap value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -250,7 +310,28 @@ public void write(JsonWriter out, FunctionRenameMap value) throws IOException { public FunctionRenameMap 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 + FunctionRenameMap instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionSearchResponse.java b/src/main/java/ai/reveng/model/FunctionSearchResponse.java index 0796000..6f0bfd6 100644 --- a/src/main/java/ai/reveng/model/FunctionSearchResponse.java +++ b/src/main/java/ai/reveng/model/FunctionSearchResponse.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List resu this.results = results; } + /** + * 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 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 FunctionSearchResponse instance itself + */ + public FunctionSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } FunctionSearchResponse functionSearchResponse = (FunctionSearchResponse) o; - return Objects.equals(this.results, functionSearchResponse.results); + return Objects.equals(this.results, functionSearchResponse.results)&& + Objects.equals(this.additionalProperties, functionSearchResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FunctionSearchResponse {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, FunctionSearchResponse value) throws IOExcepti public FunctionSearchResponse 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 + FunctionSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionSearchResult.java b/src/main/java/ai/reveng/model/FunctionSearchResult.java index 2c0be52..c780915 100644 --- a/src/main/java/ai/reveng/model/FunctionSearchResult.java +++ b/src/main/java/ai/reveng/model/FunctionSearchResult.java @@ -222,6 +222,50 @@ public void setOwnedBy(@javax.annotation.Nonnull String ownedBy) { this.ownedBy = ownedBy; } + /** + * 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 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 FunctionSearchResult instance itself + */ + public FunctionSearchResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.createdAt, functionSearchResult.createdAt) && Objects.equals(this.modelId, functionSearchResult.modelId) && Objects.equals(this.modelName, functionSearchResult.modelName) && - Objects.equals(this.ownedBy, functionSearchResult.ownedBy); + Objects.equals(this.ownedBy, functionSearchResult.ownedBy)&& + Objects.equals(this.additionalProperties, functionSearchResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName, binaryName, createdAt, modelId, modelName, ownedBy); + return Objects.hash(functionId, functionName, binaryName, createdAt, modelId, modelName, ownedBy, additionalProperties); } @Override @@ -258,6 +303,7 @@ public String toString() { sb.append(" modelId: ").append(toIndentedString(modelId)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -298,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionSearchResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionSearchResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -342,6 +380,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionSearchResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -349,7 +409,28 @@ public void write(JsonWriter out, FunctionSearchResult value) throws IOException public FunctionSearchResult 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 + FunctionSearchResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionString.java b/src/main/java/ai/reveng/model/FunctionString.java index ba79ef7..acaee4a 100644 --- a/src/main/java/ai/reveng/model/FunctionString.java +++ b/src/main/java/ai/reveng/model/FunctionString.java @@ -101,6 +101,50 @@ public void setVaddr(@javax.annotation.Nonnull Integer vaddr) { this.vaddr = vaddr; } + /** + * 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 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 FunctionString instance itself + */ + public FunctionString putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } FunctionString functionString = (FunctionString) o; return Objects.equals(this.value, functionString.value) && - Objects.equals(this.vaddr, functionString.vaddr); + Objects.equals(this.vaddr, functionString.vaddr)&& + Objects.equals(this.additionalProperties, functionString.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, vaddr); + return Objects.hash(value, vaddr, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class FunctionString {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" vaddr: ").append(toIndentedString(vaddr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionString.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionString` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionString.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionString value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, FunctionString value) throws IOException { public FunctionString 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 + FunctionString instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionStringsResponse.java b/src/main/java/ai/reveng/model/FunctionStringsResponse.java index c8bebd9..6d6aaab 100644 --- a/src/main/java/ai/reveng/model/FunctionStringsResponse.java +++ b/src/main/java/ai/reveng/model/FunctionStringsResponse.java @@ -112,6 +112,50 @@ public void setTotalStrings(@javax.annotation.Nonnull Integer totalStrings) { this.totalStrings = totalStrings; } + /** + * 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 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 FunctionStringsResponse instance itself + */ + public FunctionStringsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } FunctionStringsResponse functionStringsResponse = (FunctionStringsResponse) o; return Objects.equals(this.strings, functionStringsResponse.strings) && - Objects.equals(this.totalStrings, functionStringsResponse.totalStrings); + Objects.equals(this.totalStrings, functionStringsResponse.totalStrings)&& + Objects.equals(this.additionalProperties, functionStringsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(strings, totalStrings); + return Objects.hash(strings, totalStrings, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class FunctionStringsResponse {\n"); sb.append(" strings: ").append(toIndentedString(strings)).append("\n"); sb.append(" totalStrings: ").append(toIndentedString(totalStrings)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionStringsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionStringsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionStringsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionStringsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, FunctionStringsResponse value) throws IOExcept public FunctionStringsResponse 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 + FunctionStringsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionTaskResponse.java b/src/main/java/ai/reveng/model/FunctionTaskResponse.java index 3906973..d675a53 100644 --- a/src/main/java/ai/reveng/model/FunctionTaskResponse.java +++ b/src/main/java/ai/reveng/model/FunctionTaskResponse.java @@ -103,6 +103,50 @@ public void setErrorMessage(@javax.annotation.Nullable String errorMessage) { this.errorMessage = errorMessage; } + /** + * 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 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 FunctionTaskResponse instance itself + */ + public FunctionTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -115,7 +159,8 @@ public boolean equals(Object o) { } FunctionTaskResponse functionTaskResponse = (FunctionTaskResponse) o; return Objects.equals(this.status, functionTaskResponse.status) && - Objects.equals(this.errorMessage, functionTaskResponse.errorMessage); + Objects.equals(this.errorMessage, functionTaskResponse.errorMessage)&& + Objects.equals(this.additionalProperties, functionTaskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -124,7 +169,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, errorMessage); + return Objects.hash(status, errorMessage, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -140,6 +185,7 @@ public String toString() { sb.append("class FunctionTaskResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -179,14 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in FunctionTaskResponse is not found in the empty JSON string", FunctionTaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `status` if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { @@ -212,6 +250,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -219,7 +279,28 @@ public void write(JsonWriter out, FunctionTaskResponse value) throws IOException public FunctionTaskResponse 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 + FunctionTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionTypeInput.java b/src/main/java/ai/reveng/model/FunctionTypeInput.java index 4ee97c1..0c62529 100644 --- a/src/main/java/ai/reveng/model/FunctionTypeInput.java +++ b/src/main/java/ai/reveng/model/FunctionTypeInput.java @@ -258,6 +258,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 FunctionTypeInput instance itself + */ + public FunctionTypeInput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -276,7 +320,8 @@ public boolean equals(Object o) { Objects.equals(this.stackVars, functionTypeInput.stackVars) && Objects.equals(this.name, functionTypeInput.name) && Objects.equals(this.type, functionTypeInput.type) && - Objects.equals(this.artifactType, functionTypeInput.artifactType); + Objects.equals(this.artifactType, functionTypeInput.artifactType)&& + Objects.equals(this.additionalProperties, functionTypeInput.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -285,7 +330,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, addr, size, header, stackVars, name, type, artifactType); + return Objects.hash(lastChange, addr, size, header, stackVars, name, type, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -307,6 +352,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -347,14 +393,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionTypeInput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionTypeInput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionTypeInput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -393,6 +431,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionTypeInput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -400,7 +460,28 @@ public void write(JsonWriter out, FunctionTypeInput value) throws IOException { public FunctionTypeInput 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 + FunctionTypeInput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionTypeOutput.java b/src/main/java/ai/reveng/model/FunctionTypeOutput.java index 9fa3a01..8f188d6 100644 --- a/src/main/java/ai/reveng/model/FunctionTypeOutput.java +++ b/src/main/java/ai/reveng/model/FunctionTypeOutput.java @@ -258,6 +258,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 FunctionTypeOutput instance itself + */ + public FunctionTypeOutput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -276,7 +320,8 @@ public boolean equals(Object o) { Objects.equals(this.stackVars, functionTypeOutput.stackVars) && Objects.equals(this.name, functionTypeOutput.name) && Objects.equals(this.type, functionTypeOutput.type) && - Objects.equals(this.artifactType, functionTypeOutput.artifactType); + Objects.equals(this.artifactType, functionTypeOutput.artifactType)&& + Objects.equals(this.additionalProperties, functionTypeOutput.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -285,7 +330,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, addr, size, header, stackVars, name, type, artifactType); + return Objects.hash(lastChange, addr, size, header, stackVars, name, type, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -307,6 +352,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -347,14 +393,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionTypeOutput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionTypeOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionTypeOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -393,6 +431,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionTypeOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -400,7 +460,28 @@ public void write(JsonWriter out, FunctionTypeOutput value) throws IOException { public FunctionTypeOutput 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 + FunctionTypeOutput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionsDetailResponse.java b/src/main/java/ai/reveng/model/FunctionsDetailResponse.java index 1c0d0b3..962ba7a 100644 --- a/src/main/java/ai/reveng/model/FunctionsDetailResponse.java +++ b/src/main/java/ai/reveng/model/FunctionsDetailResponse.java @@ -337,6 +337,50 @@ public void setEmbedding1d(@javax.annotation.Nullable List embedding this.embedding1d = embedding1d; } + /** + * 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 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 FunctionsDetailResponse instance itself + */ + public FunctionsDetailResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -358,7 +402,8 @@ public boolean equals(Object o) { Objects.equals(this.sha256Hash, functionsDetailResponse.sha256Hash) && Objects.equals(this.debugHash, functionsDetailResponse.debugHash) && Objects.equals(this.embedding3d, functionsDetailResponse.embedding3d) && - Objects.equals(this.embedding1d, functionsDetailResponse.embedding1d); + Objects.equals(this.embedding1d, functionsDetailResponse.embedding1d)&& + Objects.equals(this.additionalProperties, functionsDetailResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -367,7 +412,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(functionId, functionName, functionVaddr, functionSize, analysisId, binaryId, binaryName, sha256Hash, debugHash, embedding3d, embedding1d); + return Objects.hash(functionId, functionName, functionVaddr, functionSize, analysisId, binaryId, binaryName, sha256Hash, debugHash, embedding3d, embedding1d, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -392,6 +437,7 @@ public String toString() { sb.append(" debugHash: ").append(toIndentedString(debugHash)).append("\n"); sb.append(" embedding3d: ").append(toIndentedString(embedding3d)).append("\n"); sb.append(" embedding1d: ").append(toIndentedString(embedding1d)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -432,14 +478,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionsDetailResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionsDetailResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionsDetailResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -484,6 +522,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionsDetailResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -491,7 +551,28 @@ public void write(JsonWriter out, FunctionsDetailResponse value) throws IOExcept public FunctionsDetailResponse 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 + FunctionsDetailResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/FunctionsListRename.java b/src/main/java/ai/reveng/model/FunctionsListRename.java index fdd20b7..d173917 100644 --- a/src/main/java/ai/reveng/model/FunctionsListRename.java +++ b/src/main/java/ai/reveng/model/FunctionsListRename.java @@ -88,6 +88,50 @@ public void setFunctions(@javax.annotation.Nonnull List funct this.functions = functions; } + /** + * 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 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 FunctionsListRename instance itself + */ + public FunctionsListRename putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } FunctionsListRename functionsListRename = (FunctionsListRename) o; - return Objects.equals(this.functions, functionsListRename.functions); + return Objects.equals(this.functions, functionsListRename.functions)&& + Objects.equals(this.additionalProperties, functionsListRename.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functions); + return Objects.hash(functions, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class FunctionsListRename {\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!FunctionsListRename.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `FunctionsListRename` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : FunctionsListRename.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, FunctionsListRename value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, FunctionsListRename value) throws IOException public FunctionsListRename 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 + FunctionsListRename instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java b/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java index 6f9ea9a..cb866f2 100644 --- a/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/GenerateFunctionDataTypes.java @@ -136,6 +136,50 @@ public void setDataTypesList(@javax.annotation.Nonnull GenerationStatusList data this.dataTypesList = dataTypesList; } + /** + * 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 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 GenerateFunctionDataTypes instance itself + */ + public GenerateFunctionDataTypes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { GenerateFunctionDataTypes generateFunctionDataTypes = (GenerateFunctionDataTypes) o; return Objects.equals(this.queued, generateFunctionDataTypes.queued) && Objects.equals(this.reference, generateFunctionDataTypes.reference) && - Objects.equals(this.dataTypesList, generateFunctionDataTypes.dataTypesList); + Objects.equals(this.dataTypesList, generateFunctionDataTypes.dataTypesList)&& + Objects.equals(this.additionalProperties, generateFunctionDataTypes.additionalProperties); } @Override public int hashCode() { - return Objects.hash(queued, reference, dataTypesList); + return Objects.hash(queued, reference, dataTypesList, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" queued: ").append(toIndentedString(queued)).append("\n"); sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); sb.append(" dataTypesList: ").append(toIndentedString(dataTypesList)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GenerateFunctionDataTypes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GenerateFunctionDataTypes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GenerateFunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -241,6 +279,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GenerateFunctionDataTypes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -248,7 +308,28 @@ public void write(JsonWriter out, GenerateFunctionDataTypes value) throws IOExce public GenerateFunctionDataTypes 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 + GenerateFunctionDataTypes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GenerationStatusList.java b/src/main/java/ai/reveng/model/GenerationStatusList.java index 8eab297..f28d6a1 100644 --- a/src/main/java/ai/reveng/model/GenerationStatusList.java +++ b/src/main/java/ai/reveng/model/GenerationStatusList.java @@ -136,6 +136,50 @@ public void setItems(@javax.annotation.Nonnull List ite this.items = items; } + /** + * 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 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 GenerationStatusList instance itself + */ + public GenerationStatusList putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { GenerationStatusList generationStatusList = (GenerationStatusList) o; return Objects.equals(this.totalCount, generationStatusList.totalCount) && Objects.equals(this.totalDataTypesCount, generationStatusList.totalDataTypesCount) && - Objects.equals(this.items, generationStatusList.items); + Objects.equals(this.items, generationStatusList.items)&& + Objects.equals(this.additionalProperties, generationStatusList.additionalProperties); } @Override public int hashCode() { - return Objects.hash(totalCount, totalDataTypesCount, items); + return Objects.hash(totalCount, totalDataTypesCount, items, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); sb.append(" totalDataTypesCount: ").append(toIndentedString(totalDataTypesCount)).append("\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GenerationStatusList.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GenerationStatusList` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GenerationStatusList.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -246,6 +284,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GenerationStatusList value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -253,7 +313,28 @@ public void write(JsonWriter out, GenerationStatusList value) throws IOException public GenerationStatusList 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 + GenerationStatusList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java b/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java index e58c586..175f469 100644 --- a/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java +++ b/src/main/java/ai/reveng/model/GetAiDecompilationRatingResponse.java @@ -102,6 +102,50 @@ public void setReason(@javax.annotation.Nullable String reason) { this.reason = reason; } + /** + * 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 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 GetAiDecompilationRatingResponse instance itself + */ + public GetAiDecompilationRatingResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } GetAiDecompilationRatingResponse getAiDecompilationRatingResponse = (GetAiDecompilationRatingResponse) o; return Objects.equals(this.rating, getAiDecompilationRatingResponse.rating) && - Objects.equals(this.reason, getAiDecompilationRatingResponse.reason); + Objects.equals(this.reason, getAiDecompilationRatingResponse.reason)&& + Objects.equals(this.additionalProperties, getAiDecompilationRatingResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rating, reason); + return Objects.hash(rating, reason, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class GetAiDecompilationRatingResponse {\n"); sb.append(" rating: ").append(toIndentedString(rating)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAiDecompilationRatingResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAiDecompilationRatingResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAiDecompilationRatingResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAiDecompilationRatingResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, GetAiDecompilationRatingResponse value) throws public GetAiDecompilationRatingResponse 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 + GetAiDecompilationRatingResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GetAiDecompilationTask.java b/src/main/java/ai/reveng/model/GetAiDecompilationTask.java index 4f104ce..4449fb4 100644 --- a/src/main/java/ai/reveng/model/GetAiDecompilationTask.java +++ b/src/main/java/ai/reveng/model/GetAiDecompilationTask.java @@ -258,6 +258,50 @@ public void setRawAiSummary(@javax.annotation.Nullable String rawAiSummary) { this.rawAiSummary = rawAiSummary; } + /** + * 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 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 GetAiDecompilationTask instance itself + */ + public GetAiDecompilationTask putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -276,7 +320,8 @@ public boolean equals(Object o) { Objects.equals(this.functionMappingFull, getAiDecompilationTask.functionMappingFull) && Objects.equals(this.summary, getAiDecompilationTask.summary) && Objects.equals(this.aiSummary, getAiDecompilationTask.aiSummary) && - Objects.equals(this.rawAiSummary, getAiDecompilationTask.rawAiSummary); + Objects.equals(this.rawAiSummary, getAiDecompilationTask.rawAiSummary)&& + Objects.equals(this.additionalProperties, getAiDecompilationTask.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -285,7 +330,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, decompilation, rawDecompilation, functionMapping, functionMappingFull, summary, aiSummary, rawAiSummary); + return Objects.hash(status, decompilation, rawDecompilation, functionMapping, functionMappingFull, summary, aiSummary, rawAiSummary, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -307,6 +352,7 @@ public String toString() { sb.append(" summary: ").append(toIndentedString(summary)).append("\n"); sb.append(" aiSummary: ").append(toIndentedString(aiSummary)).append("\n"); sb.append(" rawAiSummary: ").append(toIndentedString(rawAiSummary)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -347,14 +393,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetAiDecompilationTask.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetAiDecompilationTask` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetAiDecompilationTask.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -399,6 +437,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetAiDecompilationTask value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -406,7 +466,28 @@ public void write(JsonWriter out, GetAiDecompilationTask value) throws IOExcepti public GetAiDecompilationTask 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 + GetAiDecompilationTask instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GetPublicUserResponse.java b/src/main/java/ai/reveng/model/GetPublicUserResponse.java index d0b6bba..e132734 100644 --- a/src/main/java/ai/reveng/model/GetPublicUserResponse.java +++ b/src/main/java/ai/reveng/model/GetPublicUserResponse.java @@ -101,6 +101,50 @@ public void setUserId(@javax.annotation.Nonnull Integer userId) { this.userId = userId; } + /** + * 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 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 GetPublicUserResponse instance itself + */ + public GetPublicUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } GetPublicUserResponse getPublicUserResponse = (GetPublicUserResponse) o; return Objects.equals(this.username, getPublicUserResponse.username) && - Objects.equals(this.userId, getPublicUserResponse.userId); + Objects.equals(this.userId, getPublicUserResponse.userId)&& + Objects.equals(this.additionalProperties, getPublicUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, userId); + return Objects.hash(username, userId, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class GetPublicUserResponse {\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetPublicUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetPublicUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetPublicUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetPublicUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, GetPublicUserResponse value) throws IOExceptio public GetPublicUserResponse 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 + GetPublicUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GetUserResponse.java b/src/main/java/ai/reveng/model/GetUserResponse.java index 284eb20..650678e 100644 --- a/src/main/java/ai/reveng/model/GetUserResponse.java +++ b/src/main/java/ai/reveng/model/GetUserResponse.java @@ -222,6 +222,50 @@ public void setTutorialSeen(@javax.annotation.Nonnull Boolean tutorialSeen) { this.tutorialSeen = tutorialSeen; } + /** + * 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 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 GetUserResponse instance itself + */ + public GetUserResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.lastName, getUserResponse.lastName) && Objects.equals(this.email, getUserResponse.email) && Objects.equals(this.creation, getUserResponse.creation) && - Objects.equals(this.tutorialSeen, getUserResponse.tutorialSeen); + Objects.equals(this.tutorialSeen, getUserResponse.tutorialSeen)&& + Objects.equals(this.additionalProperties, getUserResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, userId, firstName, lastName, email, creation, tutorialSeen); + return Objects.hash(username, userId, firstName, lastName, email, creation, tutorialSeen, additionalProperties); } @Override @@ -258,6 +303,7 @@ public String toString() { sb.append(" email: ").append(toIndentedString(email)).append("\n"); sb.append(" creation: ").append(toIndentedString(creation)).append("\n"); sb.append(" tutorialSeen: ").append(toIndentedString(tutorialSeen)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -298,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUserResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GetUserResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GetUserResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -342,6 +380,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GetUserResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -349,7 +409,28 @@ public void write(JsonWriter out, GetUserResponse value) throws IOException { public GetUserResponse 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 + GetUserResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/GlobalVariable.java b/src/main/java/ai/reveng/model/GlobalVariable.java index 215560d..c88fc6f 100644 --- a/src/main/java/ai/reveng/model/GlobalVariable.java +++ b/src/main/java/ai/reveng/model/GlobalVariable.java @@ -198,6 +198,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 GlobalVariable instance itself + */ + public GlobalVariable putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -214,7 +258,8 @@ public boolean equals(Object o) { Objects.equals(this.name, globalVariable.name) && Objects.equals(this.type, globalVariable.type) && Objects.equals(this.size, globalVariable.size) && - Objects.equals(this.artifactType, globalVariable.artifactType); + Objects.equals(this.artifactType, globalVariable.artifactType)&& + Objects.equals(this.additionalProperties, globalVariable.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -223,7 +268,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, addr, name, type, size, artifactType); + return Objects.hash(lastChange, addr, name, type, size, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -243,6 +288,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -283,14 +329,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GlobalVariable.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `GlobalVariable` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : GlobalVariable.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -327,6 +365,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, GlobalVariable value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -334,7 +394,28 @@ public void write(JsonWriter out, GlobalVariable value) throws IOException { public GlobalVariable 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 + GlobalVariable instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/IconModel.java b/src/main/java/ai/reveng/model/IconModel.java index b605bd1..716db3b 100644 --- a/src/main/java/ai/reveng/model/IconModel.java +++ b/src/main/java/ai/reveng/model/IconModel.java @@ -77,6 +77,50 @@ public void setContent(@javax.annotation.Nullable String content) { this.content = content; } + /** + * 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 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 IconModel instance itself + */ + public IconModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } IconModel iconModel = (IconModel) o; - return Objects.equals(this.content, iconModel.content); + return Objects.equals(this.content, iconModel.content)&& + Objects.equals(this.additionalProperties, iconModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(content); + return Objects.hash(content, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class IconModel {\n"); sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!IconModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `IconModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : IconModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, IconModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, IconModel value) throws IOException { public IconModel 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 + IconModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ImportModel.java b/src/main/java/ai/reveng/model/ImportModel.java index cb9d78e..3cc15ac 100644 --- a/src/main/java/ai/reveng/model/ImportModel.java +++ b/src/main/java/ai/reveng/model/ImportModel.java @@ -112,6 +112,50 @@ public void setImports(@javax.annotation.Nonnull List 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 ImportModel instance itself + */ + public ImportModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } ImportModel importModel = (ImportModel) o; return Objects.equals(this.numberOfImports, importModel.numberOfImports) && - Objects.equals(this.imports, importModel.imports); + Objects.equals(this.imports, importModel.imports)&& + Objects.equals(this.additionalProperties, importModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(numberOfImports, imports); + return Objects.hash(numberOfImports, imports, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class ImportModel {\n"); sb.append(" numberOfImports: ").append(toIndentedString(numberOfImports)).append("\n"); sb.append(" imports: ").append(toIndentedString(imports)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ImportModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ImportModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ImportModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -216,6 +254,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ImportModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -223,7 +283,28 @@ public void write(JsonWriter out, ImportModel value) throws IOException { public ImportModel 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 + ImportModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/InverseFunctionMapItem.java b/src/main/java/ai/reveng/model/InverseFunctionMapItem.java index e91e0f9..24a665b 100644 --- a/src/main/java/ai/reveng/model/InverseFunctionMapItem.java +++ b/src/main/java/ai/reveng/model/InverseFunctionMapItem.java @@ -126,6 +126,50 @@ public void setIsExternal(@javax.annotation.Nullable Boolean isExternal) { this.isExternal = isExternal; } + /** + * 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 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 InverseFunctionMapItem instance itself + */ + public InverseFunctionMapItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -139,12 +183,13 @@ public boolean equals(Object o) { InverseFunctionMapItem inverseFunctionMapItem = (InverseFunctionMapItem) o; return Objects.equals(this.name, inverseFunctionMapItem.name) && Objects.equals(this.addr, inverseFunctionMapItem.addr) && - Objects.equals(this.isExternal, inverseFunctionMapItem.isExternal); + Objects.equals(this.isExternal, inverseFunctionMapItem.isExternal)&& + Objects.equals(this.additionalProperties, inverseFunctionMapItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, addr, isExternal); + return Objects.hash(name, addr, isExternal, additionalProperties); } @Override @@ -154,6 +199,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); sb.append(" isExternal: ").append(toIndentedString(isExternal)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -194,14 +240,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!InverseFunctionMapItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `InverseFunctionMapItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseFunctionMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, InverseFunctionMapItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, InverseFunctionMapItem value) throws IOExcepti public InverseFunctionMapItem 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 + InverseFunctionMapItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/InverseStringMapItem.java b/src/main/java/ai/reveng/model/InverseStringMapItem.java index 34db91a..5ebd36f 100644 --- a/src/main/java/ai/reveng/model/InverseStringMapItem.java +++ b/src/main/java/ai/reveng/model/InverseStringMapItem.java @@ -101,6 +101,50 @@ public void setAddr(@javax.annotation.Nullable Integer addr) { this.addr = addr; } + /** + * 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 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 InverseStringMapItem instance itself + */ + public InverseStringMapItem putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } InverseStringMapItem inverseStringMapItem = (InverseStringMapItem) o; return Objects.equals(this.string, inverseStringMapItem.string) && - Objects.equals(this.addr, inverseStringMapItem.addr); + Objects.equals(this.addr, inverseStringMapItem.addr)&& + Objects.equals(this.additionalProperties, inverseStringMapItem.additionalProperties); } @Override public int hashCode() { - return Objects.hash(string, addr); + return Objects.hash(string, addr, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class InverseStringMapItem {\n"); sb.append(" string: ").append(toIndentedString(string)).append("\n"); sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!InverseStringMapItem.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `InverseStringMapItem` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseStringMapItem.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, InverseStringMapItem value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, InverseStringMapItem value) throws IOException public InverseStringMapItem 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 + InverseStringMapItem instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/InverseValue.java b/src/main/java/ai/reveng/model/InverseValue.java index 3a89ca7..35c5fb8 100644 --- a/src/main/java/ai/reveng/model/InverseValue.java +++ b/src/main/java/ai/reveng/model/InverseValue.java @@ -77,6 +77,50 @@ public void setValue(@javax.annotation.Nonnull String value) { this.value = value; } + /** + * 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 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 InverseValue instance itself + */ + public InverseValue putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } InverseValue inverseValue = (InverseValue) o; - return Objects.equals(this.value, inverseValue.value); + return Objects.equals(this.value, inverseValue.value)&& + Objects.equals(this.additionalProperties, inverseValue.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value); + return Objects.hash(value, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class InverseValue {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!InverseValue.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `InverseValue` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : InverseValue.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, InverseValue value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, InverseValue value) throws IOException { public InverseValue 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 + InverseValue instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ListCollectionResults.java b/src/main/java/ai/reveng/model/ListCollectionResults.java index e9f3555..29558f9 100644 --- a/src/main/java/ai/reveng/model/ListCollectionResults.java +++ b/src/main/java/ai/reveng/model/ListCollectionResults.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List result this.results = results; } + /** + * 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 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 ListCollectionResults instance itself + */ + public ListCollectionResults putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } ListCollectionResults listCollectionResults = (ListCollectionResults) o; - return Objects.equals(this.results, listCollectionResults.results); + return Objects.equals(this.results, listCollectionResults.results)&& + Objects.equals(this.additionalProperties, listCollectionResults.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListCollectionResults {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListCollectionResults.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ListCollectionResults` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ListCollectionResults.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ListCollectionResults value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, ListCollectionResults value) throws IOExceptio public ListCollectionResults 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 + ListCollectionResults instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/LoginRequest.java b/src/main/java/ai/reveng/model/LoginRequest.java index 65d2dc1..e633e8e 100644 --- a/src/main/java/ai/reveng/model/LoginRequest.java +++ b/src/main/java/ai/reveng/model/LoginRequest.java @@ -101,6 +101,50 @@ public void setPassword(@javax.annotation.Nonnull String password) { this.password = password; } + /** + * 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 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 LoginRequest instance itself + */ + public LoginRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } LoginRequest loginRequest = (LoginRequest) o; return Objects.equals(this.username, loginRequest.username) && - Objects.equals(this.password, loginRequest.password); + Objects.equals(this.password, loginRequest.password)&& + Objects.equals(this.additionalProperties, loginRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(username, password); + return Objects.hash(username, password, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class LoginRequest {\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoginRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `LoginRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : LoginRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, LoginRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, LoginRequest value) throws IOException { public LoginRequest 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 + LoginRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/LoginResponse.java b/src/main/java/ai/reveng/model/LoginResponse.java index e85e85a..d5391cc 100644 --- a/src/main/java/ai/reveng/model/LoginResponse.java +++ b/src/main/java/ai/reveng/model/LoginResponse.java @@ -77,6 +77,50 @@ public void setToken(@javax.annotation.Nonnull String token) { this.token = token; } + /** + * 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 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 LoginResponse instance itself + */ + public LoginResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } LoginResponse loginResponse = (LoginResponse) o; - return Objects.equals(this.token, loginResponse.token); + return Objects.equals(this.token, loginResponse.token)&& + Objects.equals(this.additionalProperties, loginResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(token); + return Objects.hash(token, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class LoginResponse {\n"); sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoginResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `LoginResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : LoginResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, LoginResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, LoginResponse value) throws IOException { public LoginResponse 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 + LoginResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Logs.java b/src/main/java/ai/reveng/model/Logs.java index 5306ea6..df103b3 100644 --- a/src/main/java/ai/reveng/model/Logs.java +++ b/src/main/java/ai/reveng/model/Logs.java @@ -77,6 +77,50 @@ public void setLogs(@javax.annotation.Nonnull String logs) { this.logs = logs; } + /** + * 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 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 Logs instance itself + */ + public Logs putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } Logs logs = (Logs) o; - return Objects.equals(this.logs, logs.logs); + return Objects.equals(this.logs, logs.logs)&& + Objects.equals(this.additionalProperties, logs.additionalProperties); } @Override public int hashCode() { - return Objects.hash(logs); + return Objects.hash(logs, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Logs {\n"); sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Logs.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Logs` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Logs.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Logs value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, Logs value) throws IOException { public Logs 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 + Logs instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/MatchedFunction.java b/src/main/java/ai/reveng/model/MatchedFunction.java index 4e17a57..71105e3 100644 --- a/src/main/java/ai/reveng/model/MatchedFunction.java +++ b/src/main/java/ai/reveng/model/MatchedFunction.java @@ -319,6 +319,50 @@ public void setConfidence(@javax.annotation.Nullable BigDecimal confidence) { this.confidence = confidence; } + /** + * 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 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 MatchedFunction instance itself + */ + public MatchedFunction putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -340,7 +384,8 @@ public boolean equals(Object o) { Objects.equals(this.sha256Hash, matchedFunction.sha256Hash) && Objects.equals(this.analysisId, matchedFunction.analysisId) && Objects.equals(this.similarity, matchedFunction.similarity) && - Objects.equals(this.confidence, matchedFunction.confidence); + Objects.equals(this.confidence, matchedFunction.confidence)&& + Objects.equals(this.additionalProperties, matchedFunction.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -349,7 +394,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(functionId, binaryId, functionName, functionVaddr, mangledName, debug, binaryName, sha256Hash, analysisId, similarity, confidence); + return Objects.hash(functionId, binaryId, functionName, functionVaddr, mangledName, debug, binaryName, sha256Hash, analysisId, similarity, confidence, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -374,6 +419,7 @@ public String toString() { sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" similarity: ").append(toIndentedString(similarity)).append("\n"); sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -414,14 +460,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MatchedFunction.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MatchedFunction` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MatchedFunction.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -458,6 +496,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MatchedFunction value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -465,7 +525,28 @@ public void write(JsonWriter out, MatchedFunction value) throws IOException { public MatchedFunction 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 + MatchedFunction instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java b/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java index 7b42dd9..414b6e7 100644 --- a/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java +++ b/src/main/java/ai/reveng/model/MatchedFunctionSuggestion.java @@ -150,6 +150,50 @@ public void setSuggestedDemangledName(@javax.annotation.Nonnull String suggested this.suggestedDemangledName = suggestedDemangledName; } + /** + * 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 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 MatchedFunctionSuggestion instance itself + */ + public MatchedFunctionSuggestion putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -164,7 +208,8 @@ public boolean equals(Object o) { return Objects.equals(this.functionId, matchedFunctionSuggestion.functionId) && Objects.equals(this.functionVaddr, matchedFunctionSuggestion.functionVaddr) && Objects.equals(this.suggestedName, matchedFunctionSuggestion.suggestedName) && - Objects.equals(this.suggestedDemangledName, matchedFunctionSuggestion.suggestedDemangledName); + Objects.equals(this.suggestedDemangledName, matchedFunctionSuggestion.suggestedDemangledName)&& + Objects.equals(this.additionalProperties, matchedFunctionSuggestion.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -173,7 +218,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(functionId, functionVaddr, suggestedName, suggestedDemangledName); + return Objects.hash(functionId, functionVaddr, suggestedName, suggestedDemangledName, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -191,6 +236,7 @@ public String toString() { sb.append(" functionVaddr: ").append(toIndentedString(functionVaddr)).append("\n"); sb.append(" suggestedName: ").append(toIndentedString(suggestedName)).append("\n"); sb.append(" suggestedDemangledName: ").append(toIndentedString(suggestedDemangledName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -231,14 +277,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MatchedFunctionSuggestion.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MatchedFunctionSuggestion` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : MatchedFunctionSuggestion.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -269,6 +307,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MatchedFunctionSuggestion value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -276,7 +336,28 @@ public void write(JsonWriter out, MatchedFunctionSuggestion value) throws IOExce public MatchedFunctionSuggestion 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 + MatchedFunctionSuggestion instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/MetaModel.java b/src/main/java/ai/reveng/model/MetaModel.java index 22f083e..7385f0f 100644 --- a/src/main/java/ai/reveng/model/MetaModel.java +++ b/src/main/java/ai/reveng/model/MetaModel.java @@ -79,6 +79,50 @@ public void setPagination(@javax.annotation.Nullable PaginationModel pagination) this.pagination = pagination; } + /** + * 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 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 MetaModel instance itself + */ + public MetaModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -90,7 +134,8 @@ public boolean equals(Object o) { return false; } MetaModel metaModel = (MetaModel) o; - return Objects.equals(this.pagination, metaModel.pagination); + return Objects.equals(this.pagination, metaModel.pagination)&& + Objects.equals(this.additionalProperties, metaModel.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -99,7 +144,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(pagination); + return Objects.hash(pagination, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -114,6 +159,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class MetaModel {\n"); sb.append(" pagination: ").append(toIndentedString(pagination)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -153,14 +199,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in MetaModel is not found in the empty JSON string", MetaModel.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!MetaModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `MetaModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `pagination` if (jsonObj.get("pagination") != null && !jsonObj.get("pagination").isJsonNull()) { @@ -183,6 +221,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, MetaModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -190,7 +250,28 @@ public void write(JsonWriter out, MetaModel value) throws IOException { public MetaModel 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 + MetaModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ModelsResponse.java b/src/main/java/ai/reveng/model/ModelsResponse.java index 2de5ba5..430f76f 100644 --- a/src/main/java/ai/reveng/model/ModelsResponse.java +++ b/src/main/java/ai/reveng/model/ModelsResponse.java @@ -87,6 +87,50 @@ public void setModels(@javax.annotation.Nonnull List models) { this.models = models; } + /** + * 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 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 ModelsResponse instance itself + */ + public ModelsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } ModelsResponse modelsResponse = (ModelsResponse) o; - return Objects.equals(this.models, modelsResponse.models); + return Objects.equals(this.models, modelsResponse.models)&& + Objects.equals(this.additionalProperties, modelsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(models); + return Objects.hash(models, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelsResponse {\n"); sb.append(" models: ").append(toIndentedString(models)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -151,14 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ModelsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ModelsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ModelsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -189,6 +227,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ModelsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -196,7 +256,28 @@ public void write(JsonWriter out, ModelsResponse value) throws IOException { public ModelsResponse 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 + ModelsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NameConfidence.java b/src/main/java/ai/reveng/model/NameConfidence.java index 9294c3c..d069c3e 100644 --- a/src/main/java/ai/reveng/model/NameConfidence.java +++ b/src/main/java/ai/reveng/model/NameConfidence.java @@ -104,6 +104,50 @@ public void setConfidence(@javax.annotation.Nonnull BigDecimal confidence) { this.confidence = confidence; } + /** + * 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 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 NameConfidence instance itself + */ + public NameConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -116,12 +160,13 @@ public boolean equals(Object o) { } NameConfidence nameConfidence = (NameConfidence) o; return Objects.equals(this.name, nameConfidence.name) && - Objects.equals(this.confidence, nameConfidence.confidence); + Objects.equals(this.confidence, nameConfidence.confidence)&& + Objects.equals(this.additionalProperties, nameConfidence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, confidence); + return Objects.hash(name, confidence, additionalProperties); } @Override @@ -130,6 +175,7 @@ public String toString() { sb.append("class NameConfidence {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -170,14 +216,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NameConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NameConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NameConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NameConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, NameConfidence value) throws IOException { public NameConfidence 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 + NameConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NearestNeighbor.java b/src/main/java/ai/reveng/model/NearestNeighbor.java index d70d75d..f705cf4 100644 --- a/src/main/java/ai/reveng/model/NearestNeighbor.java +++ b/src/main/java/ai/reveng/model/NearestNeighbor.java @@ -246,6 +246,50 @@ public void setNearestNeighborDebug(@javax.annotation.Nonnull Boolean nearestNei this.nearestNeighborDebug = nearestNeighborDebug; } + /** + * 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 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 NearestNeighbor instance itself + */ + public NearestNeighbor putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -264,12 +308,13 @@ public boolean equals(Object o) { Objects.equals(this.nearestNeighborFunctionNameMangled, nearestNeighbor.nearestNeighborFunctionNameMangled) && Objects.equals(this.nearestNeighborBinaryId, nearestNeighbor.nearestNeighborBinaryId) && Objects.equals(this.nearestNeighborSha256Hash, nearestNeighbor.nearestNeighborSha256Hash) && - Objects.equals(this.nearestNeighborDebug, nearestNeighbor.nearestNeighborDebug); + Objects.equals(this.nearestNeighborDebug, nearestNeighbor.nearestNeighborDebug)&& + Objects.equals(this.additionalProperties, nearestNeighbor.additionalProperties); } @Override public int hashCode() { - return Objects.hash(distance, nearestNeighborAnalysisId, nearestNeighborAnalysisName, nearestNeighborFunctionName, nearestNeighborFunctionNameMangled, nearestNeighborBinaryId, nearestNeighborSha256Hash, nearestNeighborDebug); + return Objects.hash(distance, nearestNeighborAnalysisId, nearestNeighborAnalysisName, nearestNeighborFunctionName, nearestNeighborFunctionNameMangled, nearestNeighborBinaryId, nearestNeighborSha256Hash, nearestNeighborDebug, additionalProperties); } @Override @@ -284,6 +329,7 @@ public String toString() { sb.append(" nearestNeighborBinaryId: ").append(toIndentedString(nearestNeighborBinaryId)).append("\n"); sb.append(" nearestNeighborSha256Hash: ").append(toIndentedString(nearestNeighborSha256Hash)).append("\n"); sb.append(" nearestNeighborDebug: ").append(toIndentedString(nearestNeighborDebug)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -324,14 +370,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NearestNeighbor.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NearestNeighbor` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NearestNeighbor.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -368,6 +406,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NearestNeighbor value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -375,7 +435,28 @@ public void write(JsonWriter out, NearestNeighbor value) throws IOException { public NearestNeighbor 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 + NearestNeighbor instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NetworkOverviewDns.java b/src/main/java/ai/reveng/model/NetworkOverviewDns.java index 06d026a..09cf05a 100644 --- a/src/main/java/ai/reveng/model/NetworkOverviewDns.java +++ b/src/main/java/ai/reveng/model/NetworkOverviewDns.java @@ -136,6 +136,50 @@ public void setAnswers(@javax.annotation.Nonnull List this.answers = answers; } + /** + * 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 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 NetworkOverviewDns instance itself + */ + public NetworkOverviewDns putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { NetworkOverviewDns networkOverviewDns = (NetworkOverviewDns) o; return Objects.equals(this.host, networkOverviewDns.host) && Objects.equals(this.type, networkOverviewDns.type) && - Objects.equals(this.answers, networkOverviewDns.answers); + Objects.equals(this.answers, networkOverviewDns.answers)&& + Objects.equals(this.additionalProperties, networkOverviewDns.additionalProperties); } @Override public int hashCode() { - return Objects.hash(host, type, answers); + return Objects.hash(host, type, answers, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" host: ").append(toIndentedString(host)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" answers: ").append(toIndentedString(answers)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NetworkOverviewDns.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkOverviewDns` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NetworkOverviewDns.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -252,6 +290,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkOverviewDns value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -259,7 +319,28 @@ public void write(JsonWriter out, NetworkOverviewDns value) throws IOException { public NetworkOverviewDns 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 + NetworkOverviewDns instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NetworkOverviewDnsAnswer.java b/src/main/java/ai/reveng/model/NetworkOverviewDnsAnswer.java index 23d5c5b..42e3502 100644 --- a/src/main/java/ai/reveng/model/NetworkOverviewDnsAnswer.java +++ b/src/main/java/ai/reveng/model/NetworkOverviewDnsAnswer.java @@ -101,6 +101,50 @@ public void setData(@javax.annotation.Nonnull String data) { this.data = data; } + /** + * 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 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 NetworkOverviewDnsAnswer instance itself + */ + public NetworkOverviewDnsAnswer putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } NetworkOverviewDnsAnswer networkOverviewDnsAnswer = (NetworkOverviewDnsAnswer) o; return Objects.equals(this.type, networkOverviewDnsAnswer.type) && - Objects.equals(this.data, networkOverviewDnsAnswer.data); + Objects.equals(this.data, networkOverviewDnsAnswer.data)&& + Objects.equals(this.additionalProperties, networkOverviewDnsAnswer.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, data); + return Objects.hash(type, data, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class NetworkOverviewDnsAnswer {\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NetworkOverviewDnsAnswer.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkOverviewDnsAnswer` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NetworkOverviewDnsAnswer.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkOverviewDnsAnswer value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, NetworkOverviewDnsAnswer value) throws IOExcep public NetworkOverviewDnsAnswer 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 + NetworkOverviewDnsAnswer instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NetworkOverviewMetadata.java b/src/main/java/ai/reveng/model/NetworkOverviewMetadata.java index 769c5bc..a6dca8a 100644 --- a/src/main/java/ai/reveng/model/NetworkOverviewMetadata.java +++ b/src/main/java/ai/reveng/model/NetworkOverviewMetadata.java @@ -199,6 +199,50 @@ public void setType(@javax.annotation.Nonnull TypeEnum type) { this.type = type; } + /** + * 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 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 NetworkOverviewMetadata instance itself + */ + public NetworkOverviewMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -213,12 +257,13 @@ public boolean equals(Object o) { return Objects.equals(this.host, networkOverviewMetadata.host) && Objects.equals(this.countryCode, networkOverviewMetadata.countryCode) && Objects.equals(this.ASN, networkOverviewMetadata.ASN) && - Objects.equals(this.type, networkOverviewMetadata.type); + Objects.equals(this.type, networkOverviewMetadata.type)&& + Objects.equals(this.additionalProperties, networkOverviewMetadata.additionalProperties); } @Override public int hashCode() { - return Objects.hash(host, countryCode, ASN, type); + return Objects.hash(host, countryCode, ASN, type, additionalProperties); } @Override @@ -229,6 +274,7 @@ public String toString() { sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); sb.append(" ASN: ").append(toIndentedString(ASN)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -269,14 +315,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NetworkOverviewMetadata.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkOverviewMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NetworkOverviewMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -315,6 +353,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkOverviewMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -322,7 +382,28 @@ public void write(JsonWriter out, NetworkOverviewMetadata value) throws IOExcept public NetworkOverviewMetadata 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 + NetworkOverviewMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/NetworkOverviewResponse.java b/src/main/java/ai/reveng/model/NetworkOverviewResponse.java index df183a5..cd01b98 100644 --- a/src/main/java/ai/reveng/model/NetworkOverviewResponse.java +++ b/src/main/java/ai/reveng/model/NetworkOverviewResponse.java @@ -121,6 +121,50 @@ public void setMetadata(@javax.annotation.Nonnull List this.metadata = metadata; } + /** + * 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 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 NetworkOverviewResponse instance itself + */ + public NetworkOverviewResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -133,12 +177,13 @@ public boolean equals(Object o) { } NetworkOverviewResponse networkOverviewResponse = (NetworkOverviewResponse) o; return Objects.equals(this.dns, networkOverviewResponse.dns) && - Objects.equals(this.metadata, networkOverviewResponse.metadata); + Objects.equals(this.metadata, networkOverviewResponse.metadata)&& + Objects.equals(this.additionalProperties, networkOverviewResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dns, metadata); + return Objects.hash(dns, metadata, additionalProperties); } @Override @@ -147,6 +192,7 @@ public String toString() { sb.append("class NetworkOverviewResponse {\n"); sb.append(" dns: ").append(toIndentedString(dns)).append("\n"); sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -187,14 +233,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!NetworkOverviewResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `NetworkOverviewResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : NetworkOverviewResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -239,6 +277,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, NetworkOverviewResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -246,7 +306,28 @@ public void write(JsonWriter out, NetworkOverviewResponse value) throws IOExcept public NetworkOverviewResponse 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 + NetworkOverviewResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/PDBDebugModel.java b/src/main/java/ai/reveng/model/PDBDebugModel.java index 98a7ebe..8a14ebc 100644 --- a/src/main/java/ai/reveng/model/PDBDebugModel.java +++ b/src/main/java/ai/reveng/model/PDBDebugModel.java @@ -88,6 +88,50 @@ public void setDebugEntries(@javax.annotation.Nonnull List this.debugEntries = debugEntries; } + /** + * 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 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 PDBDebugModel instance itself + */ + public PDBDebugModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } PDBDebugModel pdBDebugModel = (PDBDebugModel) o; - return Objects.equals(this.debugEntries, pdBDebugModel.debugEntries); + return Objects.equals(this.debugEntries, pdBDebugModel.debugEntries)&& + Objects.equals(this.additionalProperties, pdBDebugModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(debugEntries); + return Objects.hash(debugEntries, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PDBDebugModel {\n"); sb.append(" debugEntries: ").append(toIndentedString(debugEntries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PDBDebugModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PDBDebugModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PDBDebugModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PDBDebugModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, PDBDebugModel value) throws IOException { public PDBDebugModel 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 + PDBDebugModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/PEModel.java b/src/main/java/ai/reveng/model/PEModel.java index 899768f..fc717be 100644 --- a/src/main/java/ai/reveng/model/PEModel.java +++ b/src/main/java/ai/reveng/model/PEModel.java @@ -552,6 +552,50 @@ public void setIconData(@javax.annotation.Nullable IconModel iconData) { this.iconData = iconData; } + /** + * 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 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 PEModel instance itself + */ + public PEModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -582,12 +626,13 @@ public boolean equals(Object o) { Objects.equals(this.sections, peModel.sections) && Objects.equals(this.imports, peModel.imports) && Objects.equals(this.exports, peModel.exports) && - Objects.equals(this.iconData, peModel.iconData); + Objects.equals(this.iconData, peModel.iconData)&& + Objects.equals(this.additionalProperties, peModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(type, timestamps, architecture, checksum, imageBase, security, versionInfo, debugInfo, numberOfResources, entryPoint, signature, dotnet, debugStripped, importHash, exportHash, richHeaderHash, sections, imports, exports, iconData); + return Objects.hash(type, timestamps, architecture, checksum, imageBase, security, versionInfo, debugInfo, numberOfResources, entryPoint, signature, dotnet, debugStripped, importHash, exportHash, richHeaderHash, sections, imports, exports, iconData, additionalProperties); } @Override @@ -614,6 +659,7 @@ public String toString() { sb.append(" imports: ").append(toIndentedString(imports)).append("\n"); sb.append(" exports: ").append(toIndentedString(exports)).append("\n"); sb.append(" iconData: ").append(toIndentedString(iconData)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -654,14 +700,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PEModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PEModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PEModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -719,6 +757,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PEModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -726,7 +786,28 @@ public void write(JsonWriter out, PEModel value) throws IOException { public PEModel 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 + PEModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/PaginationModel.java b/src/main/java/ai/reveng/model/PaginationModel.java index 3dca324..fef4fd7 100644 --- a/src/main/java/ai/reveng/model/PaginationModel.java +++ b/src/main/java/ai/reveng/model/PaginationModel.java @@ -125,6 +125,50 @@ public void setHasNextPage(@javax.annotation.Nonnull Boolean hasNextPage) { this.hasNextPage = hasNextPage; } + /** + * 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 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 PaginationModel instance itself + */ + public PaginationModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { PaginationModel paginationModel = (PaginationModel) o; return Objects.equals(this.pageSize, paginationModel.pageSize) && Objects.equals(this.pageNumber, paginationModel.pageNumber) && - Objects.equals(this.hasNextPage, paginationModel.hasNextPage); + Objects.equals(this.hasNextPage, paginationModel.hasNextPage)&& + Objects.equals(this.additionalProperties, paginationModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(pageSize, pageNumber, hasNextPage); + return Objects.hash(pageSize, pageNumber, hasNextPage, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); sb.append(" hasNextPage: ").append(toIndentedString(hasNextPage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PaginationModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `PaginationModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : PaginationModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -225,6 +263,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PaginationModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -232,7 +292,28 @@ public void write(JsonWriter out, PaginationModel value) throws IOException { public PaginationModel 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 + PaginationModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Params.java b/src/main/java/ai/reveng/model/Params.java index b6243d5..5962d04 100644 --- a/src/main/java/ai/reveng/model/Params.java +++ b/src/main/java/ai/reveng/model/Params.java @@ -221,6 +221,50 @@ public void setModelName(@javax.annotation.Nonnull String modelName) { this.modelName = modelName; } + /** + * 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 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 Params instance itself + */ + public Params putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -238,12 +282,13 @@ public boolean equals(Object o) { Objects.equals(this.binaryType, params.binaryType) && Objects.equals(this.binaryFormat, params.binaryFormat) && Objects.equals(this.binaryDynamic, params.binaryDynamic) && - Objects.equals(this.modelName, params.modelName); + Objects.equals(this.modelName, params.modelName)&& + Objects.equals(this.additionalProperties, params.additionalProperties); } @Override public int hashCode() { - return Objects.hash(debugHash, binarySize, architecture, binaryType, binaryFormat, binaryDynamic, modelName); + return Objects.hash(debugHash, binarySize, architecture, binaryType, binaryFormat, binaryDynamic, modelName, additionalProperties); } @Override @@ -257,6 +302,7 @@ public String toString() { sb.append(" binaryFormat: ").append(toIndentedString(binaryFormat)).append("\n"); sb.append(" binaryDynamic: ").append(toIndentedString(binaryDynamic)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -297,14 +343,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Params.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Params` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Params.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -344,6 +382,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Params value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -351,7 +411,28 @@ public void write(JsonWriter out, Params value) throws IOException { public Params 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 + Params instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Process.java b/src/main/java/ai/reveng/model/Process.java index a6bbd54..4eab20b 100644 --- a/src/main/java/ai/reveng/model/Process.java +++ b/src/main/java/ai/reveng/model/Process.java @@ -240,6 +240,50 @@ public void setChildren(@javax.annotation.Nonnull List children) { this.children = children; } + /** + * 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 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 Process instance itself + */ + public Process putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -257,12 +301,13 @@ public boolean equals(Object o) { Objects.equals(this.args, process.args) && Objects.equals(this.tsFrom, process.tsFrom) && Objects.equals(this.tsTo, process.tsTo) && - Objects.equals(this.children, process.children); + Objects.equals(this.children, process.children)&& + Objects.equals(this.additionalProperties, process.additionalProperties); } @Override public int hashCode() { - return Objects.hash(pid, procname, executableName, args, tsFrom, tsTo, children); + return Objects.hash(pid, procname, executableName, args, tsFrom, tsTo, children, additionalProperties); } @Override @@ -276,6 +321,7 @@ public String toString() { sb.append(" tsFrom: ").append(toIndentedString(tsFrom)).append("\n"); sb.append(" tsTo: ").append(toIndentedString(tsTo)).append("\n"); sb.append(" children: ").append(toIndentedString(children)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -316,14 +362,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Process.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Process` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Process.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -366,6 +404,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Process value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -373,7 +433,28 @@ public void write(JsonWriter out, Process value) throws IOException { public Process 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 + Process instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessDump.java b/src/main/java/ai/reveng/model/ProcessDump.java index 5020455..63a220c 100644 --- a/src/main/java/ai/reveng/model/ProcessDump.java +++ b/src/main/java/ai/reveng/model/ProcessDump.java @@ -150,6 +150,50 @@ public void setExtendedMetadata(@javax.annotation.Nonnull ProcessDumpMetadata ex this.extendedMetadata = extendedMetadata; } + /** + * 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 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 ProcessDump instance itself + */ + public ProcessDump putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -164,12 +208,13 @@ public boolean equals(Object o) { return Objects.equals(this.baseAddress, processDump.baseAddress) && Objects.equals(this.actualFilename, processDump.actualFilename) && Objects.equals(this.filenameFriendly, processDump.filenameFriendly) && - Objects.equals(this.extendedMetadata, processDump.extendedMetadata); + Objects.equals(this.extendedMetadata, processDump.extendedMetadata)&& + Objects.equals(this.additionalProperties, processDump.additionalProperties); } @Override public int hashCode() { - return Objects.hash(baseAddress, actualFilename, filenameFriendly, extendedMetadata); + return Objects.hash(baseAddress, actualFilename, filenameFriendly, extendedMetadata, additionalProperties); } @Override @@ -180,6 +225,7 @@ public String toString() { sb.append(" actualFilename: ").append(toIndentedString(actualFilename)).append("\n"); sb.append(" filenameFriendly: ").append(toIndentedString(filenameFriendly)).append("\n"); sb.append(" extendedMetadata: ").append(toIndentedString(extendedMetadata)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -220,14 +266,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessDump.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessDump` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessDump.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -260,6 +298,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessDump value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -267,7 +327,28 @@ public void write(JsonWriter out, ProcessDump value) throws IOException { public ProcessDump 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 + ProcessDump instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessDumpMetadata.java b/src/main/java/ai/reveng/model/ProcessDumpMetadata.java index ac05490..6eb7dde 100644 --- a/src/main/java/ai/reveng/model/ProcessDumpMetadata.java +++ b/src/main/java/ai/reveng/model/ProcessDumpMetadata.java @@ -125,6 +125,50 @@ public void setSize(@javax.annotation.Nonnull Integer size) { this.size = size; } + /** + * 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 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 ProcessDumpMetadata instance itself + */ + public ProcessDumpMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { ProcessDumpMetadata processDumpMetadata = (ProcessDumpMetadata) o; return Objects.equals(this.sha256, processDumpMetadata.sha256) && Objects.equals(this.type, processDumpMetadata.type) && - Objects.equals(this.size, processDumpMetadata.size); + Objects.equals(this.size, processDumpMetadata.size)&& + Objects.equals(this.additionalProperties, processDumpMetadata.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sha256, type, size); + return Objects.hash(sha256, type, size, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessDumpMetadata.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessDumpMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessDumpMetadata.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessDumpMetadata value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, ProcessDumpMetadata value) throws IOException public ProcessDumpMetadata 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 + ProcessDumpMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessDumps.java b/src/main/java/ai/reveng/model/ProcessDumps.java index ed56e70..b278b7f 100644 --- a/src/main/java/ai/reveng/model/ProcessDumps.java +++ b/src/main/java/ai/reveng/model/ProcessDumps.java @@ -102,6 +102,50 @@ public void setData(@javax.annotation.Nonnull ProcessDumpsData data) { this.data = data; } + /** + * 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 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 ProcessDumps instance itself + */ + public ProcessDumps putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } ProcessDumps processDumps = (ProcessDumps) o; return Objects.equals(this.success, processDumps.success) && - Objects.equals(this.data, processDumps.data); + Objects.equals(this.data, processDumps.data)&& + Objects.equals(this.additionalProperties, processDumps.additionalProperties); } @Override public int hashCode() { - return Objects.hash(success, data); + return Objects.hash(success, data, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class ProcessDumps {\n"); sb.append(" success: ").append(toIndentedString(success)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessDumps.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessDumps` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessDumps.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessDumps value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, ProcessDumps value) throws IOException { public ProcessDumps 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 + ProcessDumps instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessDumpsData.java b/src/main/java/ai/reveng/model/ProcessDumpsData.java index a1ebafa..edba624 100644 --- a/src/main/java/ai/reveng/model/ProcessDumpsData.java +++ b/src/main/java/ai/reveng/model/ProcessDumpsData.java @@ -112,6 +112,50 @@ public void setDumps(@javax.annotation.Nonnull List dumps) { this.dumps = dumps; } + /** + * 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 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 ProcessDumpsData instance itself + */ + public ProcessDumpsData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } ProcessDumpsData processDumpsData = (ProcessDumpsData) o; return Objects.equals(this.count, processDumpsData.count) && - Objects.equals(this.dumps, processDumpsData.dumps); + Objects.equals(this.dumps, processDumpsData.dumps)&& + Objects.equals(this.additionalProperties, processDumpsData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(count, dumps); + return Objects.hash(count, dumps, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class ProcessDumpsData {\n"); sb.append(" count: ").append(toIndentedString(count)).append("\n"); sb.append(" dumps: ").append(toIndentedString(dumps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessDumpsData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessDumpsData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessDumpsData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessDumpsData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, ProcessDumpsData value) throws IOException { public ProcessDumpsData 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 + ProcessDumpsData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessRegistry.java b/src/main/java/ai/reveng/model/ProcessRegistry.java index 3936bc5..5783bba 100644 --- a/src/main/java/ai/reveng/model/ProcessRegistry.java +++ b/src/main/java/ai/reveng/model/ProcessRegistry.java @@ -113,6 +113,50 @@ public void setData(@javax.annotation.Nonnull Map> data) this.data = data; } + /** + * 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 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 ProcessRegistry instance itself + */ + public ProcessRegistry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -125,12 +169,13 @@ public boolean equals(Object o) { } ProcessRegistry processRegistry = (ProcessRegistry) o; return Objects.equals(this.success, processRegistry.success) && - Objects.equals(this.data, processRegistry.data); + Objects.equals(this.data, processRegistry.data)&& + Objects.equals(this.additionalProperties, processRegistry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(success, data); + return Objects.hash(success, data, additionalProperties); } @Override @@ -139,6 +184,7 @@ public String toString() { sb.append("class ProcessRegistry {\n"); sb.append(" success: ").append(toIndentedString(success)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -179,14 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessRegistry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessRegistry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessRegistry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -211,6 +249,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessRegistry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -218,7 +278,28 @@ public void write(JsonWriter out, ProcessRegistry value) throws IOException { public ProcessRegistry 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 + ProcessRegistry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ProcessTree.java b/src/main/java/ai/reveng/model/ProcessTree.java index 3b9b5fa..624a3b7 100644 --- a/src/main/java/ai/reveng/model/ProcessTree.java +++ b/src/main/java/ai/reveng/model/ProcessTree.java @@ -112,6 +112,50 @@ public void setData(@javax.annotation.Nonnull List data) { this.data = data; } + /** + * 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 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 ProcessTree instance itself + */ + public ProcessTree putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } ProcessTree processTree = (ProcessTree) o; return Objects.equals(this.success, processTree.success) && - Objects.equals(this.data, processTree.data); + Objects.equals(this.data, processTree.data)&& + Objects.equals(this.additionalProperties, processTree.additionalProperties); } @Override public int hashCode() { - return Objects.hash(success, data); + return Objects.hash(success, data, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class ProcessTree {\n"); sb.append(" success: ").append(toIndentedString(success)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProcessTree.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ProcessTree` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ProcessTree.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ProcessTree value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, ProcessTree value) throws IOException { public ProcessTree 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 + ProcessTree instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/QueuedSecurityChecksTaskResponse.java b/src/main/java/ai/reveng/model/QueuedSecurityChecksTaskResponse.java index 3c39bbd..32afa73 100644 --- a/src/main/java/ai/reveng/model/QueuedSecurityChecksTaskResponse.java +++ b/src/main/java/ai/reveng/model/QueuedSecurityChecksTaskResponse.java @@ -77,6 +77,50 @@ public void setTaskId(@javax.annotation.Nonnull String taskId) { this.taskId = taskId; } + /** + * 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 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 QueuedSecurityChecksTaskResponse instance itself + */ + public QueuedSecurityChecksTaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } QueuedSecurityChecksTaskResponse queuedSecurityChecksTaskResponse = (QueuedSecurityChecksTaskResponse) o; - return Objects.equals(this.taskId, queuedSecurityChecksTaskResponse.taskId); + return Objects.equals(this.taskId, queuedSecurityChecksTaskResponse.taskId)&& + Objects.equals(this.additionalProperties, queuedSecurityChecksTaskResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(taskId); + return Objects.hash(taskId, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class QueuedSecurityChecksTaskResponse {\n"); sb.append(" taskId: ").append(toIndentedString(taskId)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QueuedSecurityChecksTaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `QueuedSecurityChecksTaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : QueuedSecurityChecksTaskResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QueuedSecurityChecksTaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, QueuedSecurityChecksTaskResponse value) throws public QueuedSecurityChecksTaskResponse 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 + QueuedSecurityChecksTaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ReAnalysisForm.java b/src/main/java/ai/reveng/model/ReAnalysisForm.java index 3d8cfab..72c78b7 100644 --- a/src/main/java/ai/reveng/model/ReAnalysisForm.java +++ b/src/main/java/ai/reveng/model/ReAnalysisForm.java @@ -213,6 +213,50 @@ public void setNoCache(@javax.annotation.Nullable Boolean noCache) { this.noCache = noCache; } + /** + * 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 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 ReAnalysisForm instance itself + */ + public ReAnalysisForm putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -229,7 +273,8 @@ public boolean equals(Object o) { Objects.equals(this.priority, reAnalysisForm.priority) && Objects.equals(this.essential, reAnalysisForm.essential) && Objects.equals(this.modelName, reAnalysisForm.modelName) && - Objects.equals(this.noCache, reAnalysisForm.noCache); + Objects.equals(this.noCache, reAnalysisForm.noCache)&& + Objects.equals(this.additionalProperties, reAnalysisForm.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -238,7 +283,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(tags, commandLineArgs, priority, essential, modelName, noCache); + return Objects.hash(tags, commandLineArgs, priority, essential, modelName, noCache, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -258,6 +303,7 @@ public String toString() { sb.append(" essential: ").append(toIndentedString(essential)).append("\n"); sb.append(" modelName: ").append(toIndentedString(modelName)).append("\n"); sb.append(" noCache: ").append(toIndentedString(noCache)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -297,14 +343,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ReAnalysisForm is not found in the empty JSON string", ReAnalysisForm.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ReAnalysisForm.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ReAnalysisForm` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull() && !jsonObj.get("tags").isJsonArray()) { @@ -333,6 +371,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ReAnalysisForm value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -340,7 +400,28 @@ public void write(JsonWriter out, ReAnalysisForm value) throws IOException { public ReAnalysisForm 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 + ReAnalysisForm instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Recent.java b/src/main/java/ai/reveng/model/Recent.java index c4b0cd4..8079603 100644 --- a/src/main/java/ai/reveng/model/Recent.java +++ b/src/main/java/ai/reveng/model/Recent.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List results) { this.results = results; } + /** + * 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 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 Recent instance itself + */ + public Recent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } Recent recent = (Recent) o; - return Objects.equals(this.results, recent.results); + return Objects.equals(this.results, recent.results)&& + Objects.equals(this.additionalProperties, recent.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Recent {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Recent.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Recent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Recent.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Recent value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, Recent value) throws IOException { public Recent 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 + Recent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Registry.java b/src/main/java/ai/reveng/model/Registry.java index 5f4d248..241a52f 100644 --- a/src/main/java/ai/reveng/model/Registry.java +++ b/src/main/java/ai/reveng/model/Registry.java @@ -149,6 +149,50 @@ public void setValue(@javax.annotation.Nullable String value) { this.value = value; } + /** + * 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 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 Registry instance itself + */ + public Registry putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -163,12 +207,13 @@ public boolean equals(Object o) { return Objects.equals(this.method, registry.method) && Objects.equals(this.key, registry.key) && Objects.equals(this.valueName, registry.valueName) && - Objects.equals(this.value, registry.value); + Objects.equals(this.value, registry.value)&& + Objects.equals(this.additionalProperties, registry.additionalProperties); } @Override public int hashCode() { - return Objects.hash(method, key, valueName, value); + return Objects.hash(method, key, valueName, value, additionalProperties); } @Override @@ -179,6 +224,7 @@ public String toString() { sb.append(" key: ").append(toIndentedString(key)).append("\n"); sb.append(" valueName: ").append(toIndentedString(valueName)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -219,14 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Registry.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Registry` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Registry.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -263,6 +301,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Registry value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -270,7 +330,28 @@ public void write(JsonWriter out, Registry value) throws IOException { public Registry 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 + Registry instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/RelativeBinaryResponse.java b/src/main/java/ai/reveng/model/RelativeBinaryResponse.java index 2cce75f..d1b8dd9 100644 --- a/src/main/java/ai/reveng/model/RelativeBinaryResponse.java +++ b/src/main/java/ai/reveng/model/RelativeBinaryResponse.java @@ -125,6 +125,50 @@ public void setSha256(@javax.annotation.Nonnull String sha256) { this.sha256 = sha256; } + /** + * 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 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 RelativeBinaryResponse instance itself + */ + public RelativeBinaryResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { RelativeBinaryResponse relativeBinaryResponse = (RelativeBinaryResponse) o; return Objects.equals(this.binaryId, relativeBinaryResponse.binaryId) && Objects.equals(this.name, relativeBinaryResponse.name) && - Objects.equals(this.sha256, relativeBinaryResponse.sha256); + Objects.equals(this.sha256, relativeBinaryResponse.sha256)&& + Objects.equals(this.additionalProperties, relativeBinaryResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryId, name, sha256); + return Objects.hash(binaryId, name, sha256, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!RelativeBinaryResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `RelativeBinaryResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RelativeBinaryResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, RelativeBinaryResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, RelativeBinaryResponse value) throws IOExcepti public RelativeBinaryResponse 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 + RelativeBinaryResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SBOM.java b/src/main/java/ai/reveng/model/SBOM.java index a595360..a198b82 100644 --- a/src/main/java/ai/reveng/model/SBOM.java +++ b/src/main/java/ai/reveng/model/SBOM.java @@ -120,6 +120,50 @@ public void setImportedLibs(@javax.annotation.Nonnull List importedLibs) this.importedLibs = importedLibs; } + /** + * 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 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 SBOM instance itself + */ + public SBOM putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -132,12 +176,13 @@ public boolean equals(Object o) { } SBOM SBOM = (SBOM) o; return Objects.equals(this.packages, SBOM.packages) && - Objects.equals(this.importedLibs, SBOM.importedLibs); + Objects.equals(this.importedLibs, SBOM.importedLibs)&& + Objects.equals(this.additionalProperties, SBOM.additionalProperties); } @Override public int hashCode() { - return Objects.hash(packages, importedLibs); + return Objects.hash(packages, importedLibs, additionalProperties); } @Override @@ -146,6 +191,7 @@ public String toString() { sb.append("class SBOM {\n"); sb.append(" packages: ").append(toIndentedString(packages)).append("\n"); sb.append(" importedLibs: ").append(toIndentedString(importedLibs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -186,14 +232,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SBOM.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SBOM` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SBOM.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -234,6 +272,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SBOM value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +301,28 @@ public void write(JsonWriter out, SBOM value) throws IOException { public SBOM 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 + SBOM instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SBOMPackage.java b/src/main/java/ai/reveng/model/SBOMPackage.java index 2a24a31..2308cb5 100644 --- a/src/main/java/ai/reveng/model/SBOMPackage.java +++ b/src/main/java/ai/reveng/model/SBOMPackage.java @@ -101,6 +101,50 @@ public void setVersion(@javax.annotation.Nonnull String version) { this.version = version; } + /** + * 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 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 SBOMPackage instance itself + */ + public SBOMPackage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } SBOMPackage sbOMPackage = (SBOMPackage) o; return Objects.equals(this.name, sbOMPackage.name) && - Objects.equals(this.version, sbOMPackage.version); + Objects.equals(this.version, sbOMPackage.version)&& + Objects.equals(this.additionalProperties, sbOMPackage.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, version); + return Objects.hash(name, version, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class SBOMPackage {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SBOMPackage.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SBOMPackage` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SBOMPackage.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SBOMPackage value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, SBOMPackage value) throws IOException { public SBOMPackage 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 + SBOMPackage instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SandboxOptions.java b/src/main/java/ai/reveng/model/SandboxOptions.java index d95f0ef..71116d9 100644 --- a/src/main/java/ai/reveng/model/SandboxOptions.java +++ b/src/main/java/ai/reveng/model/SandboxOptions.java @@ -101,6 +101,50 @@ public void setCommandLineArgs(@javax.annotation.Nullable String commandLineArgs this.commandLineArgs = commandLineArgs; } + /** + * 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 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 SandboxOptions instance itself + */ + public SandboxOptions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } SandboxOptions sandboxOptions = (SandboxOptions) o; return Objects.equals(this.enabled, sandboxOptions.enabled) && - Objects.equals(this.commandLineArgs, sandboxOptions.commandLineArgs); + Objects.equals(this.commandLineArgs, sandboxOptions.commandLineArgs)&& + Objects.equals(this.additionalProperties, sandboxOptions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, commandLineArgs); + return Objects.hash(enabled, commandLineArgs, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class SandboxOptions {\n"); sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); sb.append(" commandLineArgs: ").append(toIndentedString(commandLineArgs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,14 +212,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SandboxOptions is not found in the empty JSON string", SandboxOptions.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SandboxOptions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SandboxOptions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("command_line_args") != null && !jsonObj.get("command_line_args").isJsonNull()) && !jsonObj.get("command_line_args").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `command_line_args` to be a primitive type in the JSON string but got `%s`", jsonObj.get("command_line_args").toString())); @@ -195,6 +233,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SandboxOptions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +262,28 @@ public void write(JsonWriter out, SandboxOptions value) throws IOException { public SandboxOptions 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 + SandboxOptions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java index 5662892..0aab3e3 100644 --- a/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java +++ b/src/main/java/ai/reveng/model/ScrapeThirdPartyConfig.java @@ -77,6 +77,50 @@ public void setEnabled(@javax.annotation.Nullable Boolean enabled) { this.enabled = enabled; } + /** + * 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 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 ScrapeThirdPartyConfig instance itself + */ + public ScrapeThirdPartyConfig putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } ScrapeThirdPartyConfig scrapeThirdPartyConfig = (ScrapeThirdPartyConfig) o; - return Objects.equals(this.enabled, scrapeThirdPartyConfig.enabled); + return Objects.equals(this.enabled, scrapeThirdPartyConfig.enabled)&& + Objects.equals(this.additionalProperties, scrapeThirdPartyConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled); + return Objects.hash(enabled, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ScrapeThirdPartyConfig {\n"); sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -140,14 +186,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ScrapeThirdPartyConfig is not found in the empty JSON string", ScrapeThirdPartyConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ScrapeThirdPartyConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ScrapeThirdPartyConfig` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -166,6 +204,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ScrapeThirdPartyConfig value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -173,7 +233,28 @@ public void write(JsonWriter out, ScrapeThirdPartyConfig value) throws IOExcepti public ScrapeThirdPartyConfig 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 + ScrapeThirdPartyConfig instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SectionModel.java b/src/main/java/ai/reveng/model/SectionModel.java index 0a34411..1318e8e 100644 --- a/src/main/java/ai/reveng/model/SectionModel.java +++ b/src/main/java/ai/reveng/model/SectionModel.java @@ -112,6 +112,50 @@ public void setSections(@javax.annotation.Nonnull List secti this.sections = sections; } + /** + * 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 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 SectionModel instance itself + */ + public SectionModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } SectionModel sectionModel = (SectionModel) o; return Objects.equals(this.numberOfSections, sectionModel.numberOfSections) && - Objects.equals(this.sections, sectionModel.sections); + Objects.equals(this.sections, sectionModel.sections)&& + Objects.equals(this.additionalProperties, sectionModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(numberOfSections, sections); + return Objects.hash(numberOfSections, sections, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class SectionModel {\n"); sb.append(" numberOfSections: ").append(toIndentedString(numberOfSections)).append("\n"); sb.append(" sections: ").append(toIndentedString(sections)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SectionModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SectionModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SectionModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SectionModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, SectionModel value) throws IOException { public SectionModel 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 + SectionModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SecurityChecksResponse.java b/src/main/java/ai/reveng/model/SecurityChecksResponse.java index e4c505d..e3c31d1 100644 --- a/src/main/java/ai/reveng/model/SecurityChecksResponse.java +++ b/src/main/java/ai/reveng/model/SecurityChecksResponse.java @@ -136,6 +136,50 @@ public void setResults(@javax.annotation.Nonnull List resu this.results = results; } + /** + * 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 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 SecurityChecksResponse instance itself + */ + public SecurityChecksResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -149,12 +193,13 @@ public boolean equals(Object o) { SecurityChecksResponse securityChecksResponse = (SecurityChecksResponse) o; return Objects.equals(this.binaryId, securityChecksResponse.binaryId) && Objects.equals(this.totalResults, securityChecksResponse.totalResults) && - Objects.equals(this.results, securityChecksResponse.results); + Objects.equals(this.results, securityChecksResponse.results)&& + Objects.equals(this.additionalProperties, securityChecksResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(binaryId, totalResults, results); + return Objects.hash(binaryId, totalResults, results, additionalProperties); } @Override @@ -164,6 +209,7 @@ public String toString() { sb.append(" binaryId: ").append(toIndentedString(binaryId)).append("\n"); sb.append(" totalResults: ").append(toIndentedString(totalResults)).append("\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -204,14 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SecurityChecksResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SecurityChecksResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SecurityChecksResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -246,6 +284,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SecurityChecksResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -253,7 +313,28 @@ public void write(JsonWriter out, SecurityChecksResponse value) throws IOExcepti public SecurityChecksResponse 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 + SecurityChecksResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SecurityChecksResult.java b/src/main/java/ai/reveng/model/SecurityChecksResult.java index 449ae26..2bf68ec 100644 --- a/src/main/java/ai/reveng/model/SecurityChecksResult.java +++ b/src/main/java/ai/reveng/model/SecurityChecksResult.java @@ -248,6 +248,50 @@ public void setSeverity(@javax.annotation.Nonnull SeverityType severity) { this.severity = severity; } + /** + * 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 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 SecurityChecksResult instance itself + */ + public SecurityChecksResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -266,12 +310,13 @@ public boolean equals(Object o) { Objects.equals(this.description, securityChecksResult.description) && Objects.equals(this.remediation, securityChecksResult.remediation) && Objects.equals(this.confidence, securityChecksResult.confidence) && - Objects.equals(this.severity, securityChecksResult.severity); + Objects.equals(this.severity, securityChecksResult.severity)&& + Objects.equals(this.additionalProperties, securityChecksResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName, name, vulnClass, description, remediation, confidence, severity); + return Objects.hash(functionId, functionName, name, vulnClass, description, remediation, confidence, severity, additionalProperties); } @Override @@ -286,6 +331,7 @@ public String toString() { sb.append(" remediation: ").append(toIndentedString(remediation)).append("\n"); sb.append(" confidence: ").append(toIndentedString(confidence)).append("\n"); sb.append(" severity: ").append(toIndentedString(severity)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -326,14 +372,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SecurityChecksResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SecurityChecksResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SecurityChecksResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -376,6 +414,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SecurityChecksResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -383,7 +443,28 @@ public void write(JsonWriter out, SecurityChecksResult value) throws IOException public SecurityChecksResult 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 + SecurityChecksResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SecurityModel.java b/src/main/java/ai/reveng/model/SecurityModel.java index 46d8e88..3cfe425 100644 --- a/src/main/java/ai/reveng/model/SecurityModel.java +++ b/src/main/java/ai/reveng/model/SecurityModel.java @@ -317,6 +317,50 @@ public void setBoundImage(@javax.annotation.Nonnull Boolean boundImage) { this.boundImage = boundImage; } + /** + * 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 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 SecurityModel instance itself + */ + public SecurityModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -338,12 +382,13 @@ public boolean equals(Object o) { Objects.equals(this.codeIntegrity, securityModel.codeIntegrity) && Objects.equals(this.highEntropy, securityModel.highEntropy) && Objects.equals(this.seh, securityModel.seh) && - Objects.equals(this.boundImage, securityModel.boundImage); + Objects.equals(this.boundImage, securityModel.boundImage)&& + Objects.equals(this.additionalProperties, securityModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(aslr, dep, cfg, driverModel, appContainer, terminalServerAware, imageIsolation, codeIntegrity, highEntropy, seh, boundImage); + return Objects.hash(aslr, dep, cfg, driverModel, appContainer, terminalServerAware, imageIsolation, codeIntegrity, highEntropy, seh, boundImage, additionalProperties); } @Override @@ -361,6 +406,7 @@ public String toString() { sb.append(" highEntropy: ").append(toIndentedString(highEntropy)).append("\n"); sb.append(" seh: ").append(toIndentedString(seh)).append("\n"); sb.append(" boundImage: ").append(toIndentedString(boundImage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -401,14 +447,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SecurityModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SecurityModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SecurityModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -433,6 +471,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SecurityModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -440,7 +500,28 @@ public void write(JsonWriter out, SecurityModel value) throws IOException { public SecurityModel 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 + SecurityModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SimilarFunctionsResponse.java b/src/main/java/ai/reveng/model/SimilarFunctionsResponse.java index 12b9145..74a7632 100644 --- a/src/main/java/ai/reveng/model/SimilarFunctionsResponse.java +++ b/src/main/java/ai/reveng/model/SimilarFunctionsResponse.java @@ -264,6 +264,50 @@ public void setSha256Hash(@javax.annotation.Nonnull String sha256Hash) { this.sha256Hash = sha256Hash; } + /** + * 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 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 SimilarFunctionsResponse instance itself + */ + public SimilarFunctionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -282,12 +326,13 @@ public boolean equals(Object o) { Objects.equals(this.distance, similarFunctionsResponse.distance) && Objects.equals(this.embedding3d, similarFunctionsResponse.embedding3d) && Objects.equals(this.embedding1d, similarFunctionsResponse.embedding1d) && - Objects.equals(this.sha256Hash, similarFunctionsResponse.sha256Hash); + Objects.equals(this.sha256Hash, similarFunctionsResponse.sha256Hash)&& + Objects.equals(this.additionalProperties, similarFunctionsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionId, functionName, binaryId, binaryName, distance, embedding3d, embedding1d, sha256Hash); + return Objects.hash(functionId, functionName, binaryId, binaryName, distance, embedding3d, embedding1d, sha256Hash, additionalProperties); } @Override @@ -302,6 +347,7 @@ public String toString() { sb.append(" embedding3d: ").append(toIndentedString(embedding3d)).append("\n"); sb.append(" embedding1d: ").append(toIndentedString(embedding1d)).append("\n"); sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -342,14 +388,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SimilarFunctionsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SimilarFunctionsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SimilarFunctionsResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -395,6 +433,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SimilarFunctionsResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -402,7 +462,28 @@ public void write(JsonWriter out, SimilarFunctionsResponse value) throws IOExcep public SimilarFunctionsResponse 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 + SimilarFunctionsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java b/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java index 58fdf5b..f3ae8f9 100644 --- a/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java +++ b/src/main/java/ai/reveng/model/SingleCodeCertificateModel.java @@ -197,6 +197,50 @@ public void setSubjectName(@javax.annotation.Nonnull String subjectName) { this.subjectName = subjectName; } + /** + * 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 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 SingleCodeCertificateModel instance itself + */ + public SingleCodeCertificateModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -213,12 +257,13 @@ public boolean equals(Object o) { Objects.equals(this.expiresOn, singleCodeCertificateModel.expiresOn) && Objects.equals(this.issuerName, singleCodeCertificateModel.issuerName) && Objects.equals(this.serialNumber, singleCodeCertificateModel.serialNumber) && - Objects.equals(this.subjectName, singleCodeCertificateModel.subjectName); + Objects.equals(this.subjectName, singleCodeCertificateModel.subjectName)&& + Objects.equals(this.additionalProperties, singleCodeCertificateModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(version, issuedOn, expiresOn, issuerName, serialNumber, subjectName); + return Objects.hash(version, issuedOn, expiresOn, issuerName, serialNumber, subjectName, additionalProperties); } @Override @@ -231,6 +276,7 @@ public String toString() { sb.append(" issuerName: ").append(toIndentedString(issuerName)).append("\n"); sb.append(" serialNumber: ").append(toIndentedString(serialNumber)).append("\n"); sb.append(" subjectName: ").append(toIndentedString(subjectName)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -271,14 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SingleCodeCertificateModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SingleCodeCertificateModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleCodeCertificateModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -318,6 +356,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SingleCodeCertificateModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -325,7 +385,28 @@ public void write(JsonWriter out, SingleCodeCertificateModel value) throws IOExc public SingleCodeCertificateModel 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 + SingleCodeCertificateModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java b/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java index 730fdea..8a076db 100644 --- a/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java +++ b/src/main/java/ai/reveng/model/SingleCodeSignatureModel.java @@ -112,6 +112,50 @@ public void setAuthenticodeDigest(@javax.annotation.Nonnull String authenticodeD this.authenticodeDigest = authenticodeDigest; } + /** + * 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 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 SingleCodeSignatureModel instance itself + */ + public SingleCodeSignatureModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } SingleCodeSignatureModel singleCodeSignatureModel = (SingleCodeSignatureModel) o; return Objects.equals(this.certificates, singleCodeSignatureModel.certificates) && - Objects.equals(this.authenticodeDigest, singleCodeSignatureModel.authenticodeDigest); + Objects.equals(this.authenticodeDigest, singleCodeSignatureModel.authenticodeDigest)&& + Objects.equals(this.additionalProperties, singleCodeSignatureModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificates, authenticodeDigest); + return Objects.hash(certificates, authenticodeDigest, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class SingleCodeSignatureModel {\n"); sb.append(" certificates: ").append(toIndentedString(certificates)).append("\n"); sb.append(" authenticodeDigest: ").append(toIndentedString(authenticodeDigest)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SingleCodeSignatureModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SingleCodeSignatureModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleCodeSignatureModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SingleCodeSignatureModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, SingleCodeSignatureModel value) throws IOExcep public SingleCodeSignatureModel 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 + SingleCodeSignatureModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SinglePDBEntryModel.java b/src/main/java/ai/reveng/model/SinglePDBEntryModel.java index 78b384a..7c44ae0 100644 --- a/src/main/java/ai/reveng/model/SinglePDBEntryModel.java +++ b/src/main/java/ai/reveng/model/SinglePDBEntryModel.java @@ -125,6 +125,50 @@ public void setPath(@javax.annotation.Nonnull String path) { this.path = path; } + /** + * 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 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 SinglePDBEntryModel instance itself + */ + public SinglePDBEntryModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { SinglePDBEntryModel singlePDBEntryModel = (SinglePDBEntryModel) o; return Objects.equals(this.guid, singlePDBEntryModel.guid) && Objects.equals(this.age, singlePDBEntryModel.age) && - Objects.equals(this.path, singlePDBEntryModel.path); + Objects.equals(this.path, singlePDBEntryModel.path)&& + Objects.equals(this.additionalProperties, singlePDBEntryModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(guid, age, path); + return Objects.hash(guid, age, path, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" guid: ").append(toIndentedString(guid)).append("\n"); sb.append(" age: ").append(toIndentedString(age)).append("\n"); sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SinglePDBEntryModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SinglePDBEntryModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SinglePDBEntryModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -231,6 +269,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SinglePDBEntryModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -238,7 +298,28 @@ public void write(JsonWriter out, SinglePDBEntryModel value) throws IOException public SinglePDBEntryModel 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 + SinglePDBEntryModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/SingleSectionModel.java b/src/main/java/ai/reveng/model/SingleSectionModel.java index e1dba36..f48ae89 100644 --- a/src/main/java/ai/reveng/model/SingleSectionModel.java +++ b/src/main/java/ai/reveng/model/SingleSectionModel.java @@ -222,6 +222,50 @@ public void setSha3256(@javax.annotation.Nonnull String sha3256) { this.sha3256 = sha3256; } + /** + * 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 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 SingleSectionModel instance itself + */ + public SingleSectionModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -239,12 +283,13 @@ public boolean equals(Object o) { Objects.equals(this.characteristics, singleSectionModel.characteristics) && Objects.equals(this.rawSize, singleSectionModel.rawSize) && Objects.equals(this.entropy, singleSectionModel.entropy) && - Objects.equals(this.sha3256, singleSectionModel.sha3256); + Objects.equals(this.sha3256, singleSectionModel.sha3256)&& + Objects.equals(this.additionalProperties, singleSectionModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, virtualAddress, virtualSize, characteristics, rawSize, entropy, sha3256); + return Objects.hash(name, virtualAddress, virtualSize, characteristics, rawSize, entropy, sha3256, additionalProperties); } @Override @@ -258,6 +303,7 @@ public String toString() { sb.append(" rawSize: ").append(toIndentedString(rawSize)).append("\n"); sb.append(" entropy: ").append(toIndentedString(entropy)).append("\n"); sb.append(" sha3256: ").append(toIndentedString(sha3256)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -298,14 +344,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SingleSectionModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `SingleSectionModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : SingleSectionModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -339,6 +377,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SingleSectionModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -346,7 +406,28 @@ public void write(JsonWriter out, SingleSectionModel value) throws IOException { public SingleSectionModel 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 + SingleSectionModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/StackVariable.java b/src/main/java/ai/reveng/model/StackVariable.java index 94c90f2..04eb934 100644 --- a/src/main/java/ai/reveng/model/StackVariable.java +++ b/src/main/java/ai/reveng/model/StackVariable.java @@ -198,6 +198,50 @@ public void setAddr(@javax.annotation.Nonnull Integer addr) { this.addr = addr; } + /** + * 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 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 StackVariable instance itself + */ + public StackVariable putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -214,7 +258,8 @@ public boolean equals(Object o) { Objects.equals(this.name, stackVariable.name) && Objects.equals(this.type, stackVariable.type) && Objects.equals(this.size, stackVariable.size) && - Objects.equals(this.addr, stackVariable.addr); + Objects.equals(this.addr, stackVariable.addr)&& + Objects.equals(this.additionalProperties, stackVariable.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -223,7 +268,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, offset, name, type, size, addr); + return Objects.hash(lastChange, offset, name, type, size, addr, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -243,6 +288,7 @@ public String toString() { sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" addr: ").append(toIndentedString(addr)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -283,14 +329,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StackVariable.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StackVariable` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StackVariable.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -324,6 +362,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StackVariable value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -331,7 +391,28 @@ public void write(JsonWriter out, StackVariable value) throws IOException { public StackVariable 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 + StackVariable instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/StatusOutput.java b/src/main/java/ai/reveng/model/StatusOutput.java index e961dd4..83cf29f 100644 --- a/src/main/java/ai/reveng/model/StatusOutput.java +++ b/src/main/java/ai/reveng/model/StatusOutput.java @@ -101,6 +101,50 @@ public void setAnalysisStatus(@javax.annotation.Nonnull String analysisStatus) { this.analysisStatus = analysisStatus; } + /** + * 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 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 StatusOutput instance itself + */ + public StatusOutput putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } StatusOutput statusOutput = (StatusOutput) o; return Objects.equals(this.analysisId, statusOutput.analysisId) && - Objects.equals(this.analysisStatus, statusOutput.analysisStatus); + Objects.equals(this.analysisStatus, statusOutput.analysisStatus)&& + Objects.equals(this.additionalProperties, statusOutput.additionalProperties); } @Override public int hashCode() { - return Objects.hash(analysisId, analysisStatus); + return Objects.hash(analysisId, analysisStatus, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class StatusOutput {\n"); sb.append(" analysisId: ").append(toIndentedString(analysisId)).append("\n"); sb.append(" analysisStatus: ").append(toIndentedString(analysisStatus)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StatusOutput.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StatusOutput` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StatusOutput.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StatusOutput value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, StatusOutput value) throws IOException { public StatusOutput 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 + StatusOutput instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/StringFunctions.java b/src/main/java/ai/reveng/model/StringFunctions.java index 41a4564..4145520 100644 --- a/src/main/java/ai/reveng/model/StringFunctions.java +++ b/src/main/java/ai/reveng/model/StringFunctions.java @@ -112,6 +112,50 @@ public void setFunctions(@javax.annotation.Nonnull List 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 StringFunctions instance itself + */ + public StringFunctions putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } StringFunctions stringFunctions = (StringFunctions) o; return Objects.equals(this.value, stringFunctions.value) && - Objects.equals(this.functions, stringFunctions.functions); + Objects.equals(this.functions, stringFunctions.functions)&& + Objects.equals(this.additionalProperties, stringFunctions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(value, functions); + return Objects.hash(value, functions, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class StringFunctions {\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); sb.append(" functions: ").append(toIndentedString(functions)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StringFunctions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StringFunctions` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StringFunctions.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -223,6 +261,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StringFunctions value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -230,7 +290,28 @@ public void write(JsonWriter out, StringFunctions value) throws IOException { public StringFunctions 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 + StringFunctions instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Structure.java b/src/main/java/ai/reveng/model/Structure.java index 8d6c5a9..abe9fb6 100644 --- a/src/main/java/ai/reveng/model/Structure.java +++ b/src/main/java/ai/reveng/model/Structure.java @@ -185,6 +185,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 Structure instance itself + */ + public Structure putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -200,7 +244,8 @@ public boolean equals(Object o) { Objects.equals(this.name, structure.name) && Objects.equals(this.size, structure.size) && Objects.equals(this.members, structure.members) && - Objects.equals(this.artifactType, structure.artifactType); + Objects.equals(this.artifactType, structure.artifactType)&& + Objects.equals(this.additionalProperties, structure.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -209,7 +254,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, name, size, members, artifactType); + return Objects.hash(lastChange, name, size, members, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -228,6 +273,7 @@ public String toString() { sb.append(" size: ").append(toIndentedString(size)).append("\n"); sb.append(" members: ").append(toIndentedString(members)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -268,14 +314,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Structure.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Structure` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Structure.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -309,6 +347,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Structure value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -316,7 +376,28 @@ public void write(JsonWriter out, Structure value) throws IOException { public Structure 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 + Structure instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/StructureMember.java b/src/main/java/ai/reveng/model/StructureMember.java index f33fe38..7e0319a 100644 --- a/src/main/java/ai/reveng/model/StructureMember.java +++ b/src/main/java/ai/reveng/model/StructureMember.java @@ -174,6 +174,50 @@ public void setSize(@javax.annotation.Nonnull Integer size) { this.size = size; } + /** + * 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 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 StructureMember instance itself + */ + public StructureMember putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -189,7 +233,8 @@ public boolean equals(Object o) { Objects.equals(this.name, structureMember.name) && Objects.equals(this.offset, structureMember.offset) && Objects.equals(this.type, structureMember.type) && - Objects.equals(this.size, structureMember.size); + Objects.equals(this.size, structureMember.size)&& + Objects.equals(this.additionalProperties, structureMember.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -198,7 +243,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, name, offset, type, size); + return Objects.hash(lastChange, name, offset, type, size, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -217,6 +262,7 @@ public String toString() { sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -257,14 +303,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!StructureMember.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `StructureMember` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : StructureMember.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -298,6 +336,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, StructureMember value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -305,7 +365,28 @@ public void write(JsonWriter out, StructureMember value) throws IOException { public StructureMember 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 + StructureMember instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Symbols.java b/src/main/java/ai/reveng/model/Symbols.java index 52a1317..a6eeddd 100644 --- a/src/main/java/ai/reveng/model/Symbols.java +++ b/src/main/java/ai/reveng/model/Symbols.java @@ -112,6 +112,50 @@ public void setFunctionBoundaries(@javax.annotation.Nullable List 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 Symbols instance itself + */ + public Symbols putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } Symbols symbols = (Symbols) o; return Objects.equals(this.baseAddress, symbols.baseAddress) && - Objects.equals(this.functionBoundaries, symbols.functionBoundaries); + Objects.equals(this.functionBoundaries, symbols.functionBoundaries)&& + Objects.equals(this.additionalProperties, symbols.additionalProperties); } @Override public int hashCode() { - return Objects.hash(baseAddress, functionBoundaries); + return Objects.hash(baseAddress, functionBoundaries, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class Symbols {\n"); sb.append(" baseAddress: ").append(toIndentedString(baseAddress)).append("\n"); sb.append(" functionBoundaries: ").append(toIndentedString(functionBoundaries)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Symbols.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Symbols` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Symbols.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -224,6 +262,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Symbols value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -231,7 +291,28 @@ public void write(JsonWriter out, Symbols value) throws IOException { public Symbols 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 + Symbols instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TTPS.java b/src/main/java/ai/reveng/model/TTPS.java index 4d683a0..d9e84b5 100644 --- a/src/main/java/ai/reveng/model/TTPS.java +++ b/src/main/java/ai/reveng/model/TTPS.java @@ -102,6 +102,50 @@ public void setData(@javax.annotation.Nonnull TTPSData data) { this.data = data; } + /** + * 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 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 TTPS instance itself + */ + public TTPS putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } TTPS TTPS = (TTPS) o; return Objects.equals(this.success, TTPS.success) && - Objects.equals(this.data, TTPS.data); + Objects.equals(this.data, TTPS.data)&& + Objects.equals(this.additionalProperties, TTPS.additionalProperties); } @Override public int hashCode() { - return Objects.hash(success, data); + return Objects.hash(success, data, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class TTPS {\n"); sb.append(" success: ").append(toIndentedString(success)).append("\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TTPS.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TTPS` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TTPS.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TTPS value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, TTPS value) throws IOException { public TTPS 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 + TTPS instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TTPSAttack.java b/src/main/java/ai/reveng/model/TTPSAttack.java index 387d022..896ead6 100644 --- a/src/main/java/ai/reveng/model/TTPSAttack.java +++ b/src/main/java/ai/reveng/model/TTPSAttack.java @@ -101,6 +101,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * 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 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 TTPSAttack instance itself + */ + public TTPSAttack putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } TTPSAttack ttPSAttack = (TTPSAttack) o; return Objects.equals(this.id, ttPSAttack.id) && - Objects.equals(this.name, ttPSAttack.name); + Objects.equals(this.name, ttPSAttack.name)&& + Objects.equals(this.additionalProperties, ttPSAttack.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name); + return Objects.hash(id, name, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class TTPSAttack {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TTPSAttack.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TTPSAttack` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TTPSAttack.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TTPSAttack value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, TTPSAttack value) throws IOException { public TTPSAttack 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 + TTPSAttack instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TTPSData.java b/src/main/java/ai/reveng/model/TTPSData.java index 12b0a30..927863f 100644 --- a/src/main/java/ai/reveng/model/TTPSData.java +++ b/src/main/java/ai/reveng/model/TTPSData.java @@ -112,6 +112,50 @@ public void setTtps(@javax.annotation.Nonnull List ttps) { this.ttps = ttps; } + /** + * 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 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 TTPSData instance itself + */ + public TTPSData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -124,12 +168,13 @@ public boolean equals(Object o) { } TTPSData ttPSData = (TTPSData) o; return Objects.equals(this.score, ttPSData.score) && - Objects.equals(this.ttps, ttPSData.ttps); + Objects.equals(this.ttps, ttPSData.ttps)&& + Objects.equals(this.additionalProperties, ttPSData.additionalProperties); } @Override public int hashCode() { - return Objects.hash(score, ttps); + return Objects.hash(score, ttps, additionalProperties); } @Override @@ -138,6 +183,7 @@ public String toString() { sb.append("class TTPSData {\n"); sb.append(" score: ").append(toIndentedString(score)).append("\n"); sb.append(" ttps: ").append(toIndentedString(ttps)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -178,14 +224,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TTPSData.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TTPSData` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TTPSData.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -220,6 +258,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TTPSData value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -227,7 +287,28 @@ public void write(JsonWriter out, TTPSData value) throws IOException { public TTPSData 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 + TTPSData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TTPSElement.java b/src/main/java/ai/reveng/model/TTPSElement.java index 3ebe01a..b716a51 100644 --- a/src/main/java/ai/reveng/model/TTPSElement.java +++ b/src/main/java/ai/reveng/model/TTPSElement.java @@ -169,6 +169,50 @@ public void setScore(@javax.annotation.Nonnull Integer score) { this.score = score; } + /** + * 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 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 TTPSElement instance itself + */ + public TTPSElement putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -183,12 +227,13 @@ public boolean equals(Object o) { return Objects.equals(this.name, ttPSElement.name) && Objects.equals(this.attack, ttPSElement.attack) && Objects.equals(this.occurrences, ttPSElement.occurrences) && - Objects.equals(this.score, ttPSElement.score); + Objects.equals(this.score, ttPSElement.score)&& + Objects.equals(this.additionalProperties, ttPSElement.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, attack, occurrences, score); + return Objects.hash(name, attack, occurrences, score, additionalProperties); } @Override @@ -199,6 +244,7 @@ public String toString() { sb.append(" attack: ").append(toIndentedString(attack)).append("\n"); sb.append(" occurrences: ").append(toIndentedString(occurrences)).append("\n"); sb.append(" score: ").append(toIndentedString(score)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -239,14 +285,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TTPSElement.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TTPSElement` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TTPSElement.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -294,6 +332,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TTPSElement value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -301,7 +361,28 @@ public void write(JsonWriter out, TTPSElement value) throws IOException { public TTPSElement 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 + TTPSElement instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TTPSOccurance.java b/src/main/java/ai/reveng/model/TTPSOccurance.java index b314211..ee81e74 100644 --- a/src/main/java/ai/reveng/model/TTPSOccurance.java +++ b/src/main/java/ai/reveng/model/TTPSOccurance.java @@ -101,6 +101,50 @@ public void setPid(@javax.annotation.Nonnull Integer pid) { this.pid = pid; } + /** + * 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 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 TTPSOccurance instance itself + */ + public TTPSOccurance putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } TTPSOccurance ttPSOccurance = (TTPSOccurance) o; return Objects.equals(this.ppid, ttPSOccurance.ppid) && - Objects.equals(this.pid, ttPSOccurance.pid); + Objects.equals(this.pid, ttPSOccurance.pid)&& + Objects.equals(this.additionalProperties, ttPSOccurance.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ppid, pid); + return Objects.hash(ppid, pid, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class TTPSOccurance {\n"); sb.append(" ppid: ").append(toIndentedString(ppid)).append("\n"); sb.append(" pid: ").append(toIndentedString(pid)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TTPSOccurance.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TTPSOccurance` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TTPSOccurance.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -199,6 +237,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TTPSOccurance value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -206,7 +266,28 @@ public void write(JsonWriter out, TTPSOccurance value) throws IOException { public TTPSOccurance 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 + TTPSOccurance instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Tag.java b/src/main/java/ai/reveng/model/Tag.java index 8f5163f..5e36f78 100644 --- a/src/main/java/ai/reveng/model/Tag.java +++ b/src/main/java/ai/reveng/model/Tag.java @@ -77,6 +77,50 @@ public void setName(@javax.annotation.Nonnull String name) { this.name = name; } + /** + * 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 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 Tag instance itself + */ + public Tag putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -88,12 +132,13 @@ public boolean equals(Object o) { return false; } Tag tag = (Tag) o; - return Objects.equals(this.name, tag.name); + return Objects.equals(this.name, tag.name)&& + Objects.equals(this.additionalProperties, tag.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -101,6 +146,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -141,14 +187,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Tag.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Tag.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -176,6 +214,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Tag value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -183,7 +243,28 @@ public void write(JsonWriter out, Tag value) throws IOException { public Tag 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 + Tag instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TagConfidenceBody.java b/src/main/java/ai/reveng/model/TagConfidenceBody.java index d21056a..2cf9d00 100644 --- a/src/main/java/ai/reveng/model/TagConfidenceBody.java +++ b/src/main/java/ai/reveng/model/TagConfidenceBody.java @@ -88,6 +88,50 @@ public void setTags(@javax.annotation.Nonnull List tags) { this.tags = tags; } + /** + * 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 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 TagConfidenceBody instance itself + */ + public TagConfidenceBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } TagConfidenceBody tagConfidenceBody = (TagConfidenceBody) o; - return Objects.equals(this.tags, tagConfidenceBody.tags); + return Objects.equals(this.tags, tagConfidenceBody.tags)&& + Objects.equals(this.additionalProperties, tagConfidenceBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tags); + return Objects.hash(tags, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TagConfidenceBody {\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TagConfidenceBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TagConfidenceBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagConfidenceBody.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TagConfidenceBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, TagConfidenceBody value) throws IOException { public TagConfidenceBody 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 + TagConfidenceBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TagOriginBoxPlotConfidence.java b/src/main/java/ai/reveng/model/TagOriginBoxPlotConfidence.java index 54e5a85..24114d1 100644 --- a/src/main/java/ai/reveng/model/TagOriginBoxPlotConfidence.java +++ b/src/main/java/ai/reveng/model/TagOriginBoxPlotConfidence.java @@ -103,6 +103,50 @@ public void setBoxPlot(@javax.annotation.Nonnull BoxPlotConfidence boxPlot) { this.boxPlot = boxPlot; } + /** + * 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 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 TagOriginBoxPlotConfidence instance itself + */ + public TagOriginBoxPlotConfidence putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -115,12 +159,13 @@ public boolean equals(Object o) { } TagOriginBoxPlotConfidence tagOriginBoxPlotConfidence = (TagOriginBoxPlotConfidence) o; return Objects.equals(this.tag, tagOriginBoxPlotConfidence.tag) && - Objects.equals(this.boxPlot, tagOriginBoxPlotConfidence.boxPlot); + Objects.equals(this.boxPlot, tagOriginBoxPlotConfidence.boxPlot)&& + Objects.equals(this.additionalProperties, tagOriginBoxPlotConfidence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tag, boxPlot); + return Objects.hash(tag, boxPlot, additionalProperties); } @Override @@ -129,6 +174,7 @@ public String toString() { sb.append("class TagOriginBoxPlotConfidence {\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" boxPlot: ").append(toIndentedString(boxPlot)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -169,14 +215,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TagOriginBoxPlotConfidence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TagOriginBoxPlotConfidence` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagOriginBoxPlotConfidence.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TagOriginBoxPlotConfidence value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, TagOriginBoxPlotConfidence value) throws IOExc public TagOriginBoxPlotConfidence 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 + TagOriginBoxPlotConfidence instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TagResponse.java b/src/main/java/ai/reveng/model/TagResponse.java index 826ccc7..7429384 100644 --- a/src/main/java/ai/reveng/model/TagResponse.java +++ b/src/main/java/ai/reveng/model/TagResponse.java @@ -101,6 +101,50 @@ public void setOrigin(@javax.annotation.Nonnull String origin) { this.origin = origin; } + /** + * 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 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 TagResponse instance itself + */ + public TagResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } TagResponse tagResponse = (TagResponse) o; return Objects.equals(this.name, tagResponse.name) && - Objects.equals(this.origin, tagResponse.origin); + Objects.equals(this.origin, tagResponse.origin)&& + Objects.equals(this.additionalProperties, tagResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, origin); + return Objects.hash(name, origin, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class TagResponse {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TagResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TagResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TagResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, TagResponse value) throws IOException { public TagResponse 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 + TagResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TagSearchResponse.java b/src/main/java/ai/reveng/model/TagSearchResponse.java index 8f34ae2..a1b27ab 100644 --- a/src/main/java/ai/reveng/model/TagSearchResponse.java +++ b/src/main/java/ai/reveng/model/TagSearchResponse.java @@ -88,6 +88,50 @@ public void setResults(@javax.annotation.Nonnull List results) this.results = results; } + /** + * 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 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 TagSearchResponse instance itself + */ + public TagSearchResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } TagSearchResponse tagSearchResponse = (TagSearchResponse) o; - return Objects.equals(this.results, tagSearchResponse.results); + return Objects.equals(this.results, tagSearchResponse.results)&& + Objects.equals(this.additionalProperties, tagSearchResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(results); + return Objects.hash(results, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TagSearchResponse {\n"); sb.append(" results: ").append(toIndentedString(results)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TagSearchResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TagSearchResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagSearchResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TagSearchResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, TagSearchResponse value) throws IOException { public TagSearchResponse 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 + TagSearchResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TagSearchResult.java b/src/main/java/ai/reveng/model/TagSearchResult.java index d54b37a..aeaec8e 100644 --- a/src/main/java/ai/reveng/model/TagSearchResult.java +++ b/src/main/java/ai/reveng/model/TagSearchResult.java @@ -101,6 +101,50 @@ public void setTag(@javax.annotation.Nonnull String tag) { this.tag = tag; } + /** + * 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 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 TagSearchResult instance itself + */ + public TagSearchResult putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -113,12 +157,13 @@ public boolean equals(Object o) { } TagSearchResult tagSearchResult = (TagSearchResult) o; return Objects.equals(this.tagId, tagSearchResult.tagId) && - Objects.equals(this.tag, tagSearchResult.tag); + Objects.equals(this.tag, tagSearchResult.tag)&& + Objects.equals(this.additionalProperties, tagSearchResult.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tagId, tag); + return Objects.hash(tagId, tag, additionalProperties); } @Override @@ -127,6 +172,7 @@ public String toString() { sb.append("class TagSearchResult {\n"); sb.append(" tagId: ").append(toIndentedString(tagId)).append("\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TagSearchResult.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TagSearchResult` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TagSearchResult.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TagSearchResult value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, TagSearchResult value) throws IOException { public TagSearchResult 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 + TagSearchResult instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Tags.java b/src/main/java/ai/reveng/model/Tags.java index 6e40622..dcd21dc 100644 --- a/src/main/java/ai/reveng/model/Tags.java +++ b/src/main/java/ai/reveng/model/Tags.java @@ -102,6 +102,50 @@ public void setOrigin(@javax.annotation.Nonnull Origin origin) { this.origin = origin; } + /** + * 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 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 Tags instance itself + */ + public Tags putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } Tags tags = (Tags) o; return Objects.equals(this.tag, tags.tag) && - Objects.equals(this.origin, tags.origin); + Objects.equals(this.origin, tags.origin)&& + Objects.equals(this.additionalProperties, tags.additionalProperties); } @Override public int hashCode() { - return Objects.hash(tag, origin); + return Objects.hash(tag, origin, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class Tags {\n"); sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); sb.append(" origin: ").append(toIndentedString(origin)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Tags.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Tags` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Tags.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Tags value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, Tags value) throws IOException { public Tags 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 + Tags instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TaskResponse.java b/src/main/java/ai/reveng/model/TaskResponse.java index ecfadaf..8171025 100644 --- a/src/main/java/ai/reveng/model/TaskResponse.java +++ b/src/main/java/ai/reveng/model/TaskResponse.java @@ -103,6 +103,50 @@ public void setErrorMessage(@javax.annotation.Nullable String errorMessage) { this.errorMessage = errorMessage; } + /** + * 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 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 TaskResponse instance itself + */ + public TaskResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -115,7 +159,8 @@ public boolean equals(Object o) { } TaskResponse taskResponse = (TaskResponse) o; return Objects.equals(this.status, taskResponse.status) && - Objects.equals(this.errorMessage, taskResponse.errorMessage); + Objects.equals(this.errorMessage, taskResponse.errorMessage)&& + Objects.equals(this.additionalProperties, taskResponse.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -124,7 +169,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(status, errorMessage); + return Objects.hash(status, errorMessage, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -140,6 +185,7 @@ public String toString() { sb.append("class TaskResponse {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" errorMessage: ").append(toIndentedString(errorMessage)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -179,14 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in TaskResponse is not found in the empty JSON string", TaskResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TaskResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TaskResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `status` if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { @@ -212,6 +250,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TaskResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -219,7 +279,28 @@ public void write(JsonWriter out, TaskResponse value) throws IOException { public TaskResponse 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 + TaskResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/ThreatScoreFunctionBody.java b/src/main/java/ai/reveng/model/ThreatScoreFunctionBody.java index 5bd6126..16102db 100644 --- a/src/main/java/ai/reveng/model/ThreatScoreFunctionBody.java +++ b/src/main/java/ai/reveng/model/ThreatScoreFunctionBody.java @@ -87,6 +87,50 @@ public void setFunctionIds(@javax.annotation.Nullable List functionIds) this.functionIds = functionIds; } + /** + * 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 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 ThreatScoreFunctionBody instance itself + */ + public ThreatScoreFunctionBody putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -98,12 +142,13 @@ public boolean equals(Object o) { return false; } ThreatScoreFunctionBody threatScoreFunctionBody = (ThreatScoreFunctionBody) o; - return Objects.equals(this.functionIds, threatScoreFunctionBody.functionIds); + return Objects.equals(this.functionIds, threatScoreFunctionBody.functionIds)&& + Objects.equals(this.additionalProperties, threatScoreFunctionBody.additionalProperties); } @Override public int hashCode() { - return Objects.hash(functionIds); + return Objects.hash(functionIds, additionalProperties); } @Override @@ -111,6 +156,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ThreatScoreFunctionBody {\n"); sb.append(" functionIds: ").append(toIndentedString(functionIds)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -150,14 +196,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ThreatScoreFunctionBody is not found in the empty JSON string", ThreatScoreFunctionBody.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ThreatScoreFunctionBody.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `ThreatScoreFunctionBody` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("function_ids") != null && !jsonObj.get("function_ids").isJsonNull() && !jsonObj.get("function_ids").isJsonArray()) { @@ -180,6 +218,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ThreatScoreFunctionBody value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -187,7 +247,28 @@ public void write(JsonWriter out, ThreatScoreFunctionBody value) throws IOExcept public ThreatScoreFunctionBody 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 + ThreatScoreFunctionBody instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TimestampModel.java b/src/main/java/ai/reveng/model/TimestampModel.java index 3b32a04..5ce9fbe 100644 --- a/src/main/java/ai/reveng/model/TimestampModel.java +++ b/src/main/java/ai/reveng/model/TimestampModel.java @@ -125,6 +125,50 @@ public void setDebugTimestamp(@javax.annotation.Nonnull Integer debugTimestamp) this.debugTimestamp = debugTimestamp; } + /** + * 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 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 TimestampModel instance itself + */ + public TimestampModel putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -138,12 +182,13 @@ public boolean equals(Object o) { TimestampModel timestampModel = (TimestampModel) o; return Objects.equals(this.peTimestamp, timestampModel.peTimestamp) && Objects.equals(this.exportTimestamp, timestampModel.exportTimestamp) && - Objects.equals(this.debugTimestamp, timestampModel.debugTimestamp); + Objects.equals(this.debugTimestamp, timestampModel.debugTimestamp)&& + Objects.equals(this.additionalProperties, timestampModel.additionalProperties); } @Override public int hashCode() { - return Objects.hash(peTimestamp, exportTimestamp, debugTimestamp); + return Objects.hash(peTimestamp, exportTimestamp, debugTimestamp, additionalProperties); } @Override @@ -153,6 +198,7 @@ public String toString() { sb.append(" peTimestamp: ").append(toIndentedString(peTimestamp)).append("\n"); sb.append(" exportTimestamp: ").append(toIndentedString(exportTimestamp)).append("\n"); sb.append(" debugTimestamp: ").append(toIndentedString(debugTimestamp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -193,14 +239,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TimestampModel.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TimestampModel` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TimestampModel.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -225,6 +263,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TimestampModel value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -232,7 +292,28 @@ public void write(JsonWriter out, TimestampModel value) throws IOException { public TimestampModel 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 + TimestampModel instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/TypeDefinition.java b/src/main/java/ai/reveng/model/TypeDefinition.java index 37ff114..37b39ca 100644 --- a/src/main/java/ai/reveng/model/TypeDefinition.java +++ b/src/main/java/ai/reveng/model/TypeDefinition.java @@ -150,6 +150,50 @@ public void setArtifactType(@javax.annotation.Nullable String artifactType) { this.artifactType = artifactType; } + /** + * 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 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 TypeDefinition instance itself + */ + public TypeDefinition putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -164,7 +208,8 @@ public boolean equals(Object o) { return Objects.equals(this.lastChange, typeDefinition.lastChange) && Objects.equals(this.name, typeDefinition.name) && Objects.equals(this.type, typeDefinition.type) && - Objects.equals(this.artifactType, typeDefinition.artifactType); + Objects.equals(this.artifactType, typeDefinition.artifactType)&& + Objects.equals(this.additionalProperties, typeDefinition.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -173,7 +218,7 @@ private static boolean equalsNullable(JsonNullable a, JsonNullable b) @Override public int hashCode() { - return Objects.hash(lastChange, name, type, artifactType); + return Objects.hash(lastChange, name, type, artifactType, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -191,6 +236,7 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" artifactType: ").append(toIndentedString(artifactType)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -231,14 +277,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TypeDefinition.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `TypeDefinition` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : TypeDefinition.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -275,6 +313,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TypeDefinition value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -282,7 +342,28 @@ public void write(JsonWriter out, TypeDefinition value) throws IOException { public TypeDefinition 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 + TypeDefinition instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java b/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java index 7a7fffd..8650abc 100644 --- a/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java +++ b/src/main/java/ai/reveng/model/UpdateFunctionDataTypes.java @@ -102,6 +102,50 @@ public void setDataTypes(@javax.annotation.Nonnull FunctionInfoInput dataTypes) this.dataTypes = dataTypes; } + /** + * 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 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 UpdateFunctionDataTypes instance itself + */ + public UpdateFunctionDataTypes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } UpdateFunctionDataTypes updateFunctionDataTypes = (UpdateFunctionDataTypes) o; return Objects.equals(this.dataTypesVersion, updateFunctionDataTypes.dataTypesVersion) && - Objects.equals(this.dataTypes, updateFunctionDataTypes.dataTypes); + Objects.equals(this.dataTypes, updateFunctionDataTypes.dataTypes)&& + Objects.equals(this.additionalProperties, updateFunctionDataTypes.additionalProperties); } @Override public int hashCode() { - return Objects.hash(dataTypesVersion, dataTypes); + return Objects.hash(dataTypesVersion, dataTypes, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class UpdateFunctionDataTypes {\n"); sb.append(" dataTypesVersion: ").append(toIndentedString(dataTypesVersion)).append("\n"); sb.append(" dataTypes: ").append(toIndentedString(dataTypes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateFunctionDataTypes.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpdateFunctionDataTypes` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateFunctionDataTypes.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -202,6 +240,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateFunctionDataTypes value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -209,7 +269,28 @@ public void write(JsonWriter out, UpdateFunctionDataTypes value) throws IOExcept public UpdateFunctionDataTypes 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 + UpdateFunctionDataTypes instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/UploadResponse.java b/src/main/java/ai/reveng/model/UploadResponse.java index 39e10f1..e03ad57 100644 --- a/src/main/java/ai/reveng/model/UploadResponse.java +++ b/src/main/java/ai/reveng/model/UploadResponse.java @@ -126,6 +126,50 @@ public void setFilename(@javax.annotation.Nonnull String filename) { this.filename = filename; } + /** + * 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 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 UploadResponse instance itself + */ + public UploadResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -139,12 +183,13 @@ public boolean equals(Object o) { UploadResponse uploadResponse = (UploadResponse) o; return Objects.equals(this.sha256Hash, uploadResponse.sha256Hash) && Objects.equals(this.fileType, uploadResponse.fileType) && - Objects.equals(this.filename, uploadResponse.filename); + Objects.equals(this.filename, uploadResponse.filename)&& + Objects.equals(this.additionalProperties, uploadResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(sha256Hash, fileType, filename); + return Objects.hash(sha256Hash, fileType, filename, additionalProperties); } @Override @@ -154,6 +199,7 @@ public String toString() { sb.append(" sha256Hash: ").append(toIndentedString(sha256Hash)).append("\n"); sb.append(" fileType: ").append(toIndentedString(fileType)).append("\n"); sb.append(" filename: ").append(toIndentedString(filename)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -194,14 +240,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UploadResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UploadResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UploadResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -234,6 +272,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UploadResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -241,7 +301,28 @@ public void write(JsonWriter out, UploadResponse value) throws IOException { public UploadResponse 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 + UploadResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java b/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java index 3e69cf5..158c9e2 100644 --- a/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java +++ b/src/main/java/ai/reveng/model/UpsertAiDecomplationRatingRequest.java @@ -102,6 +102,50 @@ public void setReason(@javax.annotation.Nullable String reason) { this.reason = reason; } + /** + * 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 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 UpsertAiDecomplationRatingRequest instance itself + */ + public UpsertAiDecomplationRatingRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -114,12 +158,13 @@ public boolean equals(Object o) { } UpsertAiDecomplationRatingRequest upsertAiDecomplationRatingRequest = (UpsertAiDecomplationRatingRequest) o; return Objects.equals(this.rating, upsertAiDecomplationRatingRequest.rating) && - Objects.equals(this.reason, upsertAiDecomplationRatingRequest.reason); + Objects.equals(this.reason, upsertAiDecomplationRatingRequest.reason)&& + Objects.equals(this.additionalProperties, upsertAiDecomplationRatingRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(rating, reason); + return Objects.hash(rating, reason, additionalProperties); } @Override @@ -128,6 +173,7 @@ public String toString() { sb.append("class UpsertAiDecomplationRatingRequest {\n"); sb.append(" rating: ").append(toIndentedString(rating)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -168,14 +214,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpsertAiDecomplationRatingRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UpsertAiDecomplationRatingRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpsertAiDecomplationRatingRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -205,6 +243,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpsertAiDecomplationRatingRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -212,7 +272,28 @@ public void write(JsonWriter out, UpsertAiDecomplationRatingRequest value) throw public UpsertAiDecomplationRatingRequest 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 + UpsertAiDecomplationRatingRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/UserActivityResponse.java b/src/main/java/ai/reveng/model/UserActivityResponse.java index 17614e0..2cf40c7 100644 --- a/src/main/java/ai/reveng/model/UserActivityResponse.java +++ b/src/main/java/ai/reveng/model/UserActivityResponse.java @@ -198,6 +198,50 @@ public void setUsername(@javax.annotation.Nonnull String username) { this.username = username; } + /** + * 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 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 UserActivityResponse instance itself + */ + public UserActivityResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -214,12 +258,13 @@ public boolean equals(Object o) { Objects.equals(this.creation, userActivityResponse.creation) && Objects.equals(this.message, userActivityResponse.message) && Objects.equals(this.sources, userActivityResponse.sources) && - Objects.equals(this.username, userActivityResponse.username); + Objects.equals(this.username, userActivityResponse.username)&& + Objects.equals(this.additionalProperties, userActivityResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(actions, activityScope, creation, message, sources, username); + return Objects.hash(actions, activityScope, creation, message, sources, username, additionalProperties); } @Override @@ -232,6 +277,7 @@ public String toString() { sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" sources: ").append(toIndentedString(sources)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -272,14 +318,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UserActivityResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `UserActivityResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UserActivityResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -319,6 +357,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UserActivityResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -326,7 +386,28 @@ public void write(JsonWriter out, UserActivityResponse value) throws IOException public UserActivityResponse 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 + UserActivityResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Vulnerabilities.java b/src/main/java/ai/reveng/model/Vulnerabilities.java index f9f0a21..0b356ae 100644 --- a/src/main/java/ai/reveng/model/Vulnerabilities.java +++ b/src/main/java/ai/reveng/model/Vulnerabilities.java @@ -88,6 +88,50 @@ public void setVulnerabilities(@javax.annotation.Nonnull List vul this.vulnerabilities = vulnerabilities; } + /** + * 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 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 Vulnerabilities instance itself + */ + public Vulnerabilities putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -99,12 +143,13 @@ public boolean equals(Object o) { return false; } Vulnerabilities vulnerabilities = (Vulnerabilities) o; - return Objects.equals(this.vulnerabilities, vulnerabilities.vulnerabilities); + return Objects.equals(this.vulnerabilities, vulnerabilities.vulnerabilities)&& + Objects.equals(this.additionalProperties, vulnerabilities.additionalProperties); } @Override public int hashCode() { - return Objects.hash(vulnerabilities); + return Objects.hash(vulnerabilities, additionalProperties); } @Override @@ -112,6 +157,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Vulnerabilities {\n"); sb.append(" vulnerabilities: ").append(toIndentedString(vulnerabilities)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -152,14 +198,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Vulnerabilities.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Vulnerabilities` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Vulnerabilities.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -194,6 +232,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Vulnerabilities value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -201,7 +261,28 @@ public void write(JsonWriter out, Vulnerabilities value) throws IOException { public Vulnerabilities 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 + Vulnerabilities instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/main/java/ai/reveng/model/Vulnerability.java b/src/main/java/ai/reveng/model/Vulnerability.java index 5403e25..75e3923 100644 --- a/src/main/java/ai/reveng/model/Vulnerability.java +++ b/src/main/java/ai/reveng/model/Vulnerability.java @@ -376,6 +376,50 @@ public void setIsUnknown(@javax.annotation.Nullable Boolean isUnknown) { this.isUnknown = isUnknown; } + /** + * 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 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 Vulnerability instance itself + */ + public Vulnerability putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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 @@ -397,12 +441,13 @@ public boolean equals(Object o) { Objects.equals(this.cvssVector, vulnerability.cvssVector) && Objects.equals(this.remarks, vulnerability.remarks) && Objects.equals(this.score, vulnerability.score) && - Objects.equals(this.isUnknown, vulnerability.isUnknown); + Objects.equals(this.isUnknown, vulnerability.isUnknown)&& + Objects.equals(this.additionalProperties, vulnerability.additionalProperties); } @Override public int hashCode() { - return Objects.hash(vendor, product, version, cveNumber, severity, source, cvssVersion, cvssVector, remarks, score, isUnknown); + return Objects.hash(vendor, product, version, cveNumber, severity, source, cvssVersion, cvssVector, remarks, score, isUnknown, additionalProperties); } @Override @@ -420,6 +465,7 @@ public String toString() { sb.append(" remarks: ").append(toIndentedString(remarks)).append("\n"); sb.append(" score: ").append(toIndentedString(score)).append("\n"); sb.append(" isUnknown: ").append(toIndentedString(isUnknown)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -460,14 +506,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Vulnerability.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` in the JSON string is not defined in the `Vulnerability` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Vulnerability.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -521,6 +559,28 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Vulnerability value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } elementAdapter.write(out, obj); } @@ -528,7 +588,28 @@ public void write(JsonWriter out, Vulnerability value) throws IOException { public Vulnerability 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 + Vulnerability instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(Locale.ROOT, "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(); diff --git a/src/test/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunctionTest.java b/src/test/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunctionTest.java index 57550e5..4221799 100644 --- a/src/test/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunctionTest.java +++ b/src/test/java/ai/reveng/model/AppApiRestV2FunctionsResponsesFunctionTest.java @@ -19,6 +19,7 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test;