Contrast Graph API - #159
Open
johnament wants to merge 16 commits into
Open
Conversation
…eration - Add openapi-generator-maven-plugin 7.9.0 to sdk/pom.xml generating 16 model classes into com.contrastsecurity.sdk.graph from contrast-graph.yaml - Add jsr305 and javax.annotation-api as provided deps for generated @nullable and @generated annotations - Upgrade Lombok to 1.18.30 for JDK 21 compatibility - Replace <release>8</release> with <source>/<target> so provided jars are visible to the compiler - Add minimal JSON.java stub providing JSON.getGson() for generated model classes Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…s, GsonFactory delegation Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Make ContrastGraphApiImpl public (class and constructor) so it can be instantiated from the ContrastSDK.graphApi() factory method. This allows users to access the Graph API through the main SDK entry point. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Move implementation instantiation to a package-private factory class to enforce encapsulation. Implementation classes should not be directly instantiated outside their package. Changes: - Make ContrastGraphApiImpl class package-private (remove public) - Make ContrastGraphApiImpl constructor package-private (remove public) - Create ContrastGraphApiFactory as the public factory for instantiation - Update ContrastSDK.graphApi() to use the factory method Tests: ContrastGraphApiFactoryTest passes (1 test, 0 failures)
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
tylernhoward
approved these changes
Jun 10, 2026
| new ContrastSDK.Builder("user", "serviceKey", "apiKey") | ||
| .withApiUrl(server.getUrl() + "/Contrast/api") | ||
| .build(); | ||
| return new ContrastGraphApiImpl(sdk, new Gson()); |
Contributor
There was a problem hiding this comment.
Should we use JSON.getJson() here instead?
Contributor
There was a problem hiding this comment.
nit: possibility to use a helper method to reuse code in this class.
Contributor
There was a problem hiding this comment.
I think I'm ok with this as is, I think any refactor to not duplicate code affects readability
Author
There was a problem hiding this comment.
I did end up cleaning up the calls as it was ignoring proxy settings the way written.
BrianPhillips2020
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ContrastGraphApiinterface andContrastGraphApiImplfor the 5 v2 Contrast Graph endpoints served byadr-explorer-aggregator(graph search, incident graph, facets, application libraries, library details)contrast-graph.yamlOpenAPI spec viaopenapi-generator-maven-plugin(models only,okhttp-gsonlibrary,dateLibrary=string)ContrastSDK.graphApi()factory method parallel to the existingscan()factoryJSON.javautility (delegates toGsonFactory) required by generated model convenience methodsNotable build changes
openapi-generator-maven-plugin 7.9.0added (models-only, no API stubs)1.18.18 → 1.18.30for JDK 21 annotation processor compatibilityjsr305andjavax.annotation-apiadded as optional compile-scope deps (needed by generated@Nullable/@Generatedannotations, not needed at runtime)Test plan
ContrastGraphApiFactoryTest— verifiesContrastSDK.graphApi()returns aContrastGraphApiImplinstanceContrastGraphApiImplPactTest— 5 Pact consumer contract tests, one per API method, all asserting specific field valuesCodeArtifactsImplTest/ProjectsImplTest/ScansImplTestfailures are a Mockito 3.11.2 + JDK 21 incompatibility that predates this PR — not introduced here🤖 Generated with Claude Code