Skip to content

Commit 2e3bea4

Browse files
committed
Fix openapi-generator update.
1 parent 780234c commit 2e3bea4

File tree

7 files changed

+194
-2
lines changed

7 files changed

+194
-2
lines changed

boat-scaffold/src/main/java/com/backbase/oss/codegen/java/BoatJavaCodeGen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ private boolean isArrayTypeOfEnum(Schema s) {
157157
if (!ModelUtils.isArraySchema(target)) {
158158
return false;
159159
}
160-
Schema items = getSchemaItems((ArraySchema) target);
160+
Schema items = target.getItems();
161+
if (items == null) {
162+
// Will default to strings schema, which is not an enum
163+
return false;
164+
}
161165
if (items.get$ref() != null) {
162166
items = openAPI.getComponents().getSchemas().get(ModelUtils.getSimpleRef(items.get$ref()));
163167
}

boat-scaffold/src/main/java/com/backbase/oss/codegen/java/BoatSpringCodeGen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
414414
if (shouldSerializeBigDecimalAsString(property)) {
415415
property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = BigDecimalCustomSerializer.class)");
416416
model.imports.add("BigDecimalCustomSerializer");
417-
model.imports.add("JsonSerialize");
418417
}
419418
}
420419

boat-scaffold/src/main/java/com/backbase/oss/codegen/java/BoatSpringCodegenProperty.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public BoatSpringCodegenProperty(CodegenProperty codegenProperty) {
137137
defaultValue = "new HashMap<>()";
138138
isMap = true;
139139
}
140+
this.nameInCamelCase = StringUtils.capitalize(this.nameInCamelCase);
140141
}
141142
@Override
142143
public String toString() {
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{{>licenseInfo}}
2+
package {{invokerPackage}};
3+
4+
import com.fasterxml.jackson.core.type.TypeReference;
5+
6+
import java.util.Collections;
7+
import java.util.Map;
8+
9+
{{>generatedAnnotation}}
10+
public abstract class BaseApi {
11+
12+
protected ApiClient apiClient;
13+
14+
public BaseApi() {
15+
this(Configuration.getDefaultApiClient());
16+
}
17+
18+
public BaseApi(ApiClient apiClient) {
19+
this.apiClient = apiClient;
20+
}
21+
22+
public ApiClient getApiClient() {
23+
return apiClient;
24+
}
25+
26+
public void setApiClient(ApiClient apiClient) {
27+
this.apiClient = apiClient;
28+
}
29+
30+
/**
31+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
32+
* @param url The URL for the request, either full URL or only the path.
33+
* @param method The HTTP method for the request.
34+
* @throws ApiException if fails to make API call.
35+
*/
36+
public void invokeAPI(String url, String method) throws ApiException {
37+
invokeAPI(url, method, null, null, Collections.emptyMap());
38+
}
39+
40+
/**
41+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
42+
* @param url The URL for the request, either full URL or only the path.
43+
* @param method The HTTP method for the request.
44+
* @param additionalHeaders Additional headers for the request.
45+
* @throws ApiException if fails to make API call.
46+
*/
47+
public void invokeAPI(String url, String method, Map<String, String> additionalHeaders) throws ApiException {
48+
invokeAPI(url, method, null, null, additionalHeaders);
49+
}
50+
51+
/**
52+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
53+
* @param url The URL for the request, either full URL or only the path.
54+
* @param method The HTTP method for the request.
55+
* @param request The request object.
56+
* @throws ApiException if fails to make API call.
57+
*/
58+
public void invokeAPI(String url, String method, Object request) throws ApiException {
59+
invokeAPI(url, method, request, null, Collections.emptyMap());
60+
}
61+
62+
/**
63+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
64+
* @param url The URL for the request, either full URL or only the path.
65+
* @param method The HTTP method for the request.
66+
* @param request The request object.
67+
* @param additionalHeaders Additional headers for the request.
68+
* @throws ApiException if fails to make API call.
69+
*/
70+
public void invokeAPI(String url, String method, Object request, Map<String, String> additionalHeaders) throws ApiException {
71+
invokeAPI(url, method, request, null, additionalHeaders);
72+
}
73+
74+
/**
75+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
76+
* @param url The URL for the request, either full URL or only the path.
77+
* @param method The HTTP method for the request.
78+
* @param returnType The return type.
79+
* @return The API response in the specified type.
80+
* @throws ApiException if fails to make API call.
81+
*/
82+
public <T> T invokeAPI(String url, String method, TypeReference<T> returnType) throws ApiException {
83+
return invokeAPI(url, method, null, returnType, Collections.emptyMap());
84+
}
85+
86+
/**
87+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
88+
* @param url The URL for the request, either full URL or only the path.
89+
* @param method The HTTP method for the request.
90+
* @param request The request object.
91+
* @param returnType The return type.
92+
* @return The API response in the specified type.
93+
* @throws ApiException if fails to make API call.
94+
*/
95+
public <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType) throws ApiException {
96+
return invokeAPI(url, method, request, returnType, Collections.emptyMap());
97+
}
98+
99+
/**
100+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
101+
* @param url The URL for the request, either full URL or only the path.
102+
* @param method The HTTP method for the request.
103+
* @param request The request object.
104+
* @param returnType The return type.
105+
* @param additionalHeaders Additional headers for the request.
106+
* @return The API response in the specified type.
107+
* @throws ApiException if fails to make API call.
108+
*/
109+
public abstract <T> T invokeAPI(String url, String method, Object request, TypeReference<T> returnType, Map<String, String> additionalHeaders) throws ApiException;
110+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{>licenseInfo}}
2+
3+
package {{invokerPackage}};
4+
5+
import org.springframework.web.client.RestClientException;
6+
import org.springframework.core.ParameterizedTypeReference;
7+
import org.springframework.http.HttpMethod;
8+
import org.springframework.http.ResponseEntity;
9+
10+
{{>generatedAnnotation}}
11+
public abstract class BaseApi {
12+
13+
protected ApiClient apiClient;
14+
15+
public BaseApi() {
16+
this(new ApiClient());
17+
}
18+
19+
public BaseApi(ApiClient apiClient) {
20+
this.apiClient = apiClient;
21+
}
22+
23+
public ApiClient getApiClient() {
24+
return apiClient;
25+
}
26+
27+
public void setApiClient(ApiClient apiClient) {
28+
this.apiClient = apiClient;
29+
}
30+
31+
/**
32+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
33+
* @param url The URL for the request, either full URL or only the path.
34+
* @param method The HTTP method for the request.
35+
* @return ResponseEntity&lt;Void&gt;
36+
* @throws RestClientException if an error occurs while attempting to invoke the API
37+
*/
38+
public ResponseEntity<Void> invokeAPI(String url, HttpMethod method) throws RestClientException {
39+
return invokeAPI(url, method, null, new ParameterizedTypeReference<Void>() {});
40+
}
41+
42+
/**
43+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
44+
* @param url The URL for the request, either full URL or only the path.
45+
* @param method The HTTP method for the request.
46+
* @param request The request object.
47+
* @return ResponseEntity&lt;Void&gt;
48+
* @throws RestClientException if an error occurs while attempting to invoke the API
49+
*/
50+
public ResponseEntity<Void> invokeAPI(String url, HttpMethod method, Object request) throws RestClientException {
51+
return invokeAPI(url, method, request, new ParameterizedTypeReference<Void>() {});
52+
}
53+
54+
/**
55+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
56+
* @param url The URL for the request, either full URL or only the path.
57+
* @param method The HTTP method for the request.
58+
* @param returnType The return type.
59+
* @return ResponseEntity in the specified type.
60+
* @throws RestClientException if an error occurs while attempting to invoke the API
61+
*/
62+
public <T> ResponseEntity<T> invokeAPI(String url, HttpMethod method, ParameterizedTypeReference<T> returnType) throws RestClientException {
63+
return invokeAPI(url, method, null, returnType);
64+
}
65+
66+
/**
67+
* Directly invoke the API for the given URL. Useful if the API returns direct links/URLs for subsequent requests.
68+
* @param url The URL for the request, either full URL or only the path.
69+
* @param method The HTTP method for the request.
70+
* @param request The request object.
71+
* @param returnType The return type.
72+
* @return ResponseEntity in the specified type.
73+
* @throws RestClientException if an error occurs while attempting to invoke the API
74+
*/
75+
public abstract <T> ResponseEntity<T> invokeAPI(String url, HttpMethod method, Object request, ParameterizedTypeReference<T> returnType) throws RestClientException;
76+
}

boat-scaffold/src/main/templates/boat-java/model.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import java.io.Serializable;
1717
{{#jackson}}
1818
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
1919
import com.fasterxml.jackson.annotation.JsonTypeName;
20+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2021
{{#withXml}}
2122
import com.fasterxml.jackson.dataformat.xml.annotation.*;
2223
{{/withXml}}

boat-scaffold/src/main/templates/boat-spring/model.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import javax.validation.constraints.*;
4545
import org.hibernate.validator.constraints.*;
4646
{{/performBeanValidation}}
4747
{{#jackson}}
48+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
4849
{{#withXml}}
4950
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
5051
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;

0 commit comments

Comments
 (0)