Skip to content

Commit 0873bf9

Browse files
Merge pull request #191 from regulaforensics/fix/SP-24472
SP-24472 - fix example, update models
2 parents 424ef72 + 2607d5a commit 0873bf9

File tree

2 files changed

+31
-30
lines changed
  • client/src/main/generated/com/regula/documentreader/webclient/model
  • example/src/main/java/com/regula/documentreader/webclient/example

2 files changed

+31
-30
lines changed

client/src/main/generated/com/regula/documentreader/webclient/model/FDSIDList.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public class FDSIDList {
4343
public static final String SERIALIZED_NAME_COUNT = "Count";
4444

4545
@SerializedName(SERIALIZED_NAME_COUNT)
46-
@javax.annotation.Nonnull
46+
@javax.annotation.Nullable
4747
private BigDecimal count;
4848

4949
public static final String SERIALIZED_NAME_LIST = "List";
5050

5151
@SerializedName(SERIALIZED_NAME_LIST)
52-
@javax.annotation.Nonnull
52+
@javax.annotation.Nullable
5353
private List<Integer> list;
5454

5555
public static final String SERIALIZED_NAME_D_TYPE = "dType";
@@ -79,7 +79,7 @@ public class FDSIDList {
7979
public static final String SERIALIZED_NAME_D_YEAR = "dYear";
8080

8181
@SerializedName(SERIALIZED_NAME_D_YEAR)
82-
@javax.annotation.Nonnull
82+
@javax.annotation.Nullable
8383
private String dYear;
8484

8585
public static final String SERIALIZED_NAME_D_COUNTRY_NAME = "dCountryName";
@@ -127,7 +127,7 @@ public void setIcAOCode(@javax.annotation.Nonnull String icAOCode) {
127127
this.icAOCode = icAOCode;
128128
}
129129

130-
public FDSIDList count(@javax.annotation.Nonnull BigDecimal count) {
130+
public FDSIDList count(@javax.annotation.Nullable BigDecimal count) {
131131
this.count = count;
132132
return this;
133133
}
@@ -137,16 +137,16 @@ public FDSIDList count(@javax.annotation.Nonnull BigDecimal count) {
137137
*
138138
* @return count
139139
*/
140-
@javax.annotation.Nonnull
140+
@javax.annotation.Nullable
141141
public BigDecimal getCount() {
142142
return count;
143143
}
144144

145-
public void setCount(@javax.annotation.Nonnull BigDecimal count) {
145+
public void setCount(@javax.annotation.Nullable BigDecimal count) {
146146
this.count = count;
147147
}
148148

149-
public FDSIDList list(@javax.annotation.Nonnull List<Integer> list) {
149+
public FDSIDList list(@javax.annotation.Nullable List<Integer> list) {
150150
this.list = list;
151151
return this;
152152
}
@@ -164,12 +164,12 @@ public FDSIDList addListItem(Integer listItem) {
164164
*
165165
* @return list
166166
*/
167-
@javax.annotation.Nonnull
167+
@javax.annotation.Nullable
168168
public List<Integer> getList() {
169169
return list;
170170
}
171171

172-
public void setList(@javax.annotation.Nonnull List<Integer> list) {
172+
public void setList(@javax.annotation.Nullable List<Integer> list) {
173173
this.list = list;
174174
}
175175

@@ -249,7 +249,7 @@ public void setdDescription(@javax.annotation.Nullable String dDescription) {
249249
this.dDescription = dDescription;
250250
}
251251

252-
public FDSIDList dYear(@javax.annotation.Nonnull String dYear) {
252+
public FDSIDList dYear(@javax.annotation.Nullable String dYear) {
253253
this.dYear = dYear;
254254
return this;
255255
}
@@ -259,12 +259,12 @@ public FDSIDList dYear(@javax.annotation.Nonnull String dYear) {
259259
*
260260
* @return dYear
261261
*/
262-
@javax.annotation.Nonnull
262+
@javax.annotation.Nullable
263263
public String getdYear() {
264264
return dYear;
265265
}
266266

267-
public void setdYear(@javax.annotation.Nonnull String dYear) {
267+
public void setdYear(@javax.annotation.Nullable String dYear) {
268268
this.dYear = dYear;
269269
}
270270

@@ -436,12 +436,9 @@ private String toIndentedString(Object o) {
436436
// a set of required properties/fields (JSON key names)
437437
openapiRequiredFields = new HashSet<String>();
438438
openapiRequiredFields.add("ICAOCode");
439-
openapiRequiredFields.add("Count");
440-
openapiRequiredFields.add("List");
441439
openapiRequiredFields.add("dType");
442440
openapiRequiredFields.add("dFormat");
443441
openapiRequiredFields.add("dMRZ");
444-
openapiRequiredFields.add("dYear");
445442
openapiRequiredFields.add("dCountryName");
446443
openapiRequiredFields.add("isDeprecated");
447444
}
@@ -479,11 +476,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
479476
"Expected the field `ICAOCode` to be a primitive type in the JSON string but got `%s`",
480477
jsonObj.get("ICAOCode").toString()));
481478
}
482-
// ensure the required json array is present
483-
if (jsonObj.get("List") == null) {
484-
throw new IllegalArgumentException(
485-
"Expected the field `linkedContent` to be an array in the JSON string but got `null`");
486-
} else if (!jsonObj.get("List").isJsonArray()) {
479+
// ensure the optional json data is an array if present
480+
if (jsonObj.get("List") != null
481+
&& !jsonObj.get("List").isJsonNull()
482+
&& !jsonObj.get("List").isJsonArray()) {
487483
throw new IllegalArgumentException(
488484
String.format(
489485
"Expected the field `List` to be an array in the JSON string but got `%s`",
@@ -500,7 +496,8 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
500496
"Expected the field `dDescription` to be a primitive type in the JSON string but got `%s`",
501497
jsonObj.get("dDescription").toString()));
502498
}
503-
if (!jsonObj.get("dYear").isJsonPrimitive()) {
499+
if ((jsonObj.get("dYear") != null && !jsonObj.get("dYear").isJsonNull())
500+
&& !jsonObj.get("dYear").isJsonPrimitive()) {
504501
throw new IllegalArgumentException(
505502
String.format(
506503
"Expected the field `dYear` to be a primitive type in the JSON string but got `%s`",

example/src/main/java/com/regula/documentreader/webclient/example/Main.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,21 @@ public static void main(String[] args) throws IOException, ApiException {
126126

127127
var documentImage = response.images().getField(GraphicFieldType.DOCUMENT_FRONT).getValue();
128128
var portraitField = response.images().getField(GraphicFieldType.PORTRAIT);
129-
var portraitFromVisual = portraitField.getValue(Source.VISUAL);
129+
var portraitFromVisual = portraitField != null ? portraitField.getValue(Source.VISUAL) : null;
130130

131-
try {
132-
saveFile("document-image.jpg", documentImage);
133-
} catch (IOException e) {
134-
throw new RuntimeException(e);
131+
if (documentImage != null) {
132+
try {
133+
saveFile("document-image.jpg", documentImage);
134+
} catch (IOException e) {
135+
throw new RuntimeException(e);
136+
}
135137
}
136-
try {
137-
saveFile("portrait.jpg", portraitFromVisual);
138-
} catch (IOException e) {
139-
throw new RuntimeException(e);
138+
if (portraitFromVisual != null) {
139+
try {
140+
saveFile("portrait.jpg", portraitFromVisual);
141+
} catch (IOException e) {
142+
throw new RuntimeException(e);
143+
}
140144
}
141145

142146
// how to get low lvl individual results

0 commit comments

Comments
 (0)