Skip to content

Commit 6f6e1ad

Browse files
committed
Auto generated files for newest dip mds version 2.1
1 parent 0365fdb commit 6f6e1ad

19 files changed

+1196
-895
lines changed

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/api/MdEinreichenProviderApi.java

Lines changed: 0 additions & 700 deletions
This file was deleted.

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/api/MdsProviderV21Api.java

Lines changed: 793 additions & 0 deletions
Large diffs are not rendered by default.

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/client/ApiClient.java

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* dip-mds
33
* DIP-Massendatenschnittstelle
44
*
5-
* The version of the OpenAPI document: DIP-MDS 1.3
5+
* The version of the OpenAPI document: DIP-MDS 2.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -56,6 +56,7 @@
5656
import java.util.Date;
5757
import java.util.function.Supplier;
5858
import java.util.TimeZone;
59+
import java.util.Locale;
5960
import java.util.regex.Matcher;
6061
import java.util.regex.Pattern;
6162

@@ -77,11 +78,12 @@
7778
import java.text.DateFormat;
7879

7980
import software.xdev.bzst.dip.client.generated.client.auth.Authentication;
81+
import software.xdev.bzst.dip.client.generated.client.auth.HttpBearerAuth;
8082

8183
public class ApiClient extends JavaTimeFormatter {
82-
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
83-
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
84-
private String basePath = "http://localhost";
84+
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
85+
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
86+
protected String basePath = "http://localhost";
8587
protected List<ServerConfiguration> servers = new ArrayList<ServerConfiguration>(Arrays.asList(
8688
new ServerConfiguration(
8789
"",
@@ -91,22 +93,22 @@ public class ApiClient extends JavaTimeFormatter {
9193
));
9294
protected Integer serverIndex = 0;
9395
protected Map<String, String> serverVariables = null;
94-
private boolean debugging = false;
95-
private int connectionTimeout = 0;
96+
protected boolean debugging = false;
97+
protected int connectionTimeout = 0;
9698

97-
private CloseableHttpClient httpClient;
98-
private ObjectMapper objectMapper;
99+
protected CloseableHttpClient httpClient;
100+
protected ObjectMapper objectMapper;
99101
protected String tempFolderPath = null;
100102

101-
private Map<String, Authentication> authentications;
103+
protected Map<String, Authentication> authentications;
102104

103-
private int statusCode;
104-
private Map<String, List<String>> responseHeaders;
105+
protected ThreadLocal<Integer> lastStatusCode = new ThreadLocal<>();
106+
protected ThreadLocal<Map<String, List<String>>> lastResponseHeaders = new ThreadLocal<>();
105107

106-
private DateFormat dateFormat;
108+
protected DateFormat dateFormat;
107109

108110
// Methods that can have a request body
109-
private static List<String> bodyMethods = Arrays.asList("POST", "PUT", "DELETE", "PATCH");
111+
protected static List<String> bodyMethods = Arrays.asList("POST", "PUT", "DELETE", "PATCH");
110112

111113
public ApiClient(CloseableHttpClient httpClient) {
112114
objectMapper = new ObjectMapper();
@@ -118,15 +120,17 @@ public ApiClient(CloseableHttpClient httpClient) {
118120
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
119121
objectMapper.registerModule(new JavaTimeModule());
120122
objectMapper.registerModule(new JsonNullableModule());
123+
objectMapper.registerModule(new RFC3339JavaTimeModule());
121124
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
122125

123126
dateFormat = ApiClient.buildDefaultDateFormat();
124127

125128
// Set default User-Agent.
126-
setUserAgent("OpenAPI-Generator/DIP-MDS 1.3/java");
129+
setUserAgent("OpenAPI-Generator/DIP-MDS 2.1/java");
127130

128131
// Setup authentications (key: authentication name, value: authentication).
129132
authentications = new HashMap<String, Authentication>();
133+
authentications.put("BearerAuth", new HttpBearerAuth("bearer"));
130134
// Prevent the authentications from being modified.
131135
authentications = Collections.unmodifiableMap(authentications);
132136

@@ -245,16 +249,18 @@ public ApiClient setServerVariables(Map<String, String> serverVariables) {
245249
*
246250
* @return Status code
247251
*/
252+
@Deprecated
248253
public int getStatusCode() {
249-
return statusCode;
254+
return lastStatusCode.get();
250255
}
251256

252257
/**
253258
* Gets the response headers of the previous request
254259
* @return Response headers
255260
*/
261+
@Deprecated
256262
public Map<String, List<String>> getResponseHeaders() {
257-
return responseHeaders;
263+
return lastResponseHeaders.get();
258264
}
259265

260266
/**
@@ -286,6 +292,35 @@ public String getTempFolderPath() {
286292
return tempFolderPath;
287293
}
288294

295+
/**
296+
* Helper method to set access token for the first Bearer authentication.
297+
* @param bearerToken Bearer token
298+
* @return API client
299+
*/
300+
public ApiClient setBearerToken(String bearerToken) {
301+
for (Authentication auth : authentications.values()) {
302+
if (auth instanceof HttpBearerAuth) {
303+
((HttpBearerAuth) auth).setBearerToken(bearerToken);
304+
return this;
305+
}
306+
}
307+
throw new RuntimeException("No Bearer authentication configured!");
308+
}
309+
310+
/**
311+
* Helper method to set the supplier of access tokens for Bearer authentication.
312+
*
313+
* @param tokenSupplier the token supplier function
314+
*/
315+
public void setBearerToken(Supplier<String> tokenSupplier) {
316+
for (Authentication auth : authentications.values()) {
317+
if (auth instanceof HttpBearerAuth) {
318+
((HttpBearerAuth) auth).setBearerToken(tokenSupplier);
319+
return;
320+
}
321+
}
322+
throw new RuntimeException("No Bearer authentication configured!");
323+
}
289324

290325

291326

@@ -295,7 +330,7 @@ public String getTempFolderPath() {
295330
* @param userAgent User agent
296331
* @return API client
297332
*/
298-
public ApiClient setUserAgent(String userAgent) {
333+
public final ApiClient setUserAgent(String userAgent) {
299334
addDefaultHeader("User-Agent", userAgent);
300335
return this;
301336
}
@@ -317,7 +352,7 @@ public ApiClient setTempFolderPath(String tempFolderPath) {
317352
* @param value The header's value
318353
* @return API client
319354
*/
320-
public ApiClient addDefaultHeader(String key, String value) {
355+
public final ApiClient addDefaultHeader(String key, String value) {
321356
defaultHeaderMap.put(key, value);
322357
return this;
323358
}
@@ -473,7 +508,7 @@ public List<Pair> parameterToPair(String name, Object value) {
473508
* @param value The value of the parameter.
474509
* @return A list of {@code Pair} objects.
475510
*/
476-
public List<Pair> parameterToPairs(String collectionFormat, String name, Collection value) {
511+
public List<Pair> parameterToPairs(String collectionFormat, String name, Collection<?> value) {
477512
List<Pair> params = new ArrayList<Pair>();
478513

479514
// preconditions
@@ -607,7 +642,7 @@ protected Map<String, List<String>> transformResponseHeaders(Header[] headers) {
607642
/**
608643
* Parse content type object from header value
609644
*/
610-
private ContentType getContentType(String headerValue) throws ApiException {
645+
protected ContentType getContentType(String headerValue) throws ApiException {
611646
try {
612647
return ContentType.parse(headerValue);
613648
} catch (UnsupportedCharsetException e) {
@@ -618,7 +653,7 @@ private ContentType getContentType(String headerValue) throws ApiException {
618653
/**
619654
* Get content type of a response or null if one was not provided
620655
*/
621-
private String getResponseMimeType(HttpResponse response) throws ApiException {
656+
protected String getResponseMimeType(HttpResponse response) throws ApiException {
622657
Header contentTypeHeader = response.getFirstHeader("Content-Type");
623658
if (contentTypeHeader != null) {
624659
return getContentType(contentTypeHeader.getValue()).getMimeType();
@@ -713,10 +748,11 @@ public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueT
713748
}
714749

715750
return objectMapper.readValue(content, valueType);
716-
} else if ("text/plain".equalsIgnoreCase(mimeType)) {
751+
} else if (mimeType.toLowerCase().startsWith("text/")) {
717752
// convert input stream to string
718753
return (T) EntityUtils.toString(entity);
719754
} else {
755+
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
720756
throw new ApiException(
721757
"Deserialization for content type '" + mimeType + "' not supported for type '" + valueType + "'",
722758
response.getCode(),
@@ -726,7 +762,7 @@ public <T> T deserialize(CloseableHttpResponse response, TypeReference<T> valueT
726762
}
727763
}
728764

729-
private File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
765+
protected File downloadFileFromResponse(CloseableHttpResponse response) throws IOException {
730766
Header contentDispositionHeader = response.getFirstHeader("Content-Disposition");
731767
String contentDisposition = contentDispositionHeader == null ? null : contentDispositionHeader.getValue();
732768
File file = prepareDownloadFile(contentDisposition);
@@ -778,6 +814,7 @@ public String getBaseURL() {
778814
if (serverIndex != null) {
779815
if (serverIndex < 0 || serverIndex >= servers.size()) {
780816
throw new ArrayIndexOutOfBoundsException(String.format(
817+
Locale.ROOT,
781818
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
782819
));
783820
}
@@ -797,7 +834,7 @@ public String getBaseURL() {
797834
* @param urlQueryDeepObject URL query string of the deep object parameters
798835
* @return The full URL
799836
*/
800-
private String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject) {
837+
protected String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams, String urlQueryDeepObject) {
801838
String baseURL = getBaseURL();
802839

803840
final StringBuilder url = new StringBuilder();
@@ -862,12 +899,15 @@ protected Cookie buildCookie(String key, String value, URI uri) {
862899
}
863900

864901
protected <T> T processResponse(CloseableHttpResponse response, TypeReference<T> returnType) throws ApiException, IOException, ParseException {
865-
statusCode = response.getCode();
902+
int statusCode = response.getCode();
903+
lastStatusCode.set(statusCode);
866904
if (statusCode == HttpStatus.SC_NO_CONTENT) {
867905
return null;
868906
}
869907

870-
responseHeaders = transformResponseHeaders(response.getHeaders());
908+
Map<String, List<String>> responseHeaders = transformResponseHeaders(response.getHeaders());
909+
lastResponseHeaders.set(responseHeaders);
910+
871911
if (isSuccessfulStatus(statusCode)) {
872912
return this.deserialize(response, returnType);
873913
} else {
@@ -973,7 +1013,7 @@ public <T> T invokeAPI(
9731013
* @param headerParams Header parameters
9741014
* @param cookieParams Cookie parameters
9751015
*/
976-
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
1016+
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
9771017
for (String authName : authNames) {
9781018
Authentication auth = authentications.get(authName);
9791019
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/client/ApiException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* dip-mds
33
* DIP-Massendatenschnittstelle
44
*
5-
* The version of the OpenAPI document: DIP-MDS 1.3
5+
* The version of the OpenAPI document: DIP-MDS 2.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/client/BaseApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* dip-mds
33
* DIP-Massendatenschnittstelle
44
*
5-
* The version of the OpenAPI document: DIP-MDS 1.3
5+
* The version of the OpenAPI document: DIP-MDS 2.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

bzst-dip-java-client/src/generated/java/software/xdev/bzst/dip/client/generated/client/Configuration.java

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* dip-mds
33
* DIP-Massendatenschnittstelle
44
*
5-
* The version of the OpenAPI document: DIP-MDS 1.3
5+
* The version of the OpenAPI document: DIP-MDS 2.1
66
*
77
*
88
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -13,28 +13,50 @@
1313

1414
package software.xdev.bzst.dip.client.generated.client;
1515

16+
import java.util.Objects;
17+
import java.util.concurrent.atomic.AtomicReference;
18+
import java.util.function.Supplier;
19+
1620
public class Configuration {
17-
public static final String VERSION = "DIP-MDS 1.3";
18-
19-
private static ApiClient defaultApiClient = new ApiClient();
20-
21-
/**
22-
* Get the default API client, which would be used when creating API
23-
* instances without providing an API client.
24-
*
25-
* @return Default API client
26-
*/
27-
public static ApiClient getDefaultApiClient() {
28-
return defaultApiClient;
29-
}
21+
public static final String VERSION = "DIP-MDS 2.1";
22+
23+
private static final AtomicReference<ApiClient> defaultApiClient = new AtomicReference<>();
24+
private static volatile Supplier<ApiClient> apiClientFactory = ApiClient::new;
3025

31-
/**
32-
* Set the default API client, which would be used when creating API
33-
* instances without providing an API client.
34-
*
35-
* @param apiClient API client
36-
*/
37-
public static void setDefaultApiClient(ApiClient apiClient) {
38-
defaultApiClient = apiClient;
26+
/**
27+
* Get the default API client, which would be used when creating API instances without providing an API client.
28+
*
29+
* @return Default API client
30+
*/
31+
public static ApiClient getDefaultApiClient() {
32+
ApiClient client = defaultApiClient.get();
33+
if (client == null) {
34+
client = defaultApiClient.updateAndGet(val -> {
35+
if (val != null) { // changed by another thread
36+
return val;
37+
}
38+
return apiClientFactory.get();
39+
});
3940
}
40-
}
41+
return client;
42+
}
43+
44+
/**
45+
* Set the default API client, which would be used when creating API instances without providing an API client.
46+
*
47+
* @param apiClient API client
48+
*/
49+
public static void setDefaultApiClient(ApiClient apiClient) {
50+
defaultApiClient.set(apiClient);
51+
}
52+
53+
/**
54+
* set the callback used to create new ApiClient objects
55+
*/
56+
public static void setApiClientFactory(Supplier<ApiClient> factory) {
57+
apiClientFactory = Objects.requireNonNull(factory);
58+
}
59+
60+
private Configuration() {
61+
}
62+
}

0 commit comments

Comments
 (0)