Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1125,3 +1125,6 @@ components:
- "object"
- "null"
$ref: '#/components/schemas/Pet'
second_property:
description: just null type
type: null
2 changes: 2 additions & 0 deletions samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,8 @@ components:
properties:
first_property:
$ref: "#/components/schemas/Pet"
second_property:
description: just null type
updatePetWithForm_request:
properties:
name:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**firstProperty** | [**Pet**](Pet.md) | | [optional] |
|**secondProperty** | **Object** | just null type | [optional] |



Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.util.Arrays;
import org.openapitools.client.model.Pet;
import org.openapitools.jackson.nullable.JsonNullable;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -57,6 +58,11 @@ public class PetWithTypesObjectNullAndRef {
@javax.annotation.Nullable
private Pet firstProperty;

public static final String SERIALIZED_NAME_SECOND_PROPERTY = "second_property";
@SerializedName(SERIALIZED_NAME_SECOND_PROPERTY)
@javax.annotation.Nullable
private Object secondProperty = null;

public PetWithTypesObjectNullAndRef() {
}

Expand All @@ -78,6 +84,25 @@ public void setFirstProperty(@javax.annotation.Nullable Pet firstProperty) {
this.firstProperty = firstProperty;
}


public PetWithTypesObjectNullAndRef secondProperty(@javax.annotation.Nullable Object secondProperty) {
this.secondProperty = secondProperty;
return this;
}

/**
* just null type
* @return secondProperty
*/
@javax.annotation.Nullable
public Object getSecondProperty() {
return secondProperty;
}

public void setSecondProperty(@javax.annotation.Nullable Object secondProperty) {
this.secondProperty = secondProperty;
}

/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
Expand Down Expand Up @@ -133,20 +158,33 @@ public boolean equals(Object o) {
return false;
}
PetWithTypesObjectNullAndRef petWithTypesObjectNullAndRef = (PetWithTypesObjectNullAndRef) o;
return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty)&&
return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty) &&
Objects.equals(this.secondProperty, petWithTypesObjectNullAndRef.secondProperty)&&
Objects.equals(this.additionalProperties, petWithTypesObjectNullAndRef.additionalProperties);
}

private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}

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

private static <T> int hashCodeNullable(JsonNullable<T> a) {
if (a == null) {
return 1;
}
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PetWithTypesObjectNullAndRef {\n");
sb.append(" firstProperty: ").append(toIndentedString(firstProperty)).append("\n");
sb.append(" secondProperty: ").append(toIndentedString(secondProperty)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}");
return sb.toString();
Expand All @@ -166,7 +204,7 @@ private String toIndentedString(Object o) {

static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet<String>(Arrays.asList("first_property"));
openapiFields = new HashSet<String>(Arrays.asList("first_property", "second_property"));

// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>(0);
Expand Down
Loading