Skip to content

Commit e1c6346

Browse files
Update models
1 parent a3cf17f commit e1c6346

File tree

6 files changed

+81
-26
lines changed

6 files changed

+81
-26
lines changed

client/.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ src/main/generated/com/regula/documentreader/webclient/model/TransactionImage.ja
237237
src/main/generated/com/regula/documentreader/webclient/model/TransactionInfo.java
238238
src/main/generated/com/regula/documentreader/webclient/model/TransactionProcessGetResponse.java
239239
src/main/generated/com/regula/documentreader/webclient/model/TransactionProcessRequest.java
240-
src/main/generated/com/regula/documentreader/webclient/model/TransactionProcessResponse.java
241-
src/main/generated/com/regula/documentreader/webclient/model/TransactionProcessResponseItem.java
242240
src/main/generated/com/regula/documentreader/webclient/model/TransactionProcessResult.java
243241
src/main/generated/com/regula/documentreader/webclient/model/TrfFtBytes.java
244242
src/main/generated/com/regula/documentreader/webclient/model/TrfFtString.java

client/src/main/generated/com/regula/documentreader/webclient/JSON.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,8 @@ private static Class getClassByDiscriminator(
12251225
gsonBuilder.registerTypeAdapterFactory(
12261226
new com.regula.documentreader.webclient.model.ProcessRequestImage
12271227
.CustomTypeAdapterFactory());
1228+
gsonBuilder.registerTypeAdapterFactory(
1229+
new com.regula.documentreader.webclient.model.ProcessResponse.CustomTypeAdapterFactory());
12281230
gsonBuilder.registerTypeAdapterFactory(
12291231
new com.regula.documentreader.webclient.model.ProcessSystemInfo.CustomTypeAdapterFactory());
12301232
gsonBuilder.registerTypeAdapterFactory(
@@ -1367,12 +1369,6 @@ private static Class getClassByDiscriminator(
13671369
gsonBuilder.registerTypeAdapterFactory(
13681370
new com.regula.documentreader.webclient.model.TransactionProcessRequest
13691371
.CustomTypeAdapterFactory());
1370-
gsonBuilder.registerTypeAdapterFactory(
1371-
new com.regula.documentreader.webclient.model.TransactionProcessResponse
1372-
.CustomTypeAdapterFactory());
1373-
gsonBuilder.registerTypeAdapterFactory(
1374-
new com.regula.documentreader.webclient.model.TransactionProcessResponseItem
1375-
.CustomTypeAdapterFactory());
13761372
gsonBuilder.registerTypeAdapterFactory(
13771373
new com.regula.documentreader.webclient.model.TransactionProcessResult
13781374
.CustomTypeAdapterFactory());

client/src/main/generated/com/regula/documentreader/webclient/api/TransactionApi.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import com.regula.documentreader.webclient.Configuration;
2121
import com.regula.documentreader.webclient.Pair;
2222
import com.regula.documentreader.webclient.model.ListTransactionsByTagResponse;
23+
import com.regula.documentreader.webclient.model.ProcessResponse;
2324
import com.regula.documentreader.webclient.model.TransactionProcessGetResponse;
2425
import com.regula.documentreader.webclient.model.TransactionProcessRequest;
25-
import com.regula.documentreader.webclient.model.TransactionProcessResponse;
2626
import com.regula.documentreader.webclient.model.TransactionProcessResult;
2727
import java.io.File;
2828
import java.lang.reflect.Type;
@@ -1043,7 +1043,7 @@ private okhttp3.Call apiV2TransactionTransactionIdResultsGetValidateBeforeCall(
10431043
*
10441044
* @param transactionId Transaction id (required)
10451045
* @param withImages With base64 images or url (optional)
1046-
* @return TransactionProcessResponse
1046+
* @return ProcessResponse
10471047
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
10481048
* response body
10491049
* @http.response.details
@@ -1055,9 +1055,9 @@ private okhttp3.Call apiV2TransactionTransactionIdResultsGetValidateBeforeCall(
10551055
* <tr><td> 403 </td><td> Bad license. Either server or request does not contain valid license. </td><td> - </td></tr>
10561056
* </table>
10571057
*/
1058-
public TransactionProcessResponse apiV2TransactionTransactionIdResultsGet(
1058+
public ProcessResponse apiV2TransactionTransactionIdResultsGet(
10591059
UUID transactionId, Boolean withImages, HashMap<String, String> headers) throws ApiException {
1060-
ApiResponse<TransactionProcessResponse> localVarResp =
1060+
ApiResponse<ProcessResponse> localVarResp =
10611061
apiV2TransactionTransactionIdResultsGetWithHttpInfo(transactionId, withImages, headers);
10621062
return localVarResp.getData();
10631063
}
@@ -1067,7 +1067,7 @@ public TransactionProcessResponse apiV2TransactionTransactionIdResultsGet(
10671067
*
10681068
* @param transactionId Transaction id (required)
10691069
* @param withImages With base64 images or url (optional)
1070-
* @return ApiResponse&lt;TransactionProcessResponse&gt;
1070+
* @return ApiResponse&lt;ProcessResponse&gt;
10711071
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
10721072
* response body
10731073
* @http.response.details
@@ -1079,14 +1079,12 @@ public TransactionProcessResponse apiV2TransactionTransactionIdResultsGet(
10791079
* <tr><td> 403 </td><td> Bad license. Either server or request does not contain valid license. </td><td> - </td></tr>
10801080
* </table>
10811081
*/
1082-
public ApiResponse<TransactionProcessResponse>
1083-
apiV2TransactionTransactionIdResultsGetWithHttpInfo(
1084-
UUID transactionId, Boolean withImages, HashMap<String, String> headers)
1085-
throws ApiException {
1082+
public ApiResponse<ProcessResponse> apiV2TransactionTransactionIdResultsGetWithHttpInfo(
1083+
UUID transactionId, Boolean withImages, HashMap<String, String> headers) throws ApiException {
10861084
okhttp3.Call localVarCall =
10871085
apiV2TransactionTransactionIdResultsGetValidateBeforeCall(
10881086
transactionId, withImages, headers, null);
1089-
Type localVarReturnType = new TypeToken<TransactionProcessResponse>() {}.getType();
1087+
Type localVarReturnType = new TypeToken<ProcessResponse>() {}.getType();
10901088
return localVarApiClient.execute(localVarCall, localVarReturnType);
10911089
}
10921090

@@ -1111,13 +1109,13 @@ public okhttp3.Call apiV2TransactionTransactionIdResultsGetAsync(
11111109
UUID transactionId,
11121110
Boolean withImages,
11131111
HashMap<String, String> headers,
1114-
final ApiCallback<TransactionProcessResponse> _callback)
1112+
final ApiCallback<ProcessResponse> _callback)
11151113
throws ApiException {
11161114

11171115
okhttp3.Call localVarCall =
11181116
apiV2TransactionTransactionIdResultsGetValidateBeforeCall(
11191117
transactionId, withImages, headers, _callback);
1120-
Type localVarReturnType = new TypeToken<TransactionProcessResponse>() {}.getType();
1118+
Type localVarReturnType = new TypeToken<ProcessResponse>() {}.getType();
11211119
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
11221120
return localVarCall;
11231121
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.gson.stream.JsonWriter;
2424
import com.regula.documentreader.webclient.JSON;
2525
import java.io.IOException;
26-
import java.time.LocalDate;
2726
import java.util.HashSet;
2827
import java.util.Map;
2928
import java.util.Objects;
@@ -50,7 +49,7 @@ public class HealthcheckDocumentsDatabase {
5049

5150
@SerializedName(SERIALIZED_NAME_EXPORT_DATE)
5251
@javax.annotation.Nullable
53-
private LocalDate exportDate;
52+
private String exportDate;
5453

5554
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
5655

@@ -98,7 +97,7 @@ public void setVersion(@javax.annotation.Nullable String version) {
9897
this.version = version;
9998
}
10099

101-
public HealthcheckDocumentsDatabase exportDate(@javax.annotation.Nullable LocalDate exportDate) {
100+
public HealthcheckDocumentsDatabase exportDate(@javax.annotation.Nullable String exportDate) {
102101
this.exportDate = exportDate;
103102
return this;
104103
}
@@ -109,11 +108,11 @@ public HealthcheckDocumentsDatabase exportDate(@javax.annotation.Nullable LocalD
109108
* @return exportDate
110109
*/
111110
@javax.annotation.Nullable
112-
public LocalDate getExportDate() {
111+
public String getExportDate() {
113112
return exportDate;
114113
}
115114

116-
public void setExportDate(@javax.annotation.Nullable LocalDate exportDate) {
115+
public void setExportDate(@javax.annotation.Nullable String exportDate) {
117116
this.exportDate = exportDate;
118117
}
119118

@@ -249,6 +248,13 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
249248
"Expected the field `version` to be a primitive type in the JSON string but got `%s`",
250249
jsonObj.get("version").toString()));
251250
}
251+
if ((jsonObj.get("exportDate") != null && !jsonObj.get("exportDate").isJsonNull())
252+
&& !jsonObj.get("exportDate").isJsonPrimitive()) {
253+
throw new IllegalArgumentException(
254+
String.format(
255+
"Expected the field `exportDate` to be a primitive type in the JSON string but got `%s`",
256+
jsonObj.get("exportDate").toString()));
257+
}
252258
if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull())
253259
&& !jsonObj.get("description").isJsonPrimitive()) {
254260
throw new IllegalArgumentException(

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@
1212

1313
package com.regula.documentreader.webclient.model;
1414

15+
import com.google.gson.Gson;
1516
import com.google.gson.JsonElement;
1617
import com.google.gson.JsonObject;
18+
import com.google.gson.TypeAdapter;
19+
import com.google.gson.TypeAdapterFactory;
1720
import com.google.gson.annotations.SerializedName;
21+
import com.google.gson.reflect.TypeToken;
22+
import com.google.gson.stream.JsonReader;
23+
import com.google.gson.stream.JsonWriter;
1824
import com.regula.documentreader.webclient.JSON;
1925
import java.io.IOException;
2026
import java.util.HashMap;
2127
import java.util.HashSet;
2228
import java.util.Map;
2329
import java.util.Objects;
30+
import java.util.Set;
2431

2532
/** ProcessResponse */
2633
@javax.annotation.Generated(
@@ -405,6 +412,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
405412
ProcessResponse.openapiRequiredFields.toString()));
406413
}
407414
}
415+
416+
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
417+
// check to see if the JSON string contains additional fields
418+
for (Map.Entry<String, JsonElement> entry : entries) {
419+
if (!ProcessResponse.openapiFields.contains(entry.getKey())) {
420+
throw new IllegalArgumentException(
421+
String.format(
422+
"The field `%s` in the JSON string is not defined in the `ProcessResponse` properties. JSON: %s",
423+
entry.getKey(), jsonElement.toString()));
424+
}
425+
}
426+
427+
// check to make sure all required properties/fields are present in the JSON string
428+
for (String requiredField : ProcessResponse.openapiRequiredFields) {
429+
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
430+
throw new IllegalArgumentException(
431+
String.format(
432+
"The required field `%s` is not found in the JSON string: %s",
433+
requiredField, jsonElement.toString()));
434+
}
435+
}
408436
JsonObject jsonObj = jsonElement.getAsJsonObject();
409437
// validate the required field `ChipPage`
410438
RfidLocation.validateJsonElement(jsonObj.get("ChipPage"));
@@ -423,6 +451,35 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
423451
}
424452
}
425453

454+
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
455+
@SuppressWarnings("unchecked")
456+
@Override
457+
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
458+
if (!ProcessResponse.class.isAssignableFrom(type.getRawType())) {
459+
return null; // this class only serializes 'ProcessResponse' and its subtypes
460+
}
461+
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
462+
final TypeAdapter<ProcessResponse> thisAdapter =
463+
gson.getDelegateAdapter(this, TypeToken.get(ProcessResponse.class));
464+
465+
return (TypeAdapter<T>)
466+
new TypeAdapter<ProcessResponse>() {
467+
@Override
468+
public void write(JsonWriter out, ProcessResponse value) throws IOException {
469+
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
470+
elementAdapter.write(out, obj);
471+
}
472+
473+
@Override
474+
public ProcessResponse read(JsonReader in) throws IOException {
475+
JsonElement jsonElement = elementAdapter.read(in);
476+
validateJsonElement(jsonElement);
477+
return thisAdapter.fromJsonTree(jsonElement);
478+
}
479+
}.nullSafe();
480+
}
481+
}
482+
426483
/**
427484
* Create an instance of ProcessResponse given an JSON string
428485
*

client/src/main/java/com/regula/documentreader/webclient/api/DocumentReaderApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public RecognitionResponse process(
9191
}
9292

9393
public RecognitionResponse process(
94-
ProcessRequest processRequest, HashMap<String, String> headers) {
94+
ProcessRequest processRequest, HashMap<String, String> headers) {
9595
processRequest.getSystemInfo().setLicense(this.license);
9696
ProcessResponse response = processApi.apiProcess(processRequest, "", headers);
9797
return new RecognitionResponse(response);

0 commit comments

Comments
 (0)