Skip to content

Commit c0d4158

Browse files
authored
fix: config property openApiNullable=false for Kafka instance API (#234)
1 parent 3daf12b commit c0d4158

3 files changed

Lines changed: 10 additions & 36 deletions

File tree

packages/kafka-instance-sdk/src/main/java/com/openshift/cloud/api/kas/auth/invoker/JSON.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.fasterxml.jackson.annotation.*;
44
import com.fasterxml.jackson.databind.*;
5-
import org.openapitools.jackson.nullable.JsonNullableModule;
65
import com.fasterxml.jackson.datatype.jsr310.*;
76

87
import java.text.DateFormat;
@@ -22,8 +21,6 @@ public JSON() {
2221
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
2322
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
2423
mapper.setDateFormat(new RFC3339DateFormat());
25-
JsonNullableModule jnm = new JsonNullableModule();
26-
mapper.registerModule(jnm);
2724
mapper.registerModule(new JavaTimeModule());
2825
}
2926

packages/kafka-instance-sdk/src/main/java/com/openshift/cloud/api/kas/auth/models/Partition.java

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
import io.swagger.annotations.ApiModelProperty;
2626
import java.util.ArrayList;
2727
import java.util.List;
28-
import org.openapitools.jackson.nullable.JsonNullable;
29-
import com.fasterxml.jackson.annotation.JsonIgnore;
30-
import org.openapitools.jackson.nullable.JsonNullable;
31-
import java.util.NoSuchElementException;
3228
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3329
import com.fasterxml.jackson.annotation.JsonTypeName;
3430

@@ -55,7 +51,7 @@ public class Partition {
5551
private List<Node> isr = null;
5652

5753
public static final String JSON_PROPERTY_LEADER = "leader";
58-
private JsonNullable<Node> leader = JsonNullable.<Node>undefined();
54+
private Node leader;
5955

6056
public Partition() {
6157
}
@@ -158,8 +154,8 @@ public void setIsr(List<Node> isr) {
158154

159155

160156
public Partition leader(Node leader) {
161-
this.leader = JsonNullable.<Node>of(leader);
162157

158+
this.leader = leader;
163159
return this;
164160
}
165161

@@ -169,26 +165,18 @@ public Partition leader(Node leader) {
169165
**/
170166
@javax.annotation.Nullable
171167
@ApiModelProperty(value = "")
172-
@JsonIgnore
173-
174-
public Node getLeader() {
175-
return leader.orElse(null);
176-
}
177-
178168
@JsonProperty(JSON_PROPERTY_LEADER)
179169
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
180170

181-
public JsonNullable<Node> getLeader_JsonNullable() {
171+
public Node getLeader() {
182172
return leader;
183173
}
184-
185-
@JsonProperty(JSON_PROPERTY_LEADER)
186-
public void setLeader_JsonNullable(JsonNullable<Node> leader) {
187-
this.leader = leader;
188-
}
189174

175+
176+
@JsonProperty(JSON_PROPERTY_LEADER)
177+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
190178
public void setLeader(Node leader) {
191-
this.leader = JsonNullable.<Node>of(leader);
179+
this.leader = leader;
192180
}
193181

194182

@@ -204,23 +192,12 @@ public boolean equals(Object o) {
204192
return Objects.equals(this.partition, partition.partition) &&
205193
Objects.equals(this.replicas, partition.replicas) &&
206194
Objects.equals(this.isr, partition.isr) &&
207-
equalsNullable(this.leader, partition.leader);
208-
}
209-
210-
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
211-
return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
195+
Objects.equals(this.leader, partition.leader);
212196
}
213197

214198
@Override
215199
public int hashCode() {
216-
return Objects.hash(partition, replicas, isr, hashCodeNullable(leader));
217-
}
218-
219-
private static <T> int hashCodeNullable(JsonNullable<T> a) {
220-
if (a == null) {
221-
return 1;
222-
}
223-
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
200+
return Objects.hash(partition, replicas, isr, leader);
224201
}
225202

226203
@Override

scripts/generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ echo "Generating based on ${OPENAPI_FILENAME}"
5454
npx @openapitools/openapi-generator-cli generate -g java --library resteasy -t "$TEMPLATES_DIR" -i \
5555
"$OPENAPI_FILENAME.processed" -o "$OUTPUT_PATH" \
5656
--package-name="${PACKAGE_NAME}" \
57-
--additional-properties="apiTests=false,modelTests=false,hideGenerationTimestamp=true,groupId=${GROUP_ID},artifactId=${ARTIFACT_ID},modelPackage=${PACKAGE_NAME}.models,invokerPackage=${PACKAGE_NAME}.invoker,apiPackage=${PACKAGE_NAME},dateLibrary=java8,licenseName=Apache-2.0,licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.txt" \
57+
--additional-properties="openApiNullable=false,apiTests=false,modelTests=false,hideGenerationTimestamp=true,groupId=${GROUP_ID},artifactId=${ARTIFACT_ID},modelPackage=${PACKAGE_NAME}.models,invokerPackage=${PACKAGE_NAME}.invoker,apiPackage=${PACKAGE_NAME},dateLibrary=java8,licenseName=Apache-2.0,licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.txt" \
5858
--ignore-file-override=.openapi-generator-ignore
5959

6060
GROUP_ID="com.redhat.cloud"

0 commit comments

Comments
 (0)