Add null type only test to Java okhttp-gson client - #24701
Merged
Conversation
wing328
marked this pull request as ready for review
August 14, 2026 05:34
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java">
<violation number="1" location="samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java:166">
P3: The `equalsNullable` and `hashCodeNullable` helper methods are never called, and the `JsonNullable` import exists only to support them. `equals`/`hashCode` use plain `Objects.equals`/`Objects.hash` on the `Object` field, so both helpers are dead code. Remove both methods and the `JsonNullable` import.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| Objects.equals(this.additionalProperties, petWithTypesObjectNullAndRef.additionalProperties); | ||
| } | ||
|
|
||
| private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) { |
Contributor
There was a problem hiding this comment.
P3: The equalsNullable and hashCodeNullable helper methods are never called, and the JsonNullable import exists only to support them. equals/hashCode use plain Objects.equals/Objects.hash on the Object field, so both helpers are dead code. Remove both methods and the JsonNullable import.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java, line 166:
<comment>The `equalsNullable` and `hashCodeNullable` helper methods are never called, and the `JsonNullable` import exists only to support them. `equals`/`hashCode` use plain `Objects.equals`/`Objects.hash` on the `Object` field, so both helpers are dead code. Remove both methods and the `JsonNullable` import.</comment>
<file context>
@@ -133,20 +158,33 @@ public boolean equals(Object o) {
Objects.equals(this.additionalProperties, petWithTypesObjectNullAndRef.additionalProperties);
}
+ private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
+ return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ }
</file context>
This was referenced Aug 14, 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.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Adds a null-only schema property to the Java
okhttp-gson3.1 petstore sample to validate OpenAPI 3.1type: nullhandling. This ensures the generator emits a nullableObjectfield and includes it in equality, hashing, and field validation.second_propertywithtype: nulland description "just null type".PetWithTypesObjectNullAndRef: newsecondProperty(Object,@javax.annotation.Nullable), included inequals,hashCode,toString, andopenapiFields.PetWithTypesObjectNullAndRefnow listssecondPropertyas optionalObjectwith the description.JsonNullablehelpers; they are not used and do not change behavior.Review Notes
okhttp-gsonto confirmtype: nullmaps to a nullableObjectand passes validation.Written for commit 9bda43e. Summary will update on new commits.