Skip to content

Commit 9bda43e

Browse files
committed
add null type only test o java okhttpgson client
1 parent 71a84ff commit 9bda43e

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

‎modules/openapi-generator/src/test/resources/3_1/java/petstore.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,3 +1125,6 @@ components:
11251125
- "object"
11261126
- "null"
11271127
$ref: '#/components/schemas/Pet'
1128+
second_property:
1129+
description: just null type
1130+
type: null

‎samples/client/petstore/java/okhttp-gson-3.1/api/openapi.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ components:
12041204
properties:
12051205
first_property:
12061206
$ref: "#/components/schemas/Pet"
1207+
second_property:
1208+
description: just null type
12071209
updatePetWithForm_request:
12081210
properties:
12091211
name:

‎samples/client/petstore/java/okhttp-gson-3.1/docs/PetWithTypesObjectNullAndRef.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| Name | Type | Description | Notes |
99
|------------ | ------------- | ------------- | -------------|
1010
|**firstProperty** | [**Pet**](Pet.md) | | [optional] |
11+
|**secondProperty** | **Object** | just null type | [optional] |
1112

1213

1314

‎samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/PetWithTypesObjectNullAndRef.java‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.IOException;
2323
import java.util.Arrays;
2424
import org.openapitools.client.model.Pet;
25+
import org.openapitools.jackson.nullable.JsonNullable;
2526

2627
import com.google.gson.Gson;
2728
import com.google.gson.GsonBuilder;
@@ -57,6 +58,11 @@ public class PetWithTypesObjectNullAndRef {
5758
@javax.annotation.Nullable
5859
private Pet firstProperty;
5960

61+
public static final String SERIALIZED_NAME_SECOND_PROPERTY = "second_property";
62+
@SerializedName(SERIALIZED_NAME_SECOND_PROPERTY)
63+
@javax.annotation.Nullable
64+
private Object secondProperty = null;
65+
6066
public PetWithTypesObjectNullAndRef() {
6167
}
6268

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

87+
88+
public PetWithTypesObjectNullAndRef secondProperty(@javax.annotation.Nullable Object secondProperty) {
89+
this.secondProperty = secondProperty;
90+
return this;
91+
}
92+
93+
/**
94+
* just null type
95+
* @return secondProperty
96+
*/
97+
@javax.annotation.Nullable
98+
public Object getSecondProperty() {
99+
return secondProperty;
100+
}
101+
102+
public void setSecondProperty(@javax.annotation.Nullable Object secondProperty) {
103+
this.secondProperty = secondProperty;
104+
}
105+
81106
/**
82107
* A container for additional, undeclared properties.
83108
* This is a holder for any undeclared properties as specified with
@@ -133,20 +158,33 @@ public boolean equals(Object o) {
133158
return false;
134159
}
135160
PetWithTypesObjectNullAndRef petWithTypesObjectNullAndRef = (PetWithTypesObjectNullAndRef) o;
136-
return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty)&&
161+
return Objects.equals(this.firstProperty, petWithTypesObjectNullAndRef.firstProperty) &&
162+
Objects.equals(this.secondProperty, petWithTypesObjectNullAndRef.secondProperty)&&
137163
Objects.equals(this.additionalProperties, petWithTypesObjectNullAndRef.additionalProperties);
138164
}
139165

166+
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
167+
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
168+
}
169+
140170
@Override
141171
public int hashCode() {
142-
return Objects.hash(firstProperty, additionalProperties);
172+
return Objects.hash(firstProperty, secondProperty, additionalProperties);
173+
}
174+
175+
private static <T> int hashCodeNullable(JsonNullable<T> a) {
176+
if (a == null) {
177+
return 1;
178+
}
179+
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
143180
}
144181

145182
@Override
146183
public String toString() {
147184
StringBuilder sb = new StringBuilder();
148185
sb.append("class PetWithTypesObjectNullAndRef {\n");
149186
sb.append(" firstProperty: ").append(toIndentedString(firstProperty)).append("\n");
187+
sb.append(" secondProperty: ").append(toIndentedString(secondProperty)).append("\n");
150188
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
151189
sb.append("}");
152190
return sb.toString();
@@ -166,7 +204,7 @@ private String toIndentedString(Object o) {
166204

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

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

0 commit comments

Comments
 (0)