servers) {
+ this.servers = servers;
+ updateBasePath();
+ return this;
+ }
+
+ /**
+ * Getter for the field serverIndex
.
+ *
+ * @return a {@link java.lang.Integer} object.
+ */
+ public Integer getServerIndex() {
+ return serverIndex;
+ }
+
+ /**
+ * Setter for the field serverIndex
.
+ *
+ * @param serverIndex the server index
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setServerIndex(Integer serverIndex) {
+ this.serverIndex = serverIndex;
+ updateBasePath();
+ return this;
+ }
+
+ /**
+ * Getter for the field serverVariables
.
+ *
+ * @return a {@link java.util.Map} of server variables.
+ */
+ public Map getServerVariables() {
+ return serverVariables;
+ }
+
+ /**
+ * Setter for the field serverVariables
.
+ *
+ * @param serverVariables a {@link java.util.Map} of server variables.
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setServerVariables(Map serverVariables) {
+ this.serverVariables = serverVariables;
+ updateBasePath();
+ return this;
+ }
+
+ private void updateBasePath() {
+ if (serverIndex != null) {
+ setBasePath(servers.get(serverIndex).URL(serverVariables));
+ }
+ }
+
+ /**
+ * Get authentications (key: authentication name, value: authentication).
+ *
+ * @return Map of authentication object
+ */
+ public Map getAuthentications() {
+ return authentications;
+ }
+
+ /**
+ * Get authentication for the given name.
+ *
+ * @param authName The authentication name
+ * @return The authentication, null if not found
+ */
+ public Authentication getAuthentication(String authName) {
+ return authentications.get(authName);
+ }
+
+ /**
+ * Helper method to set username for the first HTTP basic authentication.
+ *
+ * @param username Username
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setUsername(String username) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setUsername(username);
+ return this;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /**
+ * Helper method to set password for the first HTTP basic authentication.
+ *
+ * @param password Password
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setPassword(String password) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setPassword(password);
+ return this;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /**
+ * Helper method to set API key value for the first API key authentication.
+ *
+ * @param apiKey API key
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setApiKey(String apiKey) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof ApiKeyAuth) {
+ ((ApiKeyAuth) auth).setApiKey(apiKey);
+ return this;
+ }
+ }
+ throw new RuntimeException("No API key authentication configured!");
+ }
+
+ /**
+ * Helper method to configure authentications which respects aliases of API keys.
+ *
+ * @param secrets Hash map from authentication name to its secret.
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient configureApiKeys(Map secrets) {
+ for (Map.Entry authEntry : authentications.entrySet()) {
+ Authentication auth = authEntry.getValue();
+ if (auth instanceof ApiKeyAuth) {
+ String name = authEntry.getKey();
+ // respect x-auth-id-alias property
+ name = authenticationLookup.getOrDefault(name, name);
+ String secret = secrets.get(name);
+ if (secret != null) {
+ ((ApiKeyAuth) auth).setApiKey(secret);
+ }
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Helper method to set API key prefix for the first API key authentication.
+ *
+ * @param apiKeyPrefix API key prefix
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setApiKeyPrefix(String apiKeyPrefix) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof ApiKeyAuth) {
+ ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
+ return this;
+ }
+ }
+ throw new RuntimeException("No API key authentication configured!");
+ }
+
+ /**
+ * Helper method to set bearer token for the first Bearer authentication.
+ *
+ * @param bearerToken Bearer token
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setBearerToken(String bearerToken) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBearerAuth) {
+ ((HttpBearerAuth) auth).setBearerToken(bearerToken);
+ return this;
+ }
+ }
+ throw new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /**
+ * Set the User-Agent header's value (by adding to the default header map).
+ *
+ * @param userAgent Http user agent
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setUserAgent(String userAgent) {
+ this.userAgent = userAgent;
+ addDefaultHeader("User-Agent", userAgent);
+ return this;
+ }
+
+ /**
+ * Get the User-Agent header's value.
+ *
+ * @return User-Agent string
+ */
+ public String getUserAgent(){
+ return userAgent;
+ }
+
+ /**
+ * Add a default header.
+ *
+ * @param key The header's key
+ * @param value The header's value
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient addDefaultHeader(String key, String value) {
+ defaultHeaderMap.put(key, value);
+ return this;
+ }
+
+ /**
+ * Add a default cookie.
+ *
+ * @param key The cookie's key
+ * @param value The cookie's value
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient addDefaultCookie(String key, String value) {
+ defaultCookieMap.put(key, value);
+ return this;
+ }
+
+ /**
+ * Gets the client config.
+ *
+ * @return Client config
+ */
+ public ClientConfig getClientConfig() {
+ return clientConfig;
+ }
+
+ /**
+ * Set the client config.
+ *
+ * @param clientConfig Set the client config
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setClientConfig(ClientConfig clientConfig) {
+ this.clientConfig = clientConfig;
+ // Rebuild HTTP Client according to the new "clientConfig" value.
+ this.httpClient = buildHttpClient();
+ return this;
+ }
+
+ /**
+ * Check that whether debugging is enabled for this API client.
+ *
+ * @return True if debugging is switched on
+ */
+ public boolean isDebugging() {
+ return debugging;
+ }
+
+ /**
+ * Enable/disable debugging for this API client.
+ *
+ * @param debugging To enable (true) or disable (false) debugging
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setDebugging(boolean debugging) {
+ this.debugging = debugging;
+ // Rebuild HTTP Client according to the new "debugging" value.
+ this.httpClient = buildHttpClient();
+ return this;
+ }
+
+ /**
+ * The path of temporary folder used to store downloaded files from endpoints
+ * with file response. The default value is null
, i.e. using
+ * the system's default temporary folder.
+ *
+ * @return Temp folder path
+ */
+ public String getTempFolderPath() {
+ return tempFolderPath;
+ }
+
+ /**
+ * Set temp folder path
+ *
+ * @param tempFolderPath Temp folder path
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setTempFolderPath(String tempFolderPath) {
+ this.tempFolderPath = tempFolderPath;
+ return this;
+ }
+
+ /**
+ * Connect timeout (in milliseconds).
+ *
+ * @return Connection timeout
+ */
+ public int getConnectTimeout() {
+ return connectionTimeout;
+ }
+
+ /**
+ * Set the connect timeout (in milliseconds).
+ * A value of 0 means no timeout, otherwise values must be between 1 and
+ * {@link Integer#MAX_VALUE}.
+ *
+ * @param connectionTimeout Connection timeout in milliseconds
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setConnectTimeout(int connectionTimeout) {
+ this.connectionTimeout = connectionTimeout;
+ httpClient.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout);
+ return this;
+ }
+
+ /**
+ * read timeout (in milliseconds).
+ *
+ * @return Read timeout
+ */
+ public int getReadTimeout() {
+ return readTimeout;
+ }
+
+ /**
+ * Set the read timeout (in milliseconds).
+ * A value of 0 means no timeout, otherwise values must be between 1 and
+ * {@link Integer#MAX_VALUE}.
+ *
+ * @param readTimeout Read timeout in milliseconds
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setReadTimeout(int readTimeout) {
+ this.readTimeout = readTimeout;
+ httpClient.property(ClientProperties.READ_TIMEOUT, readTimeout);
+ return this;
+ }
+
+ /**
+ * Get the date format used to parse/format date parameters.
+ *
+ * @return Date format
+ */
+ public DateFormat getDateFormat() {
+ return dateFormat;
+ }
+
+ /**
+ * Set the date format used to parse/format date parameters.
+ *
+ * @param dateFormat Date format
+ * @return a {@link ApiClient} object.
+ */
+ public ApiClient setDateFormat(DateFormat dateFormat) {
+ this.dateFormat = dateFormat;
+ // also set the date format for model (de)serialization with Date properties
+ this.json.setDateFormat((DateFormat) dateFormat.clone());
+ return this;
+ }
+
+ /**
+ * Parse the given string into Date object.
+ *
+ * @param str String
+ * @return Date
+ */
+ public Date parseDate(String str) {
+ try {
+ return dateFormat.parse(str);
+ } catch (java.text.ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Format the given Date object into string.
+ *
+ * @param date Date
+ * @return Date in string format
+ */
+ public String formatDate(Date date) {
+ return dateFormat.format(date);
+ }
+
+ /**
+ * Format the given parameter object into string.
+ *
+ * @param param Object
+ * @return Object in string format
+ */
+ public String parameterToString(Object param) {
+ if (param == null) {
+ return "";
+ } else if (param instanceof Date) {
+ return formatDate((Date) param);
+ } else if (param instanceof OffsetDateTime) {
+ return formatOffsetDateTime((OffsetDateTime) param);
+ } else if (param instanceof Collection>) {
+ StringBuilder b = new StringBuilder();
+ for(Object o : (Collection>)param) {
+ if(b.length() > 0) {
+ b.append(',');
+ }
+ b.append(String.valueOf(o));
+ }
+ return b.toString();
+ } else {
+ return String.valueOf(param);
+ }
+ }
+
+ /*
+ * Format to {@code Pair} objects.
+ *
+ * @param collectionFormat Collection format
+ * @param name Name
+ * @param value Value
+ * @return List of pairs
+ */
+ public List parameterToPairs(String collectionFormat, String name, Object value){
+ List params = new ArrayList<>();
+
+ // preconditions
+ if (name == null || name.isEmpty() || value == null) return params;
+
+ Collection> valueCollection;
+ if (value instanceof Collection>) {
+ valueCollection = (Collection>) value;
+ } else {
+ params.add(new Pair(name, parameterToString(value)));
+ return params;
+ }
+
+ if (valueCollection.isEmpty()){
+ return params;
+ }
+
+ // get the collection format (default: csv)
+ String format = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat);
+
+ // create the params based on the collection format
+ if ("multi".equals(format)) {
+ for (Object item : valueCollection) {
+ params.add(new Pair(name, parameterToString(item)));
+ }
+
+ return params;
+ }
+
+ String delimiter = ",";
+
+ if ("csv".equals(format)) {
+ delimiter = ",";
+ } else if ("ssv".equals(format)) {
+ delimiter = " ";
+ } else if ("tsv".equals(format)) {
+ delimiter = "\t";
+ } else if ("pipes".equals(format)) {
+ delimiter = "|";
+ }
+
+ StringBuilder sb = new StringBuilder() ;
+ for (Object item : valueCollection) {
+ sb.append(delimiter);
+ sb.append(parameterToString(item));
+ }
+
+ params.add(new Pair(name, sb.substring(1)));
+
+ return params;
+ }
+
+ /**
+ * Check if the given MIME is a JSON MIME.
+ * JSON MIME examples:
+ * application/json
+ * application/json; charset=UTF8
+ * APPLICATION/JSON
+ * application/vnd.company+json
+ * "*{@literal /}*" is also considered JSON by this method.
+ *
+ * @param mime MIME
+ * @return True if the MIME type is JSON
+ */
+ public boolean isJsonMime(String mime) {
+ return mime != null && (mime.equals("*/*") || JSON_MIME_PATTERN.matcher(mime).matches());
+ }
+
+ /**
+ * Select the Accept header's value from the given accepts array:
+ * if JSON exists in the given array, use it;
+ * otherwise use all of them (joining into a string)
+ *
+ * @param accepts The accepts array to select from
+ * @return The Accept header to use. If the given array is empty,
+ * null will be returned (not to set the Accept header explicitly).
+ */
+ public String selectHeaderAccept(String... accepts) {
+ if (accepts == null || accepts.length == 0) {
+ return null;
+ }
+ for (String accept : accepts) {
+ if (isJsonMime(accept)) {
+ return accept;
+ }
+ }
+ return StringUtil.join(accepts, ",");
+ }
+
+ /**
+ * Select the Content-Type header's value from the given array:
+ * if JSON exists in the given array, use it;
+ * otherwise use the first one of the array.
+ *
+ * @param contentTypes The Content-Type array to select from
+ * @return The Content-Type header to use. If the given array is empty,
+ * JSON will be used.
+ */
+ public String selectHeaderContentType(String... contentTypes) {
+ if (contentTypes == null || contentTypes.length == 0) {
+ return "application/json";
+ }
+ for (String contentType : contentTypes) {
+ if (isJsonMime(contentType)) {
+ return contentType;
+ }
+ }
+ return contentTypes[0];
+ }
+
+ /**
+ * Escape the given string to be used as URL query value.
+ *
+ * @param str String
+ * @return Escaped string
+ */
+ public String escapeString(String str) {
+ try {
+ return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
+ } catch (UnsupportedEncodingException e) {
+ return str;
+ }
+ }
+
+ /**
+ * Serialize the given Java object into string entity according the given
+ * Content-Type (only JSON is supported for now).
+ *
+ * @param obj Object
+ * @param formParams Form parameters
+ * @param contentType Context type
+ * @return Entity
+ * @throws ApiException API exception
+ */
+ public Entity> serialize(Object obj, Map formParams, String contentType, boolean isBodyNullable) throws ApiException {
+ Entity> entity;
+ if (contentType.startsWith("multipart/form-data")) {
+ MultiPart multiPart = new MultiPart();
+ for (Entry param: formParams.entrySet()) {
+ if (param.getValue() instanceof Iterable) {
+ ((Iterable)param.getValue()).forEach(v -> addParamToMultipart(v, param.getKey(), multiPart));
+ } else {
+ addParamToMultipart(param.getValue(), param.getKey(), multiPart);
+ }
+ }
+ entity = Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE);
+ } else if (contentType.startsWith("application/x-www-form-urlencoded")) {
+ Form form = new Form();
+ for (Entry param: formParams.entrySet()) {
+ form.param(param.getKey(), parameterToString(param.getValue()));
+ }
+ entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
+ } else {
+ // We let jersey handle the serialization
+ if (isBodyNullable) { // payload is nullable
+ if (obj instanceof String) {
+ entity = Entity.entity(obj == null ? "null" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
+ } else {
+ entity = Entity.entity(obj == null ? "null" : obj, contentType);
+ }
+ } else {
+ if (obj instanceof String) {
+ entity = Entity.entity(obj == null ? "" : "\"" + ((String)obj).replaceAll("\"", Matcher.quoteReplacement("\\\"")) + "\"", contentType);
+ } else {
+ entity = Entity.entity(obj == null ? "" : obj, contentType);
+ }
+ }
+ }
+ return entity;
+ }
+
+ /**
+ * Adds the object with the provided key to the MultiPart.
+ * Based on the object type sets Content-Disposition and Content-Type.
+ *
+ * @param obj Object
+ * @param key Key of the object
+ * @param multiPart MultiPart to add the form param to
+ */
+ private void addParamToMultipart(Object value, String key, MultiPart multiPart) {
+ if (value instanceof File) {
+ File file = (File) value;
+ FormDataContentDisposition contentDisp = FormDataContentDisposition.name(key)
+ .fileName(file.getName()).size(file.length()).build();
+
+ // Attempt to probe the content type for the file so that the form part is more correctly
+ // and precisely identified, but fall back to application/octet-stream if that fails.
+ MediaType type;
+ try {
+ type = MediaType.valueOf(Files.probeContentType(file.toPath()));
+ } catch (IOException | IllegalArgumentException e) {
+ type = MediaType.APPLICATION_OCTET_STREAM_TYPE;
+ }
+
+ multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, type));
+ } else {
+ FormDataContentDisposition contentDisp = FormDataContentDisposition.name(key).build();
+ multiPart.bodyPart(new FormDataBodyPart(contentDisp, parameterToString(value)));
+ }
+ }
+
+ /**
+ * Serialize the given Java object into string according the given
+ * Content-Type (only JSON, HTTP form is supported for now).
+ *
+ * @param obj Object
+ * @param formParams Form parameters
+ * @param contentType Context type
+ * @param isBodyNullable True if the body is nullable
+ * @return String
+ * @throws ApiException API exception
+ */
+ public String serializeToString(Object obj, Map formParams, String contentType, boolean isBodyNullable) throws ApiException {
+ try {
+ if (contentType.startsWith("multipart/form-data")) {
+ throw new ApiException("multipart/form-data not yet supported for serializeToString (http signature authentication)");
+ } else if (contentType.startsWith("application/x-www-form-urlencoded")) {
+ String formString = "";
+ for (Entry param : formParams.entrySet()) {
+ formString = param.getKey() + "=" + URLEncoder.encode(parameterToString(param.getValue()), "UTF-8") + "&";
+ }
+
+ if (formString.length() == 0) { // empty string
+ return formString;
+ } else {
+ return formString.substring(0, formString.length() - 1);
+ }
+ } else {
+ if (isBodyNullable) {
+ return obj == null ? "null" : json.getMapper().writeValueAsString(obj);
+ } else {
+ return obj == null ? "" : json.getMapper().writeValueAsString(obj);
+ }
+ }
+ } catch (Exception ex) {
+ throw new ApiException("Failed to perform serializeToString: " + ex.toString());
+ }
+ }
+
+ /**
+ * Deserialize response body to Java object according to the Content-Type.
+ *
+ * @param Type
+ * @param response Response
+ * @param returnType Return type
+ * @return Deserialize object
+ * @throws ApiException API exception
+ */
+ @SuppressWarnings("unchecked")
+ public T deserialize(Response response, GenericType returnType) throws ApiException {
+ if (response == null || returnType == null) {
+ return null;
+ }
+
+ if ("byte[]".equals(returnType.toString())) {
+ // Handle binary response (byte array).
+ return (T) response.readEntity(byte[].class);
+ } else if (returnType.getRawType() == File.class) {
+ // Handle file downloading.
+ T file = (T) downloadFileFromResponse(response);
+ return file;
+ }
+
+ // read the entity stream multiple times
+ response.bufferEntity();
+
+ return response.readEntity(returnType);
+ }
+
+ /**
+ * Download file from the given response.
+ *
+ * @param response Response
+ * @return File
+ * @throws ApiException If fail to read file content from response and write to disk
+ */
+ public File downloadFileFromResponse(Response response) throws ApiException {
+ try {
+ File file = prepareDownloadFile(response);
+ Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ return file;
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ }
+
+ /**
+ * Prepare the file for download from the response.
+ *
+ * @param response a {@link jakarta.ws.rs.core.Response} object.
+ * @return a {@link java.io.File} object.
+ * @throws java.io.IOException if any.
+ */
+ public File prepareDownloadFile(Response response) throws IOException {
+ String filename = null;
+ String contentDisposition = (String) response.getHeaders().getFirst("Content-Disposition");
+ if (contentDisposition != null && !"".equals(contentDisposition)) {
+ // Get filename from the Content-Disposition header.
+ Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
+ Matcher matcher = pattern.matcher(contentDisposition);
+ if (matcher.find())
+ filename = matcher.group(1);
+ }
+
+ String prefix;
+ String suffix = null;
+ if (filename == null) {
+ prefix = "download-";
+ suffix = "";
+ } else {
+ int pos = filename.lastIndexOf('.');
+ if (pos == -1) {
+ prefix = filename + "-";
+ } else {
+ prefix = filename.substring(0, pos) + "-";
+ suffix = filename.substring(pos);
+ }
+ // Files.createTempFile requires the prefix to be at least three characters long
+ if (prefix.length() < 3)
+ prefix = "download-";
+ }
+
+ if (tempFolderPath == null)
+ return Files.createTempFile(prefix, suffix).toFile();
+ else
+ return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile();
+ }
+
+ /**
+ * Invoke API by sending HTTP request with the given options.
+ *
+ * @param Type
+ * @param operation The qualified name of the operation
+ * @param path The sub-path of the HTTP URL
+ * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
+ * @param queryParams The query parameters
+ * @param body The request body object
+ * @param headerParams The header parameters
+ * @param cookieParams The cookie parameters
+ * @param formParams The form parameters
+ * @param accept The request's Accept header
+ * @param contentType The request's Content-Type header
+ * @param authNames The authentications to apply
+ * @param returnType The return type into which to deserialize the response
+ * @param isBodyNullable True if the body is nullable
+ * @return The response body in type of string
+ * @throws ApiException API exception
+ */
+ public ApiResponse invokeAPI(
+ String operation,
+ String path,
+ String method,
+ List queryParams,
+ Object body,
+ Map headerParams,
+ Map cookieParams,
+ Map formParams,
+ String accept,
+ String contentType,
+ String[] authNames,
+ GenericType returnType,
+ boolean isBodyNullable)
+ throws ApiException {
+
+ String targetURL;
+ List serverConfigurations;
+ if (serverIndex != null && (serverConfigurations = operationServers.get(operation)) != null) {
+ int index = operationServerIndex.getOrDefault(operation, serverIndex).intValue();
+ Map variables = operationServerVariables.getOrDefault(operation, serverVariables);
+ if (index < 0 || index >= serverConfigurations.size()) {
+ throw new ArrayIndexOutOfBoundsException(
+ String.format(
+ "Invalid index %d when selecting the host settings. Must be less than %d",
+ index, serverConfigurations.size()));
+ }
+ targetURL = serverConfigurations.get(index).URL(variables) + path;
+ } else {
+ targetURL = this.basePath + path;
+ }
+ // Not using `.target(targetURL).path(path)` below,
+ // to support (constant) query string in `path`, e.g. "/posts?draft=1"
+ WebTarget target = httpClient.target(targetURL);
+
+ if (queryParams != null) {
+ for (Pair queryParam : queryParams) {
+ if (queryParam.getValue() != null) {
+ target = target.queryParam(queryParam.getName(), escapeString(queryParam.getValue()));
+ }
+ }
+ }
+
+ Invocation.Builder invocationBuilder = target.request();
+
+ if (accept != null) {
+ invocationBuilder = invocationBuilder.accept(accept);
+ }
+
+ for (Entry entry : cookieParams.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ invocationBuilder = invocationBuilder.cookie(entry.getKey(), value);
+ }
+ }
+
+ for (Entry entry : defaultCookieMap.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ invocationBuilder = invocationBuilder.cookie(entry.getKey(), value);
+ }
+ }
+
+ Entity> entity = serialize(body, formParams, contentType, isBodyNullable);
+
+ // put all headers in one place
+ Map allHeaderParams = new HashMap<>(defaultHeaderMap);
+ allHeaderParams.putAll(headerParams);
+
+ if (authNames != null) {
+ // update different parameters (e.g. headers) for authentication
+ updateParamsForAuth(
+ authNames,
+ queryParams,
+ allHeaderParams,
+ cookieParams,
+ null,
+ method,
+ target.getUri());
+ }
+
+ for (Entry entry : allHeaderParams.entrySet()) {
+ String value = entry.getValue();
+ if (value != null) {
+ invocationBuilder = invocationBuilder.header(entry.getKey(), value);
+ }
+ }
+
+ Response response = null;
+
+ try {
+ response = sendRequest(method, invocationBuilder, entity);
+
+ final int statusCode = response.getStatusInfo().getStatusCode();
+
+ Map> responseHeaders = buildResponseHeaders(response);
+
+ if (statusCode == Status.NO_CONTENT.getStatusCode()) {
+ return new ApiResponse(statusCode, responseHeaders);
+ } else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
+ if (returnType == null) {
+ return new ApiResponse(statusCode, responseHeaders);
+ } else {
+ return new ApiResponse(statusCode, responseHeaders, deserialize(response, returnType));
+ }
+ } else {
+ String message = "error";
+ String respBody = null;
+ if (response.hasEntity()) {
+ try {
+ respBody = String.valueOf(response.readEntity(String.class));
+ message = respBody;
+ } catch (RuntimeException e) {
+ // e.printStackTrace();
+ }
+ }
+ throw new ApiException(
+ response.getStatus(), message, buildResponseHeaders(response), respBody);
+ }
+ } finally {
+ try {
+ response.close();
+ } catch (Exception e) {
+ // it's not critical, since the response object is local in method invokeAPI; that's fine,
+ // just continue
+ }
+ }
+ }
+
+ private Response sendRequest(String method, Invocation.Builder invocationBuilder, Entity> entity) {
+ Response response;
+ if ("POST".equals(method)) {
+ response = invocationBuilder.post(entity);
+ } else if ("PUT".equals(method)) {
+ response = invocationBuilder.put(entity);
+ } else if ("DELETE".equals(method)) {
+ if ("".equals(entity.getEntity())) {
+ response = invocationBuilder.method("DELETE");
+ } else {
+ response = invocationBuilder.method("DELETE", entity);
+ }
+ } else if ("PATCH".equals(method)) {
+ response = invocationBuilder.method("PATCH", entity);
+ } else {
+ response = invocationBuilder.method(method);
+ }
+ return response;
+ }
+
+ /**
+ * @deprecated Add qualified name of the operation as a first parameter.
+ */
+ @Deprecated
+ public ApiResponse invokeAPI(String path, String method, List queryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String accept, String contentType, String[] authNames, GenericType returnType, boolean isBodyNullable) throws ApiException {
+ return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, isBodyNullable);
+ }
+
+ /**
+ * Build the Client used to make HTTP requests.
+ *
+ * @return Client
+ */
+ protected Client buildHttpClient() {
+ // recreate the client config to pickup changes
+ clientConfig = getDefaultClientConfig();
+
+ ClientBuilder clientBuilder = ClientBuilder.newBuilder();
+ clientBuilder = clientBuilder.withConfig(clientConfig);
+ customizeClientBuilder(clientBuilder);
+ return clientBuilder.build();
+ }
+
+ /**
+ * Get the default client config.
+ *
+ * @return Client config
+ */
+ public ClientConfig getDefaultClientConfig() {
+ ClientConfig clientConfig = new ClientConfig();
+ clientConfig.register(MultiPartFeature.class);
+ clientConfig.register(json);
+ clientConfig.register(JacksonFeature.class);
+ clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
+ // turn off compliance validation to be able to send payloads with DELETE calls
+ clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
+ if (debugging) {
+ clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
+ clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
+ // Set logger to ALL
+ java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
+ } else {
+ // suppress warnings for payloads with DELETE calls:
+ java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
+ }
+
+ return clientConfig;
+ }
+
+ /**
+ * Customize the client builder.
+ *
+ * This method can be overridden to customize the API client. For example, this can be used to:
+ * 1. Set the hostname verifier to be used by the client to verify the endpoint's hostname
+ * against its identification information.
+ * 2. Set the client-side key store.
+ * 3. Set the SSL context that will be used when creating secured transport connections to
+ * server endpoints from web targets created by the client instance that is using this SSL context.
+ * 4. Set the client-side trust store.
+ *
+ * To completely disable certificate validation (at your own risk), you can
+ * override this method and invoke disableCertificateValidation(clientBuilder).
+ *
+ * @param clientBuilder a {@link jakarta.ws.rs.client.ClientBuilder} object.
+ */
+ protected void customizeClientBuilder(ClientBuilder clientBuilder) {
+ // No-op extension point
+ }
+
+ /**
+ * Disable X.509 certificate validation in TLS connections.
+ *
+ * Please note that trusting all certificates is extremely risky.
+ * This may be useful in a development environment with self-signed certificates.
+ *
+ * @param clientBuilder a {@link jakarta.ws.rs.client.ClientBuilder} object.
+ * @throws java.security.KeyManagementException if any.
+ * @throws java.security.NoSuchAlgorithmException if any.
+ */
+ protected void disableCertificateValidation(ClientBuilder clientBuilder) throws KeyManagementException, NoSuchAlgorithmException {
+ TrustManager[] trustAllCerts = new X509TrustManager[] {
+ new X509TrustManager() {
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType) {
+ }
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ }
+ }
+ };
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(null, trustAllCerts, new SecureRandom());
+ clientBuilder.sslContext(sslContext);
+ }
+
+ /**
+ * Build the response headers.
+ *
+ * @param response a {@link jakarta.ws.rs.core.Response} object.
+ * @return a {@link java.util.Map} of response headers.
+ */
+ protected Map> buildResponseHeaders(Response response) {
+ Map> responseHeaders = new HashMap<>();
+ for (Entry> entry: response.getHeaders().entrySet()) {
+ List values = entry.getValue();
+ List headers = new ArrayList<>();
+ for (Object o : values) {
+ headers.add(String.valueOf(o));
+ }
+ responseHeaders.put(entry.getKey(), headers);
+ }
+ return responseHeaders;
+ }
+
+ /**
+ * Update query and header parameters based on authentication settings.
+ *
+ * @param authNames The authentications to apply
+ * @param queryParams List of query parameters
+ * @param headerParams Map of header parameters
+ * @param cookieParams Map of cookie parameters
+ * @param method HTTP method (e.g. POST)
+ * @param uri HTTP URI
+ */
+ protected void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
+ Map cookieParams, String payload, String method, URI uri) throws ApiException {
+ for (String authName : authNames) {
+ Authentication auth = authentications.get(authName);
+ if (auth == null) {
+ continue;
+ }
+ auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
+ }
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiException.java
new file mode 100644
index 000000000000..df3b9b4b7efc
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiException.java
@@ -0,0 +1,96 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import java.util.Map;
+import java.util.List;
+
+/**
+ * API Exception
+ */
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class ApiException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ private int code = 0;
+ private Map> responseHeaders = null;
+ private String responseBody = null;
+
+ public ApiException() {}
+
+ public ApiException(Throwable throwable) {
+ super(throwable);
+ }
+
+ public ApiException(String message) {
+ super(message);
+ }
+
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
+ super(message, throwable);
+ this.code = code;
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
+
+ public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
+ this(message, (Throwable) null, code, responseHeaders, responseBody);
+ }
+
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
+ this(message, throwable, code, responseHeaders, null);
+ }
+
+ public ApiException(int code, Map> responseHeaders, String responseBody) {
+ this((String) null, (Throwable) null, code, responseHeaders, responseBody);
+ }
+
+ public ApiException(int code, String message) {
+ super(message);
+ this.code = code;
+ }
+
+ public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
+ this(code, message);
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
+
+ /**
+ * Get the HTTP status code.
+ *
+ * @return HTTP status code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Get the HTTP response headers.
+ *
+ * @return A map of list of string
+ */
+ public Map> getResponseHeaders() {
+ return responseHeaders;
+ }
+
+ /**
+ * Get the HTTP response body.
+ *
+ * @return Response body in the form of string
+ */
+ public String getResponseBody() {
+ return responseBody;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiResponse.java
new file mode 100644
index 000000000000..448fc9ef70f1
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ApiResponse.java
@@ -0,0 +1,74 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API response returned by API call.
+ *
+ * @param The type of data that is deserialized from response body
+ */
+public class ApiResponse {
+ private final int statusCode;
+ private final Map> headers;
+ private final T data;
+
+ /**
+ * @param statusCode The status code of HTTP response
+ * @param headers The headers of HTTP response
+ */
+ public ApiResponse(int statusCode, Map> headers) {
+ this(statusCode, headers, null);
+ }
+
+ /**
+ * @param statusCode The status code of HTTP response
+ * @param headers The headers of HTTP response
+ * @param data The object deserialized from response bod
+ */
+ public ApiResponse(int statusCode, Map> headers, T data) {
+ this.statusCode = statusCode;
+ this.headers = headers;
+ this.data = data;
+ }
+
+ /**
+ * Get the status code
+ *
+ * @return status code
+ */
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ /**
+ * Get the headers
+ *
+ * @return map of headers
+ */
+ public Map> getHeaders() {
+ return headers;
+ }
+
+ /**
+ * Get the data
+ *
+ * @return data
+ */
+ public T getData() {
+ return data;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Configuration.java
new file mode 100644
index 000000000000..ec6816306a69
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Configuration.java
@@ -0,0 +1,41 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class Configuration {
+ public static final String VERSION = "1.0.0";
+
+ private static ApiClient defaultApiClient = new ApiClient();
+
+ /**
+ * Get the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @return Default API client
+ */
+ public static ApiClient getDefaultApiClient() {
+ return defaultApiClient;
+ }
+
+ /**
+ * Set the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @param apiClient API client
+ */
+ public static void setDefaultApiClient(ApiClient apiClient) {
+ defaultApiClient = apiClient;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java
new file mode 100644
index 000000000000..c9e2d563c99a
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JSON.java
@@ -0,0 +1,262 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.json.JsonMapper;
+import org.openapitools.jackson.nullable.JsonNullableModule;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.openapitools.client.model.*;
+
+import java.text.DateFormat;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.ext.ContextResolver;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class JSON implements ContextResolver {
+ private ObjectMapper mapper;
+
+ public JSON() {
+ mapper = JsonMapper.builder()
+ .serializationInclusion(JsonInclude.Include.NON_NULL)
+ .configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
+ .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
+ .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
+ .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
+ .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
+ .defaultDateFormat(new RFC3339DateFormat())
+ .addModule(new JavaTimeModule())
+ .addModule(new JsonNullableModule())
+ .build();
+ }
+
+ /**
+ * Set the date format for JSON (de)serialization with Date properties.
+ * @param dateFormat Date format
+ */
+ public void setDateFormat(DateFormat dateFormat) {
+ mapper.setDateFormat(dateFormat);
+ }
+
+ @Override
+ public ObjectMapper getContext(Class> type) {
+ return mapper;
+ }
+
+ /**
+ * Get the object mapper
+ *
+ * @return object mapper
+ */
+ public ObjectMapper getMapper() { return mapper; }
+
+ /**
+ * Returns the target model class that should be used to deserialize the input data.
+ * The discriminator mappings are used to determine the target model class.
+ *
+ * @param node The input data.
+ * @param modelClass The class that contains the discriminator mappings.
+ */
+ public static Class> getClassForElement(JsonNode node, Class> modelClass) {
+ ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass);
+ if (cdm != null) {
+ return cdm.getClassForElement(node, new HashSet<>());
+ }
+ return null;
+ }
+
+ /**
+ * Helper class to register the discriminator mappings.
+ */
+ private static class ClassDiscriminatorMapping {
+ // The model class name.
+ Class> modelClass;
+ // The name of the discriminator property.
+ String discriminatorName;
+ // The discriminator mappings for a model class.
+ Map> discriminatorMappings;
+
+ // Constructs a new class discriminator.
+ ClassDiscriminatorMapping(Class> cls, String propertyName, Map> mappings) {
+ modelClass = cls;
+ discriminatorName = propertyName;
+ discriminatorMappings = new HashMap<>();
+ if (mappings != null) {
+ discriminatorMappings.putAll(mappings);
+ }
+ }
+
+ // Return the name of the discriminator property for this model class.
+ String getDiscriminatorPropertyName() {
+ return discriminatorName;
+ }
+
+ // Return the discriminator value or null if the discriminator is not
+ // present in the payload.
+ String getDiscriminatorValue(JsonNode node) {
+ // Determine the value of the discriminator property in the input data.
+ if (discriminatorName != null) {
+ // Get the value of the discriminator property, if present in the input payload.
+ node = node.get(discriminatorName);
+ if (node != null && node.isValueNode()) {
+ String discrValue = node.asText();
+ if (discrValue != null) {
+ return discrValue;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the target model class that should be used to deserialize the input data.
+ * This function can be invoked for anyOf/oneOf composed models with discriminator mappings.
+ * The discriminator mappings are used to determine the target model class.
+ *
+ * @param node The input data.
+ * @param visitedClasses The set of classes that have already been visited.
+ */
+ Class> getClassForElement(JsonNode node, Set> visitedClasses) {
+ if (visitedClasses.contains(modelClass)) {
+ // Class has already been visited.
+ return null;
+ }
+ // Determine the value of the discriminator property in the input data.
+ String discrValue = getDiscriminatorValue(node);
+ if (discrValue == null) {
+ return null;
+ }
+ Class> cls = discriminatorMappings.get(discrValue);
+ // It may not be sufficient to return this cls directly because that target class
+ // may itself be a composed schema, possibly with its own discriminator.
+ visitedClasses.add(modelClass);
+ for (Class> childClass : discriminatorMappings.values()) {
+ ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass);
+ if (childCdm == null) {
+ continue;
+ }
+ if (!discriminatorName.equals(childCdm.discriminatorName)) {
+ discrValue = getDiscriminatorValue(node);
+ if (discrValue == null) {
+ continue;
+ }
+ }
+ if (childCdm != null) {
+ // Recursively traverse the discriminator mappings.
+ Class> childDiscr = childCdm.getClassForElement(node, visitedClasses);
+ if (childDiscr != null) {
+ return childDiscr;
+ }
+ }
+ }
+ return cls;
+ }
+ }
+
+ /**
+ * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy.
+ *
+ * The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy,
+ * so it's not possible to use the instanceof keyword.
+ *
+ * @param modelClass A OpenAPI model class.
+ * @param inst The instance object.
+ */
+ public static boolean isInstanceOf(Class> modelClass, Object inst, Set> visitedClasses) {
+ if (modelClass.isInstance(inst)) {
+ // This handles the 'allOf' use case with single parent inheritance.
+ return true;
+ }
+ if (visitedClasses.contains(modelClass)) {
+ // This is to prevent infinite recursion when the composed schemas have
+ // a circular dependency.
+ return false;
+ }
+ visitedClasses.add(modelClass);
+
+ // Traverse the oneOf/anyOf composed schemas.
+ Map> descendants = modelDescendants.get(modelClass);
+ if (descendants != null) {
+ for (GenericType> childType : descendants.values()) {
+ if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * A map of discriminators for all model classes.
+ */
+ private static Map, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<>();
+
+ /**
+ * A map of oneOf/anyOf descendants for each model class.
+ */
+ private static Map, Map>> modelDescendants = new HashMap<>();
+
+ /**
+ * Register a model class discriminator.
+ *
+ * @param modelClass the model class
+ * @param discriminatorPropertyName the name of the discriminator property
+ * @param mappings a map with the discriminator mappings.
+ */
+ public static void registerDiscriminator(Class> modelClass, String discriminatorPropertyName, Map> mappings) {
+ ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings);
+ modelDiscriminators.put(modelClass, m);
+ }
+
+ /**
+ * Register the oneOf/anyOf descendants of the modelClass.
+ *
+ * @param modelClass the model class
+ * @param descendants a map of oneOf/anyOf descendants.
+ */
+ public static void registerDescendants(Class> modelClass, Map> descendants) {
+ modelDescendants.put(modelClass, descendants);
+ }
+
+ private static JSON json;
+
+ static
+ {
+ json = new JSON();
+ }
+
+ /**
+ * Get the default JSON instance.
+ *
+ * @return the default JSON instance
+ */
+ public static JSON getDefault() {
+ return json;
+ }
+
+ /**
+ * Set the default JSON instance.
+ *
+ * @param json JSON instance to be used
+ */
+ public static void setDefault(JSON json) {
+ JSON.json = json;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JavaTimeFormatter.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JavaTimeFormatter.java
new file mode 100644
index 000000000000..c8cc1343f174
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/JavaTimeFormatter.java
@@ -0,0 +1,64 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+package org.openapitools.client;
+
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+/**
+ * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class.
+ * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}.
+ */
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class JavaTimeFormatter {
+
+ private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+
+ /**
+ * Get the date format used to parse/format {@code OffsetDateTime} parameters.
+ * @return DateTimeFormatter
+ */
+ public DateTimeFormatter getOffsetDateTimeFormatter() {
+ return offsetDateTimeFormatter;
+ }
+
+ /**
+ * Set the date format used to parse/format {@code OffsetDateTime} parameters.
+ * @param offsetDateTimeFormatter {@code DateTimeFormatter}
+ */
+ public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) {
+ this.offsetDateTimeFormatter = offsetDateTimeFormatter;
+ }
+
+ /**
+ * Parse the given string into {@code OffsetDateTime} object.
+ * @param str String
+ * @return {@code OffsetDateTime}
+ */
+ public OffsetDateTime parseOffsetDateTime(String str) {
+ try {
+ return OffsetDateTime.parse(str, offsetDateTimeFormatter);
+ } catch (DateTimeParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ /**
+ * Format the given {@code OffsetDateTime} object into string.
+ * @param offsetDateTime {@code OffsetDateTime}
+ * @return {@code OffsetDateTime} in string format
+ */
+ public String formatOffsetDateTime(OffsetDateTime offsetDateTime) {
+ return offsetDateTimeFormatter.format(offsetDateTime);
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Pair.java
new file mode 100644
index 000000000000..7d0efd43223f
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/Pair.java
@@ -0,0 +1,57 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class Pair {
+ private String name = "";
+ private String value = "";
+
+ public Pair (String name, String value) {
+ setName(name);
+ setValue(value);
+ }
+
+ private void setName(String name) {
+ if (!isValidString(name)) {
+ return;
+ }
+
+ this.name = name;
+ }
+
+ private void setValue(String value) {
+ if (!isValidString(value)) {
+ return;
+ }
+
+ this.value = value;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ private boolean isValidString(String arg) {
+ if (arg == null) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339DateFormat.java
new file mode 100644
index 000000000000..e76558580992
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/RFC3339DateFormat.java
@@ -0,0 +1,58 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+package org.openapitools.client;
+
+import com.fasterxml.jackson.databind.util.StdDateFormat;
+
+import java.text.DateFormat;
+import java.text.FieldPosition;
+import java.text.ParsePosition;
+import java.util.Date;
+import java.text.DecimalFormat;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class RFC3339DateFormat extends DateFormat {
+ private static final long serialVersionUID = 1L;
+ private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
+
+ private final StdDateFormat fmt = new StdDateFormat()
+ .withTimeZone(TIMEZONE_Z)
+ .withColonInTimeZone(true);
+
+ public RFC3339DateFormat() {
+ this.calendar = new GregorianCalendar();
+ this.numberFormat = new DecimalFormat();
+ }
+
+ @Override
+ public Date parse(String source) {
+ return parse(source, new ParsePosition(0));
+ }
+
+ @Override
+ public Date parse(String source, ParsePosition pos) {
+ return fmt.parse(source, pos);
+ }
+
+ @Override
+ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
+ return fmt.format(date, toAppendTo, fieldPosition);
+ }
+
+ @Override
+ public Object clone() {
+ return super.clone();
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 000000000000..c2dda4d4dfbc
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,72 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import java.util.Map;
+
+/**
+ * Representing a Server configuration.
+ */
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class ServerConfiguration {
+ public String URL;
+ public String description;
+ public Map variables;
+
+ /**
+ * @param URL A URL to the target host.
+ * @param description A description of the host designated by the URL.
+ * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template.
+ */
+ public ServerConfiguration(String URL, String description, Map variables) {
+ this.URL = URL;
+ this.description = description;
+ this.variables = variables;
+ }
+
+ /**
+ * Format URL template using given variables.
+ *
+ * @param variables A map between a variable name and its value.
+ * @return Formatted URL.
+ */
+ public String URL(Map variables) {
+ String url = this.URL;
+
+ // go through variables and replace placeholders
+ for (Map.Entry variable: this.variables.entrySet()) {
+ String name = variable.getKey();
+ ServerVariable serverVariable = variable.getValue();
+ String value = serverVariable.defaultValue;
+
+ if (variables != null && variables.containsKey(name)) {
+ value = variables.get(name);
+ if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) {
+ throw new IllegalArgumentException("The variable " + name + " in the server URL has invalid value " + value + ".");
+ }
+ }
+ url = url.replace("{" + name + "}", value);
+ }
+ return url;
+ }
+
+ /**
+ * Format URL template using default server variables.
+ *
+ * @return Formatted URL.
+ */
+ public String URL() {
+ return URL(null);
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 000000000000..ca7b83416fe3
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,37 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class ServerVariable {
+ public String description;
+ public String defaultValue;
+ public HashSet enumValues = null;
+
+ /**
+ * @param description A description for the server variable.
+ * @param defaultValue The default value to use for substitution.
+ * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set.
+ */
+ public ServerVariable(String description, String defaultValue, HashSet enumValues) {
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.enumValues = enumValues;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/StringUtil.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/StringUtil.java
new file mode 100644
index 000000000000..6a5e16551a65
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/StringUtil.java
@@ -0,0 +1,83 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class StringUtil {
+ /**
+ * Check if the given array contains the given value (with case-insensitive comparison).
+ *
+ * @param array The array
+ * @param value The value to search
+ * @return true if the array contains the value
+ */
+ public static boolean containsIgnoreCase(String[] array, String value) {
+ for (String str : array) {
+ if (value == null && str == null) {
+ return true;
+ }
+ if (value != null && value.equalsIgnoreCase(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Join an array of strings with the given separator.
+ *
+ * Note: This might be replaced by utility method from commons-lang or guava someday
+ * if one of those libraries is added as dependency.
+ *
+ *
+ * @param array The array of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(String[] array, String separator) {
+ int len = array.length;
+ if (len == 0) {
+ return "";
+ }
+
+ StringBuilder out = new StringBuilder();
+ out.append(array[0]);
+ for (int i = 1; i < len; i++) {
+ out.append(separator).append(array[i]);
+ }
+ return out.toString();
+ }
+
+ /**
+ * Join a list of strings with the given separator.
+ *
+ * @param list The list of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(Collection list, String separator) {
+ Iterator iterator = list.iterator();
+ StringBuilder out = new StringBuilder();
+ if (iterator.hasNext()) {
+ out.append(iterator.next());
+ }
+ while (iterator.hasNext()) {
+ out.append(separator).append(iterator.next());
+ }
+ return out.toString();
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/api/DefaultApi.java
new file mode 100644
index 000000000000..3a30b83571cc
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/api/DefaultApi.java
@@ -0,0 +1,83 @@
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.Pair;
+
+import jakarta.ws.rs.core.GenericType;
+
+import org.openapitools.client.model.PostRequest;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class DefaultApi {
+ private ApiClient apiClient;
+
+ public DefaultApi() {
+ this(Configuration.getDefaultApiClient());
+ }
+
+ public DefaultApi(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * Get the API client
+ *
+ * @return API client
+ */
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ /**
+ * Set the API client
+ *
+ * @param apiClient an instance of API client
+ */
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ *
+ *
+ * @param postRequest (optional)
+ * @throws ApiException if fails to make API call
+ * @http.response.details
+
+ Status Code Description Response Headers
+ 200 OK -
+
+ */
+ public void rootPost(PostRequest postRequest) throws ApiException {
+ rootPostWithHttpInfo(postRequest);
+ }
+
+ /**
+ *
+ *
+ * @param postRequest (optional)
+ * @return ApiResponse<Void>
+ * @throws ApiException if fails to make API call
+ * @http.response.details
+
+ Status Code Description Response Headers
+ 200 OK -
+
+ */
+ public ApiResponse rootPostWithHttpInfo(PostRequest postRequest) throws ApiException {
+ String localVarAccept = apiClient.selectHeaderAccept();
+ String localVarContentType = apiClient.selectHeaderContentType("application/json");
+ return apiClient.invokeAPI("DefaultApi.rootPost", "/", "POST", new ArrayList<>(), postRequest,
+ new LinkedHashMap<>(), new LinkedHashMap<>(), new LinkedHashMap<>(), localVarAccept, localVarContentType,
+ null, null, false);
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
new file mode 100644
index 000000000000..a67bcb4f4bde
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
@@ -0,0 +1,79 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.auth;
+
+import org.openapitools.client.Pair;
+import org.openapitools.client.ApiException;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.List;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class ApiKeyAuth implements Authentication {
+ private final String location;
+ private final String paramName;
+
+ private String apiKey;
+ private String apiKeyPrefix;
+
+ public ApiKeyAuth(String location, String paramName) {
+ this.location = location;
+ this.paramName = paramName;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public String getParamName() {
+ return paramName;
+ }
+
+ public String getApiKey() {
+ return apiKey;
+ }
+
+ public void setApiKey(String apiKey) {
+ this.apiKey = apiKey;
+ }
+
+ public String getApiKeyPrefix() {
+ return apiKeyPrefix;
+ }
+
+ public void setApiKeyPrefix(String apiKeyPrefix) {
+ this.apiKeyPrefix = apiKeyPrefix;
+ }
+
+ @Override
+ public void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException {
+ if (apiKey == null) {
+ return;
+ }
+ String value;
+ if (apiKeyPrefix != null) {
+ value = apiKeyPrefix + " " + apiKey;
+ } else {
+ value = apiKey;
+ }
+ if ("query".equals(location)) {
+ queryParams.add(new Pair(paramName, value));
+ } else if ("header".equals(location)) {
+ headerParams.put(paramName, value);
+ } else if ("cookie".equals(location)) {
+ cookieParams.put(paramName, value);
+ }
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/Authentication.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/Authentication.java
new file mode 100644
index 000000000000..f127bb765c91
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/Authentication.java
@@ -0,0 +1,33 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.auth;
+
+import org.openapitools.client.Pair;
+import org.openapitools.client.ApiException;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.List;
+
+public interface Authentication {
+ /**
+ * Apply authentication settings to header and query params.
+ *
+ * @param queryParams List of query parameters
+ * @param headerParams Map of header parameters
+ * @param cookieParams Map of cookie parameters
+ */
+ void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException;
+
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
new file mode 100644
index 000000000000..1dfe233ee2e5
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
@@ -0,0 +1,55 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.auth;
+
+import org.openapitools.client.Pair;
+import org.openapitools.client.ApiException;
+
+import java.util.Base64;
+import java.nio.charset.StandardCharsets;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.List;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class HttpBasicAuth implements Authentication {
+ private String username;
+ private String password;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException {
+ if (username == null && password == null) {
+ return;
+ }
+ String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
+ headerParams.put("Authorization", "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8)));
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
new file mode 100644
index 000000000000..667b5ab85bdc
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
@@ -0,0 +1,62 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.auth;
+
+import org.openapitools.client.Pair;
+import org.openapitools.client.ApiException;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.List;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class HttpBearerAuth implements Authentication {
+ private final String scheme;
+ private String bearerToken;
+
+ public HttpBearerAuth(String scheme) {
+ this.scheme = scheme;
+ }
+
+ /**
+ * Gets the token, which together with the scheme, will be sent as the value of the Authorization header.
+ *
+ * @return The bearer token
+ */
+ public String getBearerToken() {
+ return bearerToken;
+ }
+
+ /**
+ * Sets the token, which together with the scheme, will be sent as the value of the Authorization header.
+ *
+ * @param bearerToken The bearer token to send in the Authorization header
+ */
+ public void setBearerToken(String bearerToken) {
+ this.bearerToken = bearerToken;
+ }
+
+ @Override
+ public void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException {
+ if(bearerToken == null) {
+ return;
+ }
+
+ headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken);
+ }
+
+ private static String upperCaseBearer(String scheme) {
+ return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme;
+ }
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
new file mode 100644
index 000000000000..7851c91cd7f6
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
@@ -0,0 +1,149 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import org.openapitools.client.ApiException;
+import java.util.Objects;
+import java.lang.reflect.Type;
+import java.util.Map;
+import jakarta.ws.rs.core.GenericType;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
+ */
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public abstract class AbstractOpenApiSchema {
+
+ // store the actual instance of the schema/object
+ private Object instance;
+
+ // is nullable
+ private Boolean isNullable;
+
+ // schema type (e.g. oneOf, anyOf)
+ private final String schemaType;
+
+ public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
+ this.schemaType = schemaType;
+ this.isNullable = isNullable;
+ }
+
+ /**
+ * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
+ *
+ * @return an instance of the actual schema/object
+ */
+ public abstract Map> getSchemas();
+
+ /**
+ * Get the actual instance
+ *
+ * @return an instance of the actual schema/object
+ */
+ @JsonValue
+ public Object getActualInstance() {return instance;}
+
+ /**
+ * Set the actual instance
+ *
+ * @param instance the actual instance of the schema/object
+ */
+ public void setActualInstance(Object instance) {this.instance = instance;}
+
+ /**
+ * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well
+ *
+ * @return an instance of the actual schema/object
+ */
+ public Object getActualInstanceRecursively() {
+ return getActualInstanceRecursively(this);
+ }
+
+ private Object getActualInstanceRecursively(AbstractOpenApiSchema object) {
+ if (object.getActualInstance() == null) {
+ return null;
+ } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) {
+ return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance());
+ } else {
+ return object.getActualInstance();
+ }
+ }
+
+ /**
+ * Get the schema type (e.g. anyOf, oneOf)
+ *
+ * @return the schema type
+ */
+ public String getSchemaType() {
+ return schemaType;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ").append(getClass()).append(" {\n");
+ sb.append(" instance: ").append(toIndentedString(instance)).append("\n");
+ sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n");
+ sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ AbstractOpenApiSchema a = (AbstractOpenApiSchema) o;
+ return Objects.equals(this.instance, a.instance) &&
+ Objects.equals(this.isNullable, a.isNullable) &&
+ Objects.equals(this.schemaType, a.schemaType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(instance, isNullable, schemaType);
+ }
+
+ /**
+ * Is nullable
+ *
+ * @return true if it's nullable
+ */
+ public Boolean isNullable() {
+ if (Boolean.TRUE.equals(isNullable)) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+
+
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/PostRequest.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/PostRequest.java
new file mode 100644
index 000000000000..b00424574894
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/PostRequest.java
@@ -0,0 +1,234 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Map;
+import java.util.HashMap;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Arrays;
+import java.util.Map;
+import org.openapitools.client.model.SchemaA;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.openapitools.client.JSON;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+
+import jakarta.ws.rs.core.GenericType;
+import jakarta.ws.rs.core.Response;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import org.openapitools.client.JSON;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+@JsonDeserialize(using = PostRequest.PostRequestDeserializer.class)
+@JsonSerialize(using = PostRequest.PostRequestSerializer.class)
+public class PostRequest extends AbstractOpenApiSchema {
+ private static final Logger log = Logger.getLogger(PostRequest.class.getName());
+
+ public static class PostRequestSerializer extends StdSerializer {
+ public PostRequestSerializer(Class t) {
+ super(t);
+ }
+
+ public PostRequestSerializer() {
+ this(null);
+ }
+
+ @Override
+ public void serialize(PostRequest value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
+ jgen.writeObject(value.getActualInstance());
+ }
+ }
+
+ public static class PostRequestDeserializer extends StdDeserializer {
+ public PostRequestDeserializer() {
+ this(PostRequest.class);
+ }
+
+ public PostRequestDeserializer(Class> vc) {
+ super(vc);
+ }
+
+ @Override
+ public PostRequest deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+ JsonNode tree = jp.readValueAsTree();
+ Object deserialized = null;
+ boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
+ int match = 0;
+ JsonToken token = tree.traverse(jp.getCodec()).nextToken();
+ // deserialize SchemaA
+ try {
+ boolean attemptParsing = true;
+ if (attemptParsing) {
+ deserialized = tree.traverse(jp.getCodec()).readValueAs(SchemaA.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ match++;
+ log.log(Level.FINER, "Input data matches schema 'SchemaA'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(Level.FINER, "Input data does not match schema 'SchemaA'", e);
+ }
+
+ // deserialize Map
+ try {
+ boolean attemptParsing = true;
+ attemptParsing = typeCoercion; //respect type coercion setting
+ if (!attemptParsing) {
+ }
+ if (attemptParsing) {
+ final TypeReference> ref = new TypeReference>(){};
+ deserialized = tree.traverse(jp.getCodec()).readValueAs(ref);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ match++;
+ log.log(Level.FINER, "Input data matches schema 'Map'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(Level.FINER, "Input data does not match schema 'Map'", e);
+ }
+
+ if (match == 1) {
+ PostRequest ret = new PostRequest();
+ ret.setActualInstance(deserialized);
+ return ret;
+ }
+ throw new IOException(String.format("Failed deserialization for PostRequest: %d classes match result, expected 1", match));
+ }
+
+ /**
+ * Handle deserialization of the 'null' value.
+ */
+ @Override
+ public PostRequest getNullValue(DeserializationContext ctxt) throws JsonMappingException {
+ throw new JsonMappingException(ctxt.getParser(), "PostRequest cannot be null");
+ }
+ }
+
+ // store a list of schema names defined in oneOf
+ public static final Map> schemas = new HashMap<>();
+
+ public PostRequest() {
+ super("oneOf", Boolean.FALSE);
+ }
+
+ public PostRequest(SchemaA o) {
+ super("oneOf", Boolean.FALSE);
+ setActualInstance(o);
+ }
+
+ public PostRequest(Map o) {
+ super("oneOf", Boolean.FALSE);
+ setActualInstance(o);
+ }
+
+ static {
+ schemas.put("Map", new GenericType>() {
+ });
+ schemas.put("SchemaA", new GenericType() {
+ });
+ JSON.registerDescendants(PostRequest.class, Collections.unmodifiableMap(schemas));
+ }
+
+ @Override
+ public Map> getSchemas() {
+ return PostRequest.schemas;
+ }
+
+ /**
+ * Set the instance that matches the oneOf child schema, check
+ * the instance parameter is valid against the oneOf child schemas:
+ * Map, SchemaA
+ *
+ * It could be an instance of the 'oneOf' schemas.
+ * The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
+ */
+ @Override
+ public void setActualInstance(Object instance) {
+ if (JSON.isInstanceOf(SchemaA.class, instance, new HashSet<>())) {
+ super.setActualInstance(instance);
+ return;
+ }
+
+ if (JSON.isInstanceOf(Map.class, instance, new HashSet<>())) {
+ super.setActualInstance(instance);
+ return;
+ }
+
+ throw new RuntimeException("Invalid instance type. Must be Map, SchemaA");
+ }
+
+ /**
+ * Get the actual instance, which can be the following:
+ * Map, SchemaA
+ *
+ * @return The actual instance (Map, SchemaA)
+ */
+ @Override
+ public Object getActualInstance() {
+ return super.getActualInstance();
+ }
+
+ /**
+ * Get the actual instance of `SchemaA`. If the actual instance is not `SchemaA`,
+ * the ClassCastException will be thrown.
+ *
+ * @return The actual instance of `SchemaA`
+ * @throws ClassCastException if the instance is not `SchemaA`
+ */
+ public SchemaA getSchemaA() throws ClassCastException {
+ return (SchemaA)super.getActualInstance();
+ }
+
+ /**
+ * Get the actual instance of `Map`. If the actual instance is not `Map`,
+ * the ClassCastException will be thrown.
+ *
+ * @return The actual instance of `Map`
+ * @throws ClassCastException if the instance is not `Map`
+ */
+ public Map getMapStringObject() throws ClassCastException {
+ return (Map)super.getActualInstance();
+ }
+
+}
+
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/SchemaA.java b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/SchemaA.java
new file mode 100644
index 000000000000..57c96163fb56
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/main/java/org/openapitools/client/model/SchemaA.java
@@ -0,0 +1,110 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import java.util.Objects;
+import java.util.Map;
+import java.util.HashMap;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Arrays;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.openapitools.client.JSON;
+
+
+/**
+ * SchemaA
+ */
+@JsonPropertyOrder({
+ SchemaA.JSON_PROPERTY_PROP_A
+})
+@JsonTypeName("schemaA")
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0-SNAPSHOT")
+public class SchemaA {
+ public static final String JSON_PROPERTY_PROP_A = "propA";
+ private String propA;
+
+ public SchemaA() {
+ }
+
+ public SchemaA propA(String propA) {
+ this.propA = propA;
+ return this;
+ }
+
+ /**
+ * Get propA
+ * @return propA
+ */
+ @jakarta.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_PROP_A)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+
+ public String getPropA() {
+ return propA;
+ }
+
+
+ @JsonProperty(JSON_PROPERTY_PROP_A)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public void setPropA(String propA) {
+ this.propA = propA;
+ }
+
+
+ /**
+ * Return true if this schemaA object is equal to o.
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ SchemaA schemaA = (SchemaA) o;
+ return Objects.equals(this.propA, schemaA.propA);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(propA);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class SchemaA {\n");
+ sb.append(" propA: ").append(toIndentedString(propA)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+}
+
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/api/DefaultApiTest.java b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/api/DefaultApiTest.java
new file mode 100644
index 000000000000..912eab008f54
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/api/DefaultApiTest.java
@@ -0,0 +1,46 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.*;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.model.PostRequest;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API tests for DefaultApi
+ */
+public class DefaultApiTest {
+
+ private final DefaultApi api = new DefaultApi();
+
+ /**
+ * @throws ApiException if the Api call fails
+ */
+ @Test
+ public void rootPostTest() throws ApiException {
+ //PostRequest postRequest = null;
+ //api.rootPost(postRequest);
+ // TODO: test validations
+ }
+
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/PostRequestTest.java b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/PostRequestTest.java
new file mode 100644
index 000000000000..9df9acfb2dab
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/PostRequestTest.java
@@ -0,0 +1,51 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Arrays;
+import java.util.Map;
+import org.openapitools.client.model.SchemaA;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Model tests for PostRequest
+ */
+public class PostRequestTest {
+ private final PostRequest model = new PostRequest();
+
+ /**
+ * Model tests for PostRequest
+ */
+ @Test
+ public void testPostRequest() {
+ // TODO: test PostRequest
+ }
+
+ /**
+ * Test the property 'propA'
+ */
+ @Test
+ public void propATest() {
+ // TODO: test propA
+ }
+
+}
diff --git a/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/SchemaATest.java b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/SchemaATest.java
new file mode 100644
index 000000000000..6af956784b65
--- /dev/null
+++ b/samples/client/petstore/java/jersey3-oneOf/src/test/java/org/openapitools/client/model/SchemaATest.java
@@ -0,0 +1,49 @@
+/*
+ * dummy
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Arrays;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Model tests for SchemaA
+ */
+public class SchemaATest {
+ private final SchemaA model = new SchemaA();
+
+ /**
+ * Model tests for SchemaA
+ */
+ @Test
+ public void testSchemaA() {
+ // TODO: test SchemaA
+ }
+
+ /**
+ * Test the property 'propA'
+ */
+ @Test
+ public void propATest() {
+ // TODO: test propA
+ }
+
+}