> getAsyncResponseInterceptor() {
+ return asyncResponseInterceptor;
+ }
+
+ /**
+ * Set the read timeout for the http client.
+ *
+ * This is the value used by default for each request, though it can be
+ * overridden on a per-request basis with a request interceptor.
+ *
+ * @param readTimeout The read timeout used by default by the http client.
+ * Setting this value to null resets the timeout to an
+ * effectively infinite value.
+ * @return This object.
+ */
+ public ApiClient setReadTimeout(Duration readTimeout) {
+ this.readTimeout = readTimeout;
+ return this;
+ }
+
+ /**
+ * Get the read timeout that was set.
+ *
+ * @return The read timeout, or null if no timeout was set. Null represents
+ * an infinite wait time.
+ */
+ public Duration getReadTimeout() {
+ return readTimeout;
+ }
+ /**
+ * Sets the connect timeout (in milliseconds) for the http client.
+ *
+ * In the case where a new connection needs to be established, if
+ * the connection cannot be established within the given {@code
+ * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler)
+ * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or
+ * {@link HttpClient#sendAsync(HttpRequest,BodyHandler)
+ * HttpClient::sendAsync} completes exceptionally with an
+ * {@code HttpConnectTimeoutException}. If a new connection does not
+ * need to be established, for example if a connection can be reused
+ * from a previous request, then this timeout duration has no effect.
+ *
+ * @param connectTimeout connection timeout in milliseconds
+ *
+ * @return This object.
+ */
+ public ApiClient setConnectTimeout(Duration connectTimeout) {
+ this.connectTimeout = connectTimeout;
+ this.builder.connectTimeout(connectTimeout);
+ return this;
+ }
+
+ /**
+ * Get connection timeout (in milliseconds).
+ *
+ * @return Timeout in milliseconds
+ */
+ public Duration getConnectTimeout() {
+ return connectTimeout;
+ }
+}
diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiException.java
new file mode 100644
index 00000000000..94037ce979a
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiException.java
@@ -0,0 +1,90 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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.net.http.HttpHeaders;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class ApiException extends Exception {
+ private int code = 0;
+ private HttpHeaders 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, HttpHeaders responseHeaders, String responseBody) {
+ super(message, throwable);
+ this.code = code;
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
+
+ public ApiException(String message, int code, HttpHeaders responseHeaders, String responseBody) {
+ this(message, (Throwable) null, code, responseHeaders, responseBody);
+ }
+
+ public ApiException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) {
+ this(message, throwable, code, responseHeaders, null);
+ }
+
+ public ApiException(int code, HttpHeaders 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, HttpHeaders 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 Headers as an HttpHeaders object
+ */
+ public HttpHeaders 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/native-jakarta/src/main/java/org/openapitools/client/ApiResponse.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiResponse.java
new file mode 100644
index 00000000000..bebd7b21923
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ApiResponse.java
@@ -0,0 +1,59 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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 {
+ final private int statusCode;
+ final private Map> headers;
+ final private 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;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public Map> getHeaders() {
+ return headers;
+ }
+
+ public T getData() {
+ return data;
+ }
+}
diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/Configuration.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/Configuration.java
new file mode 100644
index 00000000000..311f2f23f1f
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/Configuration.java
@@ -0,0 +1,39 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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")
+public class Configuration {
+ 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/native-jakarta/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/JSON.java
new file mode 100644
index 00000000000..38564358737
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/JSON.java
@@ -0,0 +1,248 @@
+package org.openapitools.client;
+
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+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;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class JSON {
+ private ObjectMapper mapper;
+
+ public JSON() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
+ mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ mapper.setDateFormat(new RFC3339DateFormat());
+ mapper.registerModule(new JavaTimeModule());
+ JsonNullableModule jnm = new JsonNullableModule();
+ mapper.registerModule(jnm);
+ }
+
+ /**
+ * Set the date format for JSON (de)serialization with Date properties.
+ *
+ * @param dateFormat Date format
+ */
+ public void setDateFormat(DateFormat dateFormat) {
+ mapper.setDateFormat(dateFormat);
+ }
+
+ /**
+ * 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.
+ *
+ * @return the target model class.
+ */
+ 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.
+ *
+ * @return the target model class.
+ */
+ 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.
+ * @param visitedClasses The set of classes that have already been visited.
+ *
+ * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy.
+ */
+ 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 (Class> childType : descendants.values()) {
+ if (isInstanceOf(childType, 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/native-jakarta/src/main/java/org/openapitools/client/Pair.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/Pair.java
new file mode 100644
index 00000000000..3af4fd0353b
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/Pair.java
@@ -0,0 +1,57 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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")
+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/native-jakarta/src/main/java/org/openapitools/client/RFC3339DateFormat.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339DateFormat.java
new file mode 100644
index 00000000000..e36c77a670b
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/RFC3339DateFormat.java
@@ -0,0 +1,57 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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;
+
+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();
+ }
+}
\ No newline at end of file
diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ServerConfiguration.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ServerConfiguration.java
new file mode 100644
index 00000000000..59edc528a44
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ServerConfiguration.java
@@ -0,0 +1,58 @@
+package org.openapitools.client;
+
+import java.util.Map;
+
+/**
+ * Representing a Server configuration.
+ */
+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/native-jakarta/src/main/java/org/openapitools/client/ServerVariable.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ServerVariable.java
new file mode 100644
index 00000000000..c2f13e21666
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/ServerVariable.java
@@ -0,0 +1,23 @@
+package org.openapitools.client;
+
+import java.util.HashSet;
+
+/**
+ * Representing a Server Variable for server URL template substitution.
+ */
+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/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java
new file mode 100644
index 00000000000..c8b0a4e5cd4
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java
@@ -0,0 +1,708 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Pair;
+
+import java.io.File;
+import org.openapitools.client.model.ModelApiResponse;
+import org.openapitools.client.model.Pet;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+
+import java.util.ArrayList;
+import java.util.StringJoiner;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class PetApi {
+ private final HttpClient memberVarHttpClient;
+ private final ObjectMapper memberVarObjectMapper;
+ private final String memberVarBaseUri;
+ private final Consumer memberVarInterceptor;
+ private final Duration memberVarReadTimeout;
+ private final Consumer> memberVarResponseInterceptor;
+ private final Consumer> memberVarAsyncResponseInterceptor;
+
+ public PetApi() {
+ this(new ApiClient());
+ }
+
+ public PetApi(ApiClient apiClient) {
+ memberVarHttpClient = apiClient.getHttpClient();
+ memberVarObjectMapper = apiClient.getObjectMapper();
+ memberVarBaseUri = apiClient.getBaseUri();
+ memberVarInterceptor = apiClient.getRequestInterceptor();
+ memberVarReadTimeout = apiClient.getReadTimeout();
+ memberVarResponseInterceptor = apiClient.getResponseInterceptor();
+ memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
+ }
+
+ protected ApiException getApiException(String operationId, HttpResponse response) throws IOException {
+ String body = response.body() == null ? null : new String(response.body().readAllBytes());
+ String message = formatExceptionMessage(operationId, response.statusCode(), body);
+ return new ApiException(response.statusCode(), message, response.headers(), body);
+ }
+
+ private String formatExceptionMessage(String operationId, int statusCode, String body) {
+ if (body == null || body.isEmpty()) {
+ body = "[no body]";
+ }
+ return operationId + " call failed with: " + statusCode + " - " + body;
+ }
+
+ /**
+ * Add a new pet to the store
+ *
+ * @param pet Pet object that needs to be added to the store (required)
+ * @return Pet
+ * @throws ApiException if fails to make API call
+ */
+ public Pet addPet(Pet pet) throws ApiException {
+ ApiResponse localVarResponse = addPetWithHttpInfo(pet);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * Add a new pet to the store
+ *
+ * @param pet Pet object that needs to be added to the store (required)
+ * @return ApiResponse<Pet>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse addPetWithHttpInfo(Pet pet) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = addPetRequestBuilder(pet);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("addPet", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder addPetRequestBuilder(Pet pet) throws ApiException {
+ // verify the required parameter 'pet' is set
+ if (pet == null) {
+ throw new ApiException(400, "Missing the required parameter 'pet' when calling addPet");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet";
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Content-Type", "application/json");
+ localVarRequestBuilder.header("Accept", "application/xml, application/json");
+
+ try {
+ byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet);
+ localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Deletes a pet
+ *
+ * @param petId Pet id to delete (required)
+ * @param apiKey (optional)
+ * @throws ApiException if fails to make API call
+ */
+ public void deletePet(Long petId, String apiKey) throws ApiException {
+ deletePetWithHttpInfo(petId, apiKey);
+ }
+
+ /**
+ * Deletes a pet
+ *
+ * @param petId Pet id to delete (required)
+ * @param apiKey (optional)
+ * @return ApiResponse<Void>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = deletePetRequestBuilder(petId, apiKey);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("deletePet", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ null
+ );
+ } finally {
+ // Drain the InputStream
+ while (localVarResponse.body().read() != -1) {
+ // Ignore
+ }
+ localVarResponse.body().close();
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder deletePetRequestBuilder(Long petId, String apiKey) throws ApiException {
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling deletePet");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/{petId}"
+ .replace("{petId}", ApiClient.urlEncode(petId.toString()));
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ if (apiKey != null) {
+ localVarRequestBuilder.header("api_key", apiKey.toString());
+ }
+ localVarRequestBuilder.header("Accept", "application/json");
+
+ localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Finds Pets by status
+ * Multiple status values can be provided with comma separated strings
+ * @param status Status values that need to be considered for filter (required)
+ * @return List<Pet>
+ * @throws ApiException if fails to make API call
+ */
+ public List findPetsByStatus(List status) throws ApiException {
+ ApiResponse> localVarResponse = findPetsByStatusWithHttpInfo(status);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * Finds Pets by status
+ * Multiple status values can be provided with comma separated strings
+ * @param status Status values that need to be considered for filter (required)
+ * @return ApiResponse<List<Pet>>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = findPetsByStatusRequestBuilder(status);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("findPetsByStatus", localVarResponse);
+ }
+ return new ApiResponse>(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder findPetsByStatusRequestBuilder(List status) throws ApiException {
+ // verify the required parameter 'status' is set
+ if (status == null) {
+ throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/findByStatus";
+
+ List localVarQueryParams = new ArrayList<>();
+ localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status));
+
+ if (!localVarQueryParams.isEmpty()) {
+ StringJoiner queryJoiner = new StringJoiner("&");
+ localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
+ } else {
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+ }
+
+ localVarRequestBuilder.header("Accept", "application/xml, application/json");
+
+ localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Finds Pets by tags
+ * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ * @param tags Tags to filter by (required)
+ * @return List<Pet>
+ * @throws ApiException if fails to make API call
+ * @deprecated
+ */
+ @Deprecated
+ public List findPetsByTags(List tags) throws ApiException {
+ ApiResponse> localVarResponse = findPetsByTagsWithHttpInfo(tags);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * Finds Pets by tags
+ * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ * @param tags Tags to filter by (required)
+ * @return ApiResponse<List<Pet>>
+ * @throws ApiException if fails to make API call
+ * @deprecated
+ */
+ @Deprecated
+ public ApiResponse> findPetsByTagsWithHttpInfo(List tags) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = findPetsByTagsRequestBuilder(tags);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("findPetsByTags", localVarResponse);
+ }
+ return new ApiResponse>(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder findPetsByTagsRequestBuilder(List tags) throws ApiException {
+ // verify the required parameter 'tags' is set
+ if (tags == null) {
+ throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/findByTags";
+
+ List localVarQueryParams = new ArrayList<>();
+ localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags));
+
+ if (!localVarQueryParams.isEmpty()) {
+ StringJoiner queryJoiner = new StringJoiner("&");
+ localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue()));
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString()));
+ } else {
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+ }
+
+ localVarRequestBuilder.header("Accept", "application/xml, application/json");
+
+ localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Find pet by ID
+ * Returns a single pet
+ * @param petId ID of pet to return (required)
+ * @return Pet
+ * @throws ApiException if fails to make API call
+ */
+ public Pet getPetById(Long petId) throws ApiException {
+ ApiResponse localVarResponse = getPetByIdWithHttpInfo(petId);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * Find pet by ID
+ * Returns a single pet
+ * @param petId ID of pet to return (required)
+ * @return ApiResponse<Pet>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse getPetByIdWithHttpInfo(Long petId) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = getPetByIdRequestBuilder(petId);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("getPetById", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder getPetByIdRequestBuilder(Long petId) throws ApiException {
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetById");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/{petId}"
+ .replace("{petId}", ApiClient.urlEncode(petId.toString()));
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Accept", "application/xml, application/json");
+
+ localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Update an existing pet
+ *
+ * @param pet Pet object that needs to be added to the store (required)
+ * @return Pet
+ * @throws ApiException if fails to make API call
+ * API documentation for the updatePet operation
+ * @see Update an existing pet Documentation
+ */
+ public Pet updatePet(Pet pet) throws ApiException {
+ ApiResponse localVarResponse = updatePetWithHttpInfo(pet);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * Update an existing pet
+ *
+ * @param pet Pet object that needs to be added to the store (required)
+ * @return ApiResponse<Pet>
+ * @throws ApiException if fails to make API call
+ * API documentation for the updatePet operation
+ * @see Update an existing pet Documentation
+ */
+ public ApiResponse updatePetWithHttpInfo(Pet pet) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = updatePetRequestBuilder(pet);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("updatePet", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder updatePetRequestBuilder(Pet pet) throws ApiException {
+ // verify the required parameter 'pet' is set
+ if (pet == null) {
+ throw new ApiException(400, "Missing the required parameter 'pet' when calling updatePet");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet";
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Content-Type", "application/json");
+ localVarRequestBuilder.header("Accept", "application/xml, application/json");
+
+ try {
+ byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(pet);
+ localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Updates a pet in the store with form data
+ *
+ * @param petId ID of pet that needs to be updated (required)
+ * @param name Updated name of the pet (optional)
+ * @param status Updated status of the pet (optional)
+ * @throws ApiException if fails to make API call
+ */
+ public void updatePetWithForm(Long petId, String name, String status) throws ApiException {
+ updatePetWithFormWithHttpInfo(petId, name, status);
+ }
+
+ /**
+ * Updates a pet in the store with form data
+ *
+ * @param petId ID of pet that needs to be updated (required)
+ * @param name Updated name of the pet (optional)
+ * @param status Updated status of the pet (optional)
+ * @return ApiResponse<Void>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = updatePetWithFormRequestBuilder(petId, name, status);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("updatePetWithForm", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ null
+ );
+ } finally {
+ // Drain the InputStream
+ while (localVarResponse.body().read() != -1) {
+ // Ignore
+ }
+ localVarResponse.body().close();
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder updatePetWithFormRequestBuilder(Long petId, String name, String status) throws ApiException {
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling updatePetWithForm");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/{petId}"
+ .replace("{petId}", ApiClient.urlEncode(petId.toString()));
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Accept", "application/json");
+
+ localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * uploads an image
+ *
+ * @param petId ID of pet to update (required)
+ * @param additionalMetadata Additional data to pass to server (optional)
+ * @param _file file to upload (optional)
+ * @return ModelApiResponse
+ * @throws ApiException if fails to make API call
+ */
+ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _file) throws ApiException {
+ ApiResponse localVarResponse = uploadFileWithHttpInfo(petId, additionalMetadata, _file);
+ return localVarResponse.getData();
+ }
+
+ /**
+ * uploads an image
+ *
+ * @param petId ID of pet to update (required)
+ * @param additionalMetadata Additional data to pass to server (optional)
+ * @param _file file to upload (optional)
+ * @return ApiResponse<ModelApiResponse>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = uploadFileRequestBuilder(petId, additionalMetadata, _file);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("uploadFile", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream
+ );
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder uploadFileRequestBuilder(Long petId, String additionalMetadata, File _file) throws ApiException {
+ // verify the required parameter 'petId' is set
+ if (petId == null) {
+ throw new ApiException(400, "Missing the required parameter 'petId' when calling uploadFile");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/pet/{petId}/uploadImage"
+ .replace("{petId}", ApiClient.urlEncode(petId.toString()));
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Accept", "application/json");
+
+ localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+}
diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java
new file mode 100644
index 00000000000..125c604bc2b
--- /dev/null
+++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/StoreApi.java
@@ -0,0 +1,366 @@
+/*
+ * OpenAPI Petstore
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
+ *
+ * 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.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Pair;
+
+import org.openapitools.client.model.Order;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+
+import java.util.ArrayList;
+import java.util.StringJoiner;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class StoreApi {
+ private final HttpClient memberVarHttpClient;
+ private final ObjectMapper memberVarObjectMapper;
+ private final String memberVarBaseUri;
+ private final Consumer memberVarInterceptor;
+ private final Duration memberVarReadTimeout;
+ private final Consumer> memberVarResponseInterceptor;
+ private final Consumer> memberVarAsyncResponseInterceptor;
+
+ public StoreApi() {
+ this(new ApiClient());
+ }
+
+ public StoreApi(ApiClient apiClient) {
+ memberVarHttpClient = apiClient.getHttpClient();
+ memberVarObjectMapper = apiClient.getObjectMapper();
+ memberVarBaseUri = apiClient.getBaseUri();
+ memberVarInterceptor = apiClient.getRequestInterceptor();
+ memberVarReadTimeout = apiClient.getReadTimeout();
+ memberVarResponseInterceptor = apiClient.getResponseInterceptor();
+ memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
+ }
+
+ protected ApiException getApiException(String operationId, HttpResponse response) throws IOException {
+ String body = response.body() == null ? null : new String(response.body().readAllBytes());
+ String message = formatExceptionMessage(operationId, response.statusCode(), body);
+ return new ApiException(response.statusCode(), message, response.headers(), body);
+ }
+
+ private String formatExceptionMessage(String operationId, int statusCode, String body) {
+ if (body == null || body.isEmpty()) {
+ body = "[no body]";
+ }
+ return operationId + " call failed with: " + statusCode + " - " + body;
+ }
+
+ /**
+ * Delete purchase order by ID
+ * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ * @param orderId ID of the order that needs to be deleted (required)
+ * @throws ApiException if fails to make API call
+ */
+ public void deleteOrder(String orderId) throws ApiException {
+ deleteOrderWithHttpInfo(orderId);
+ }
+
+ /**
+ * Delete purchase order by ID
+ * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ * @param orderId ID of the order that needs to be deleted (required)
+ * @return ApiResponse<Void>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse deleteOrderWithHttpInfo(String orderId) throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = deleteOrderRequestBuilder(orderId);
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("deleteOrder", localVarResponse);
+ }
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ null
+ );
+ } finally {
+ // Drain the InputStream
+ while (localVarResponse.body().read() != -1) {
+ // Ignore
+ }
+ localVarResponse.body().close();
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder deleteOrderRequestBuilder(String orderId) throws ApiException {
+ // verify the required parameter 'orderId' is set
+ if (orderId == null) {
+ throw new ApiException(400, "Missing the required parameter 'orderId' when calling deleteOrder");
+ }
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/store/order/{orderId}"
+ .replace("{orderId}", ApiClient.urlEncode(orderId.toString()));
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Accept", "application/json");
+
+ localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+ /**
+ * Returns pet inventories by status
+ * Returns a map of status codes to quantities
+ * @return Map<String, Integer>
+ * @throws ApiException if fails to make API call
+ */
+ public Map getInventory() throws ApiException {
+ ApiResponse