The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true|
-|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x
**jersey3**
HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x
**feign**
HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x
**webclient**
HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x
**resteasy**
HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x
**vertx**
HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x
**google-api-client**
HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x
**rest-assured**
HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+
**microprofile**
HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x
**apache-httpclient**
HTTP client: Apache httpclient 5.x
|okhttp-gson|
+|library|library template (sub-template) to use|
**jersey2**
HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x
**jersey3**
HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x
**feign**
HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.x
**okhttp-gson**
[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
**retrofit2**
HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)
**resttemplate**
HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x
**webclient**
HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x
**restclient**
HTTP client: Spring RestClient 6.1. JSON processing: Jackson 2.9.x
**resteasy**
HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x
**vertx**
HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x
**google-api-client**
HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x
**rest-assured**
HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8
**native**
HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+
**microprofile**
HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x
**apache-httpclient**
HTTP client: Apache httpclient 5.x
|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
@@ -84,7 +84,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|supportStreaming|Support streaming endpoint (beta)| |false|
|supportUrlQuery|Generate toUrlQueryString in POJO (default to true). Available on `native`, `apache-httpclient` libraries.| |false|
|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi|
-|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, libraries| |false|
+|useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, restclient, libraries| |false|
|useBeanValidation|Use BeanValidation API annotations| |false|
|useEnumCaseInsensitive|Use `equalsIgnoreCase` when String for enum comparison| |false|
|useGzipFeature|Send gzip-encoded requests| |false|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index 7fd122981af..ce8e200906f 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -83,6 +83,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String RESTEASY = "resteasy";
public static final String RESTTEMPLATE = "resttemplate";
public static final String WEBCLIENT = "webclient";
+ public static final String RESTCLIENT = "restclient";
public static final String REST_ASSURED = "rest-assured";
public static final String RETROFIT_2 = "retrofit2";
public static final String VERTX = "vertx";
@@ -216,7 +217,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
cliOptions.add(CliOption.newString(MICROPROFILE_FRAMEWORK, "Framework for microprofile. Possible values \"kumuluzee\""));
cliOptions.add(CliOption.newString(MICROPROFILE_MUTINY, "Whether to use async types for microprofile (currently only Smallrye Mutiny is supported)."));
- cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, libraries"));
+ cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, restclient, libraries"));
cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations));
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
cliOptions.add(CliOption.newBoolean(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT_DESC + " (only available for okhttp-gson library)", this.withAWSV4Signature));
@@ -238,6 +239,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)");
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
+ supportedLibraries.put(RESTCLIENT, "HTTP client: Spring RestClient 6.1. JSON processing: Jackson 2.9.x");
supportedLibraries.put(RESTEASY, "HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(VERTX, "HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
@@ -300,7 +302,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
@Override
public void processOpts() {
- if (WEBCLIENT.equals(getLibrary()) || NATIVE.equals(getLibrary())) {
+ if (WEBCLIENT.equals(getLibrary()) || NATIVE.equals(getLibrary()) || RESTCLIENT.equals(getLibrary())) {
dateLibrary = "java8";
} else if (MICROPROFILE.equals(getLibrary())) {
dateLibrary = "legacy";
@@ -508,7 +510,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
// helper for client library that allow to parse/format java.time.OffsetDateTime or org.threeten.bp.OffsetDateTime
- if (additionalProperties.containsKey("jsr310") && (isLibrary(WEBCLIENT) || isLibrary(VERTX) || isLibrary(RESTTEMPLATE) || isLibrary(RESTEASY) || isLibrary(MICROPROFILE) || isLibrary(JERSEY2) || isLibrary(JERSEY3) || isLibrary(APACHE))) {
+ if (additionalProperties.containsKey("jsr310") && (isLibrary(WEBCLIENT) || isLibrary(VERTX) || isLibrary(RESTTEMPLATE) || isLibrary(RESTEASY) || isLibrary(MICROPROFILE) || isLibrary(JERSEY2) || isLibrary(JERSEY3) || isLibrary(APACHE) || isLibrary(RESTCLIENT))) {
supportingFiles.add(new SupportingFile("JavaTimeFormatter.mustache", invokerFolder, "JavaTimeFormatter.java"));
}
@@ -556,7 +558,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
reservedWords.remove("file");
}
- if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || RETROFIT_2.equals(getLibrary()) || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
+ if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || RETROFIT_2.equals(getLibrary()) || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()) || RESTCLIENT.equals(getLibrary()))) {
supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java"));
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
@@ -659,6 +661,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
} else if (WEBCLIENT.equals(getLibrary())) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
+ } else if (RESTCLIENT.equals(getLibrary())) {
+ forceSerializationLibrary(SERIALIZATION_LIBRARY_JACKSON);
+ applyJakartaPackage();
} else if (VERTX.equals(getLibrary())) {
typeMapping.put("file", "AsyncFile");
importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile");
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache
new file mode 100644
index 00000000000..d6e0baeaee0
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/ApiClient.mustache
@@ -0,0 +1,750 @@
+package {{invokerPackage}};
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import java.util.function.Consumer;
+{{#openApiNullable}}
+import org.openapitools.jackson.nullable.JsonNullableModule;
+{{/openApiNullable}}
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.InvalidMediaTypeException;
+import org.springframework.http.MediaType;
+ import org.springframework.http.converter.HttpMessageConverter;
+ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+{{#withXml}}
+ import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
+{{/withXml}}
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.util.UriComponentsBuilder;
+import org.springframework.web.client.RestClient;
+import org.springframework.web.client.RestClient.ResponseSpec;
+import java.util.Optional;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TimeZone;
+
+import {{javaxPackage}}.annotation.Nullable;
+
+{{#jsr310}}
+import java.time.OffsetDateTime;
+{{/jsr310}}
+
+import {{invokerPackage}}.auth.Authentication;
+import {{invokerPackage}}.auth.HttpBasicAuth;
+import {{invokerPackage}}.auth.HttpBearerAuth;
+import {{invokerPackage}}.auth.ApiKeyAuth;
+{{#hasOAuthMethods}}
+import {{invokerPackage}}.auth.OAuth;
+{{/hasOAuthMethods}}
+
+{{>generatedAnnotation}}
+public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
+ public enum CollectionFormat {
+ CSV(","), TSV("\t"), SSV(" "), PIPES("|"), MULTI(null);
+
+ private final String separator;
+ CollectionFormat(String separator) {
+ this.separator = separator;
+ }
+
+ private String collectionToString(Collection> collection) {
+ return StringUtils.collectionToDelimitedString(collection, separator);
+ }
+ }
+
+ private final HttpHeaders defaultHeaders = new HttpHeaders();
+ private final MultiValueMap defaultCookies = new LinkedMultiValueMap<>();
+
+ private String basePath = "{{basePath}}";
+
+ private final RestClient restClient;
+ private final DateFormat dateFormat;
+ private final ObjectMapper objectMapper;
+
+ private Map authentications;
+
+
+ public ApiClient() {
+ this.dateFormat = createDefaultDateFormat();
+ this.objectMapper = createDefaultObjectMapper(this.dateFormat);
+ this.restClient = buildRestClient(this.objectMapper);
+ this.init();
+ }
+
+ public ApiClient(RestClient restClient) {
+ this(Optional.ofNullable(restClient).orElseGet(ApiClient::buildRestClient), createDefaultDateFormat());
+ }
+
+ public ApiClient(ObjectMapper mapper, DateFormat format) {
+ this(buildRestClient(mapper.copy()), format);
+ }
+
+ public ApiClient(RestClient restClient, ObjectMapper mapper, DateFormat format) {
+ this(Optional.ofNullable(restClient).orElseGet(() -> buildRestClient(mapper.copy())), format);
+ }
+
+ private ApiClient(RestClient restClient, DateFormat format) {
+ this.restClient = restClient;
+ this.dateFormat = format;
+ this.objectMapper = createDefaultObjectMapper(format);
+ this.init();
+ }
+
+ public static DateFormat createDefaultDateFormat() {
+ DateFormat dateFormat = new RFC3339DateFormat();
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dateFormat;
+ }
+
+ public static ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) {
+ if (null == dateFormat) {
+ dateFormat = createDefaultDateFormat();
+ }
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setDateFormat(dateFormat);
+ mapper.registerModule(new JavaTimeModule());
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ {{#openApiNullable}}
+ JsonNullableModule jnm = new JsonNullableModule();
+ mapper.registerModule(jnm);
+ {{/openApiNullable}}
+ return mapper;
+ }
+
+ protected void init() {
+ // Setup authentications (key: authentication name, value: authentication).
+ authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
+ authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{#isBasicBearer}}
+ authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
+ authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
+ authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
+ // Prevent the authentications from being modified.
+ authentications = Collections.unmodifiableMap(authentications);
+ }
+
+ /**
+ * Build the RestClientBuilder used to make RestClient.
+ * @param mapper ObjectMapper used for serialize/deserialize
+ * @return RestClient
+ */
+ public static RestClient.Builder buildRestClientBuilder(ObjectMapper mapper) {
+ {{#withXml}}
+ XmlMapper xmlMapper = new XmlMapper();
+ xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
+ {{#openApiNullable}}
+ xmlMapper.registerModule(new JsonNullableModule());
+ {{/openApiNullable}}
+
+ {{/withXml}}
+ Consumer>> messageConverters = converters -> {
+ converters.add(new MappingJackson2HttpMessageConverter(mapper));
+ {{#withXml}}
+ converters.add(new MappingJackson2XmlHttpMessageConverter(xmlMapper));
+ {{/withXml}}
+ };
+
+ return RestClient.builder().messageConverters(messageConverters);
+ }
+
+ /**
+ * Build the RestClientBuilder used to make RestClient.
+ * @return RestClient
+ */
+ public static RestClient.Builder buildRestClientBuilder() {
+ return buildRestClientBuilder(createDefaultObjectMapper(null));
+ }
+
+ /**
+ * Build the RestClient used to make HTTP requests.
+ * @param mapper ObjectMapper used for serialize/deserialize
+ * @return RestClient
+ */
+ public static RestClient buildRestClient(ObjectMapper mapper) {
+ return buildRestClientBuilder(mapper).build();
+ }
+
+ /**
+ * Build the RestClient used to make HTTP requests.
+ * @return RestClient
+ */
+ public static RestClient buildRestClient() {
+ return buildRestClientBuilder(createDefaultObjectMapper(null)).build();
+ }
+
+ /**
+ * Get the current base path
+ * @return String the base path
+ */
+ public String getBasePath() {
+ return basePath;
+ }
+
+ /**
+ * Set the base path, which should include the host
+ * @param basePath the base path
+ * @return ApiClient this client
+ */
+ public ApiClient setBasePath(String basePath) {
+ this.basePath = basePath;
+ return this;
+ }
+
+ /**
+ * Get authentications (key: authentication name, value: authentication).
+ * @return Map the currently configured authentication types
+ */
+ 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 access token for the first Bearer authentication.
+ * @param bearerToken Bearer token
+ */
+ public void setBearerToken(String bearerToken) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBearerAuth) {
+ ((HttpBearerAuth) auth).setBearerToken(bearerToken);
+ return;
+ }
+ }
+ throw new RuntimeException("No Bearer authentication configured!");
+ }
+
+ /**
+ * Helper method to set username for the first HTTP basic authentication.
+ * @param username the username
+ */
+ public void setUsername(String username) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setUsername(username);
+ return;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /**
+ * Helper method to set password for the first HTTP basic authentication.
+ * @param password the password
+ */
+ public void setPassword(String password) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setPassword(password);
+ return;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /**
+ * Helper method to set API key value for the first API key authentication.
+ * @param apiKey the API key
+ */
+ public void setApiKey(String apiKey) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof ApiKeyAuth) {
+ ((ApiKeyAuth) auth).setApiKey(apiKey);
+ return;
+ }
+ }
+ throw new RuntimeException("No API key authentication configured!");
+ }
+
+ /**
+ * Helper method to set API key prefix for the first API key authentication.
+ * @param apiKeyPrefix the API key prefix
+ */
+ public void setApiKeyPrefix(String apiKeyPrefix) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof ApiKeyAuth) {
+ ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
+ return;
+ }
+ }
+ throw new RuntimeException("No API key authentication configured!");
+ }
+
+ {{#hasOAuthMethods}}
+ /**
+ * Helper method to set access token for the first OAuth2 authentication.
+ * @param accessToken the access token
+ */
+ public void setAccessToken(String accessToken) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof OAuth) {
+ ((OAuth) auth).setAccessToken(accessToken);
+ return;
+ }
+ }
+ throw new RuntimeException("No OAuth2 authentication configured!");
+ }
+
+ {{/hasOAuthMethods}}
+ /**
+ * Set the User-Agent header's value (by adding to the default header map).
+ * @param userAgent the user agent string
+ * @return ApiClient this client
+ */
+ public ApiClient setUserAgent(String userAgent) {
+ addDefaultHeader("User-Agent", userAgent);
+ return this;
+ }
+
+ /**
+ * Add a default header.
+ *
+ * @param name The header's name
+ * @param value The header's value
+ * @return ApiClient this client
+ */
+ public ApiClient addDefaultHeader(String name, String value) {
+ if (defaultHeaders.containsKey(name)) {
+ defaultHeaders.remove(name);
+ }
+ defaultHeaders.add(name, value);
+ return this;
+ }
+
+ /**
+ * Add a default cookie.
+ *
+ * @param name The cookie's name
+ * @param value The cookie's value
+ * @return ApiClient this client
+ */
+ public ApiClient addDefaultCookie(String name, String value) {
+ if (defaultCookies.containsKey(name)) {
+ defaultCookies.remove(name);
+ }
+ defaultCookies.add(name, value);
+ return this;
+ }
+
+ /**
+ * Get the date format used to parse/format date parameters.
+ * @return DateFormat format
+ */
+ public DateFormat getDateFormat() {
+ return dateFormat;
+ }
+
+ /**
+ * Parse the given string into Date object.
+ */
+ public Date parseDate(String str) {
+ try {
+ return dateFormat.parse(str);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Format the given Date object into string.
+ */
+ public String formatDate(Date date) {
+ return dateFormat.format(date);
+ }
+
+ /**
+ * Get the ObjectMapper used to make HTTP requests.
+ * @return ObjectMapper objectMapper
+ */
+ public ObjectMapper getObjectMapper() {
+ return objectMapper;
+ }
+
+ /**
+ * Get the RestClient used to make HTTP requests.
+ * @return RestClient restClient
+ */
+ public RestClient getRestClient() {
+ return restClient;
+ }
+
+ /**
+ * Format the given parameter object into string.
+ * @param param the object to convert
+ * @return String the parameter represented as a String
+ */
+ public String parameterToString(Object param) {
+ if (param == null) {
+ return "";
+ } else if (param instanceof Date) {
+ return formatDate( (Date) param);
+ } {{#jsr310}}else if (param instanceof OffsetDateTime) {
+ return formatOffsetDateTime((OffsetDateTime) param);
+ } {{/jsr310}}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);
+ }
+ }
+
+ /**
+ * Converts a parameter to a {@link MultiValueMap} for use in REST requests
+ * @param collectionFormat The format to convert to
+ * @param name The name of the parameter
+ * @param value The parameter's value
+ * @return a Map containing the String value(s) of the input parameter
+ */
+ public MultiValueMap parameterToMultiValueMap(CollectionFormat collectionFormat, String name, Object value) {
+ final MultiValueMap params = new LinkedMultiValueMap<>();
+
+ if (name == null || name.isEmpty() || value == null) {
+ return params;
+ }
+
+ if(collectionFormat == null) {
+ collectionFormat = CollectionFormat.CSV;
+ }
+
+ if (value instanceof Map) {
+ @SuppressWarnings("unchecked")
+ final Map valuesMap = (Map) value;
+ for (final Entry entry : valuesMap.entrySet()) {
+ params.add(entry.getKey(), parameterToString(entry.getValue()));
+ }
+ return params;
+ }
+
+ Collection> valueCollection = null;
+ if (value instanceof Collection) {
+ valueCollection = (Collection>) value;
+ } else {
+ params.add(name, parameterToString(value));
+ return params;
+ }
+
+ if (valueCollection.isEmpty()){
+ return params;
+ }
+
+ if (collectionFormat.equals(CollectionFormat.MULTI)) {
+ for (Object item : valueCollection) {
+ params.add(name, parameterToString(item));
+ }
+ return params;
+ }
+
+ List values = new ArrayList<>();
+ for(Object o : valueCollection) {
+ values.add(parameterToString(o));
+ }
+ params.add(name, collectionFormat.collectionToString(values));
+
+ return params;
+ }
+
+ /**
+ * Check if the given {@code String} is a JSON MIME.
+ * @param mediaType the input MediaType
+ * @return boolean true if the MediaType represents JSON, false otherwise
+ */
+ public boolean isJsonMime(String mediaType) {
+ // "* / *" is default to JSON
+ if ("*/*".equals(mediaType)) {
+ return true;
+ }
+
+ try {
+ return isJsonMime(MediaType.parseMediaType(mediaType));
+ } catch (InvalidMediaTypeException e) {
+ }
+ return false;
+ }
+
+ /**
+ * Check if the given MIME is a JSON MIME.
+ * JSON MIME examples:
+ * application/json
+ * application/json; charset=UTF8
+ * APPLICATION/JSON
+ * @param mediaType the input MediaType
+ * @return boolean true if the MediaType represents JSON, false otherwise
+ */
+ public boolean isJsonMime(MediaType mediaType) {
+ return mediaType != null && (MediaType.APPLICATION_JSON.isCompatibleWith(mediaType) || mediaType.getSubtype().matches("^.*(\\+json|ndjson)[;]?\\s*$"));
+ }
+
+ /**
+ * Check if the given {@code String} is a Problem JSON MIME (RFC-7807).
+ * @param mediaType the input MediaType
+ * @return boolean true if the MediaType represents Problem JSON, false otherwise
+ */
+ public boolean isProblemJsonMime(String mediaType) {
+ return "application/problem+json".equalsIgnoreCase(mediaType);
+ }
+
+ /**
+ * 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 List The list of MediaTypes to use for the Accept header
+ */
+ public List selectHeaderAccept(String[] accepts) {
+ if (accepts.length == 0) {
+ return null;
+ }
+ for (String accept : accepts) {
+ MediaType mediaType = MediaType.parseMediaType(accept);
+ if (isJsonMime(mediaType) && !isProblemJsonMime(accept)) {
+ return Collections.singletonList(mediaType);
+ }
+ }
+ return MediaType.parseMediaTypes(StringUtils.arrayToCommaDelimitedString(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 MediaType The Content-Type header to use. If the given array is empty, null will be returned.
+ */
+ public MediaType selectHeaderContentType(String[] contentTypes) {
+ if (contentTypes.length == 0) {
+ return null;
+ }
+ for (String contentType : contentTypes) {
+ MediaType mediaType = MediaType.parseMediaType(contentType);
+ if (isJsonMime(mediaType)) {
+ return mediaType;
+ }
+ }
+ return MediaType.parseMediaType(contentTypes[0]);
+ }
+
+ /**
+ * Select the body to use for the request
+ *
+ * @param obj the body object
+ * @param formParams the form parameters
+ * @param contentType the content type of the request
+ * @return Object the selected body
+ */
+ protected Object selectBody(Object obj, MultiValueMap formParams, MediaType contentType) {
+ boolean isForm = MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType) || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType);
+ return isForm ? formParams : obj;
+ }
+
+ /**
+ * Invoke API by sending HTTP request with the given options.
+ *
+ * @param the return type to use
+ * @param path The sub-path of the HTTP URL
+ * @param method The request method
+ * @param pathParams The path parameters
+ * @param queryParams The query parameters
+ * @param body The request body object
+ * @param headerParams The header 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
+ * @return The response body in chosen type
+ */
+ public ResponseSpec invokeAPI(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException {
+ final RestClient.RequestBodySpec requestBuilder = prepareRequest(path, method, pathParams, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
+ return requestBuilder.retrieve();
+ }
+
+ /**
+ * Include queryParams in uriParams taking into account the paramName
+ * @param queryParams The query parameters
+ * @param uriParams The path parameters
+ * return templatized query string
+ */
+ private String generateQueryUri(MultiValueMap queryParams, Map uriParams) {
+ StringBuilder queryBuilder = new StringBuilder();
+ queryParams.forEach((name, values) -> {
+ if (CollectionUtils.isEmpty(values)) {
+ if (queryBuilder.length() != 0) {
+ queryBuilder.append('&');
+ }
+ queryBuilder.append(name);
+ } else {
+ int valueItemCounter = 0;
+ for (Object value : values) {
+ if (queryBuilder.length() != 0) {
+ queryBuilder.append('&');
+ }
+ queryBuilder.append(name);
+ if (value != null) {
+ String templatizedKey = name + valueItemCounter++;
+ uriParams.put(templatizedKey, value.toString());
+ queryBuilder.append('=').append("{").append(templatizedKey).append("}");
+ }
+ }
+ }
+ });
+ return queryBuilder.toString();
+ }
+
+ private RestClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map pathParams,
+ MultiValueMap queryParams, Object body, HttpHeaders headerParams,
+ MultiValueMap cookieParams, MultiValueMap formParams, List accept,
+ MediaType contentType, String[] authNames) {
+ updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
+
+ final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
+
+ String finalUri = builder.build(false).toUriString();
+ Map uriParams = new HashMap<>();
+ uriParams.putAll(pathParams);
+
+ if (queryParams != null && !queryParams.isEmpty()) {
+ //Include queryParams in uriParams taking into account the paramName
+ String queryUri = generateQueryUri(queryParams, uriParams);
+ //Append to finalUri the templatized query string like "?param1={param1Value}&.......
+ finalUri += "?" + queryUri;
+ }
+
+ final RestClient.RequestBodySpec requestBuilder = restClient.method(method).uri(finalUri, uriParams);
+
+ if (accept != null) {
+ requestBuilder.accept(accept.toArray(new MediaType[accept.size()]));
+ }
+ if(contentType != null) {
+ requestBuilder.contentType(contentType);
+ }
+
+ addHeadersToRequest(headerParams, requestBuilder);
+ addHeadersToRequest(defaultHeaders, requestBuilder);
+ addCookiesToRequest(cookieParams, requestBuilder);
+ addCookiesToRequest(defaultCookies, requestBuilder);
+
+ var selectedBody = selectBody(body, formParams, contentType);
+ if (selectedBody != null) {
+ requestBuilder.body(selectedBody);
+ }
+
+ return requestBuilder;
+ }
+
+ /**
+ * Add headers to the request that is being built
+ * @param headers The headers to add
+ * @param requestBuilder The current request
+ */
+ protected void addHeadersToRequest(HttpHeaders headers, RestClient.RequestBodySpec requestBuilder) {
+ for (Entry> entry : headers.entrySet()) {
+ List values = entry.getValue();
+ for(String value : values) {
+ if (value != null) {
+ requestBuilder.header(entry.getKey(), value);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add cookies to the request that is being built
+ *
+ * @param cookies The cookies to add
+ * @param requestBuilder The current request
+ */
+ protected void addCookiesToRequest(MultiValueMap cookies, RestClient.RequestBodySpec requestBuilder) {
+ if (!cookies.isEmpty()) {
+ requestBuilder.header("Cookie", buildCookieHeader(cookies));
+ }
+ }
+
+ /**
+ * Build cookie header. Keeps a single value per cookie (as per
+ * RFC6265 section 5.3).
+ *
+ * @param cookies map all cookies
+ * @return header string for cookies.
+ */
+ private String buildCookieHeader(MultiValueMap cookies) {
+ final StringBuilder cookieValue = new StringBuilder();
+ String delimiter = "";
+ for (final Map.Entry> entry : cookies.entrySet()) {
+ final String value = entry.getValue().get(entry.getValue().size() - 1);
+ cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), value));
+ delimiter = "; ";
+ }
+ return cookieValue.toString();
+ }
+
+ /**
+ * Update query and header parameters based on authentication settings.
+ *
+ * @param authNames The authentications to apply
+ * @param queryParams The query parameters
+ * @param headerParams The header parameters
+ * @param cookieParams the cookie parameters
+ */
+ protected void updateParamsForAuth(String[] authNames, MultiValueMap queryParams, HttpHeaders headerParams, MultiValueMap cookieParams) {
+ for (String authName : authNames) {
+ Authentication auth = authentications.get(authName);
+ if (auth == null) {
+ throw new RestClientException("Authentication undefined: " + authName);
+ }
+ auth.applyToParams(queryParams, headerParams, cookieParams);
+ }
+ }
+
+ /**
+ * Formats the specified collection path parameter to a string value.
+ *
+ * @param collectionFormat The collection format of the parameter.
+ * @param values The values of the parameter.
+ * @return String representation of the parameter
+ */
+ public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection> values) {
+ // create the value based on the collection format
+ if (CollectionFormat.MULTI.equals(collectionFormat)) {
+ // not valid for path params
+ return parameterToString(values);
+ }
+
+ // collectionFormat is assumed to be "csv" by default
+ if(collectionFormat == null) {
+ collectionFormat = CollectionFormat.CSV;
+ }
+
+ return collectionFormat.collectionToString(values);
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/README.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/README.mustache
new file mode 100644
index 00000000000..247b48b0e19
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/README.mustache
@@ -0,0 +1,248 @@
+# {{artifactId}}
+
+{{appName}}
+
+- API version: {{appVersion}}
+{{^hideGenerationTimestamp}}
+
+- Build date: {{generatedDate}}
+{{/hideGenerationTimestamp}}
+
+- Generator version: {{generatorVersion}}
+
+{{{appDescriptionWithNewLines}}}
+
+{{#infoUrl}}
+ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
+{{/infoUrl}}
+
+*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
+
+## Requirements
+
+Building the API client library requires:
+
+1. Java 17+
+{{#jersey2}}
+2. Maven (3.8.3+)/Gradle (7.2+)
+{{/jersey2}}
+{{^jersey2}}
+2. Maven/Gradle
+{{/jersey2}}
+
+## Installation
+
+To install the API client library to your local Maven repository, simply execute:
+
+```shell
+mvn clean install
+```
+
+To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
+
+```shell
+mvn clean deploy
+```
+
+Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
+
+### Maven users
+
+Add this dependency to your project's POM:
+
+```xml
+
+ {{{groupId}}}
+ {{{artifactId}}}
+ {{{artifactVersion}}}
+ compile
+
+```
+
+### Gradle users
+
+Add this dependency to your project's build file:
+
+```groovy
+ repositories {
+ mavenCentral() // Needed if the '{{{artifactId}}}' jar has been published to maven central.
+ mavenLocal() // Needed if the '{{{artifactId}}}' jar has been published to the local maven repo.
+ }
+
+ dependencies {
+ implementation "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
+ }
+```
+
+### Others
+
+At first generate the JAR by executing:
+
+```shell
+mvn clean package
+```
+
+Then manually install the following JARs:
+
+- `target/{{{artifactId}}}-{{{artifactVersion}}}.jar`
+- `target/lib/*.jar`
+
+{{#jersey2}}
+## Usage
+
+To add a HTTP proxy for the API client, use `ClientConfig`:
+```java
+{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
+import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.ClientProperties;
+import {{{invokerPackage}}}.*;
+import {{{package}}}.{{{classname}}};
+
+...
+
+ApiClient defaultClient = Configuration.getDefaultApiClient();
+ClientConfig clientConfig = defaultClient.getClientConfig();
+clientConfig.connectorProvider(new ApacheConnectorProvider());
+clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
+clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
+clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
+defaultClient.setClientConfig(clientConfig);
+
+{{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
+{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
+```
+
+{{/jersey2}}
+## Getting Started
+
+Please follow the [installation](#installation) instruction and execute the following Java code:
+
+```java
+{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
+import {{{invokerPackage}}}.*;
+import {{{invokerPackage}}}.auth.*;
+import {{{modelPackage}}}.*;
+import {{{package}}}.{{{classname}}};
+
+public class {{{classname}}}Example {
+
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("{{{basePath}}}");
+ {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
+ // Configure HTTP basic authorization: {{{name}}}
+ HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}");
+ {{{name}}}.setUsername("YOUR USERNAME");
+ {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasicBasic}}{{#isBasicBearer}}
+ // Configure HTTP bearer authorization: {{{name}}}
+ HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}");
+ {{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
+ // Configure API key authorization: {{{name}}}
+ ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}");
+ {{{name}}}.setApiKey("YOUR API KEY");
+ // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
+ //{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}}
+ // Configure OAuth2 access token for authorization: {{{name}}}
+ OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}");
+ {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}}{{#isHttpSignature}}
+ // Configure HTTP signature authorization: {{{name}}}
+ HttpSignatureAuth {{{name}}} = (HttpSignatureAuth) defaultClient.getAuthentication("{{{name}}}");
+ // All the HTTP signature parameters below should be customized to your environment.
+ // Configure the keyId
+ {{{name}}}.setKeyId("YOUR KEY ID");
+ // Configure the signature algorithm
+ {{{name}}}.setSigningAlgorithm(SigningAlgorithm.HS2019);
+ // Configure the specific cryptographic algorithm
+ {{{name}}}.setAlgorithm(Algorithm.ECDSA_SHA256);
+ // Configure the cryptographic algorithm parameters, if applicable
+ {{{name}}}.setAlgorithmParameterSpec(null);
+ // Set the cryptographic digest algorithm.
+ {{{name}}}.setDigestAlgorithm("SHA-256");
+ // Set the HTTP headers that should be included in the HTTP signature.
+ {{{name}}}.setHeaders(Arrays.asList("date", "host"));
+ // Set the private key used to sign the HTTP messages
+ {{{name}}}.setPrivateKey();{{/isHttpSignature}}
+ {{/authMethods}}
+ {{/hasAuthMethods}}
+
+ {{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
+ {{#allParams}}
+ {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
+ {{/allParams}}
+ try {
+ {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
+ System.out.println(result);{{/returnType}}
+ } catch (ApiException e) {
+ System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
+{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *{{basePath}}*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{commonPath}}{{path}} | {{summary}}
+{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
+
+## Documentation for Models
+
+{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md)
+{{/model}}{{/models}}
+
+
+## Documentation for Authorization
+
+{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
+{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
+{{#authMethods}}
+
+### {{name}}
+
+{{#isApiKey}}
+
+- **Type**: API key
+- **API key parameter name**: {{keyParamName}}
+- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
+{{/isApiKey}}
+{{#isBasicBasic}}
+
+- **Type**: HTTP basic authentication
+{{/isBasicBasic}}
+{{#isBasicBearer}}
+
+- **Type**: HTTP Bearer Token authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
+{{/isBasicBearer}}
+{{#isHttpSignature}}
+
+- **Type**: HTTP signature authentication
+{{/isHttpSignature}}
+{{#isOAuth}}
+
+- **Type**: OAuth
+- **Flow**: {{flow}}
+- **Authorization URL**: {{authorizationUrl}}
+- **Scopes**: {{^scopes}}N/A{{/scopes}}
+{{#scopes}} - {{scope}}: {{description}}
+{{/scopes}}
+{{/isOAuth}}
+
+{{/authMethods}}
+
+## Recommendation
+
+It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
+
+## Author
+
+{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
+{{/-last}}{{/apis}}{{/apiInfo}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache
new file mode 100644
index 00000000000..1475fc0f4ec
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache
@@ -0,0 +1,185 @@
+package {{package}};
+
+import {{invokerPackage}}.ApiClient;
+
+{{#imports}}import {{import}};
+{{/imports}}
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.web.client.RestClient.ResponseSpec;
+import org.springframework.web.client.RestClientResponseException;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+
+{{>generatedAnnotation}}
+{{#operations}}
+public class {{classname}} {
+ private ApiClient apiClient;
+
+ public {{classname}}() {
+ this(new ApiClient());
+ }
+
+ @Autowired
+ public {{classname}}(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ {{#operation}}
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#responses}} *
{{code}}{{#message}} - {{.}}{{/message}}
+{{/responses}}{{#allParams}} * @param {{paramName}} {{description}}{{^description}}The {{paramName}} parameter{{/description}}
+{{/allParams}}{{#returnType}} * @return {{.}}
+{{/returnType}} * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+{{#externalDocs}}
+ * {{description}}
+ * @see {{summary}} Documentation
+{{/externalDocs}}
+{{#isDeprecated}}
+ * @deprecated
+{{/isDeprecated}}
+ */
+ {{#isDeprecated}}
+ @Deprecated
+ {{/isDeprecated}}
+ private ResponseSpec {{operationId}}RequestCreation({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException {
+ Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
+ {{#allParams}}
+ {{#required}}
+ // verify the required parameter '{{paramName}}' is set
+ if ({{paramName}} == null) {
+ throw new RestClientResponseException("Missing the required parameter '{{paramName}}' when calling {{operationId}}", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null);
+ }
+ {{/required}}
+ {{/allParams}}
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+ {{#hasPathParams}}
+
+ {{#pathParams}}
+ pathParams.put("{{baseName}}", {{#collectionFormat}}apiClient.collectionPathParameterToString(ApiClient.CollectionFormat.valueOf("csv".toUpperCase()), {{/collectionFormat}}{{{paramName}}}{{#collectionFormat}}){{/collectionFormat}});
+ {{/pathParams}}
+ {{/hasPathParams}}
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+ {{#hasQueryParams}}
+
+ {{#queryParams}}{{#isExplode}}{{#hasVars}}{{#vars}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{.}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}.{{getter}}()));
+ {{/vars}}{{/hasVars}}{{^hasVars}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{.}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));
+ {{/hasVars}}{{/isExplode}}{{^isExplode}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{.}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));
+ {{/isExplode}}{{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}}
+
+ {{#headerParams}}
+ if ({{paramName}} != null)
+ headerParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{^-last}}
+ {{/-last}}
+ {{/headerParams}}
+ {{/hasHeaderParams}}
+ {{#hasCookieParams}}
+
+ {{#cookieParams}}
+ cookieParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{.}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));
+ {{/cookieParams}}
+ {{/hasCookieParams}}
+ {{#hasFormParams}}
+
+ {{#formParams}}
+ if ({{paramName}} != null)
+ formParams.add{{#collectionFormat}}All{{/collectionFormat}}("{{baseName}}", {{#isFile}}{{^collectionFormat}}{{#useAbstractionForFiles}}{{paramName}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}new FileSystemResource({{paramName}}){{/useAbstractionForFiles}}{{/collectionFormat}}{{/isFile}}{{#isFile}}{{#collectionFormat}}{{paramName}}.stream(){{^useAbstractionForFiles}}.map(FileSystemResource::new){{/useAbstractionForFiles}}.collect(Collectors.toList()){{/collectionFormat}}{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});
+ {{/formParams}}
+ {{/hasFormParams}}
+
+ final String[] localVarAccepts = { {{#hasProduces}}
+ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
+ {{/hasProduces}}};
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = { {{#hasConsumes}}
+ {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
+ {{/hasConsumes}}};
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
+
+ {{#returnType}}ParameterizedTypeReference<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}
+ return apiClient.invokeAPI("{{{path}}}", HttpMethod.{{httpMethod}}, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#responses}} *
{{code}}{{#message}} - {{.}}{{/message}}
+{{/responses}}{{#allParams}} * @param {{paramName}} {{description}}{{^description}}The {{paramName}} parameter{{/description}}
+{{/allParams}}{{#returnType}} * @return {{.}}
+{{/returnType}} * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+{{#externalDocs}}
+ * {{description}}
+ * @see {{summary}} Documentation
+{{/externalDocs}}
+ */
+ public {{#returnType}}{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException {
+ {{#returnType}}ParameterizedTypeReference<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}
+ {{#returnType}}return {{/returnType}}{{operationId}}RequestCreation({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).body(localVarReturnType);
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#responses}} *
{{code}}{{#message}} - {{.}}{{/message}}
+{{/responses}}{{#allParams}} * @param {{paramName}} {{description}}{{^description}}The {{paramName}} parameter{{/description}}
+{{/allParams}}{{#returnType}} * @return ResponseEntity<{{.}}>
+{{/returnType}} * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+{{#externalDocs}}
+ * {{description}}
+ * @see {{summary}} Documentation
+{{/externalDocs}}
+ */
+ public {{#returnType}}ResponseEntity<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}ResponseEntity{{/returnType}} {{operationId}}WithHttpInfo({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws RestClientResponseException {
+ {{#returnType}}ParameterizedTypeReference<{{#isResponseFile}}{{#useAbstractionForFiles}}org.springframework.core.io.Resource{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{returnType}}}{{/useAbstractionForFiles}}{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}> localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};{{/returnType}}
+ return {{operationId}}RequestCreation({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}).toEntity(localVarReturnType);
+ }
+
+ /**
+ * {{summary}}
+ * {{notes}}
+{{#responses}} *
+ * 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/echo_api/java/restclient/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/api/AuthApi.java
new file mode 100644
index 00000000000..cedca931923
--- /dev/null
+++ b/samples/client/echo_api/java/restclient/src/main/java/org/openapitools/client/api/AuthApi.java
@@ -0,0 +1,174 @@
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiClient;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.core.ParameterizedTypeReference;
+import org.springframework.web.client.RestClient.ResponseSpec;
+import org.springframework.web.client.RestClientResponseException;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+
+@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0-SNAPSHOT")
+public class AuthApi {
+ private ApiClient apiClient;
+
+ public AuthApi() {
+ this(new ApiClient());
+ }
+
+ @Autowired
+ public AuthApi(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ *
200 - Successful operation
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testAuthHttpBasicRequestCreation() throws RestClientResponseException {
+ Object postBody = null;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = { };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { "http_auth" };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/auth/http/basic", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ *
200 - Successful operation
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testAuthHttpBasic() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testAuthHttpBasicRequestCreation().body(localVarReturnType);
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ *
200 - Successful operation
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testAuthHttpBasicWithHttpInfo() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testAuthHttpBasicRequestCreation().toEntity(localVarReturnType);
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ *
200 - Successful operation
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testAuthHttpBasicWithResponseSpec() throws RestClientResponseException {
+ return testAuthHttpBasicRequestCreation();
+ }
+ /**
+ * To test HTTP bearer authentication
+ * To test HTTP bearer authentication
+ *
200 - Successful operation
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testAuthHttpBearerRequestCreation() throws RestClientResponseException {
+ Object postBody = null;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = { };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { "http_bearer_auth" };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/auth/http/bearer", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * To test HTTP bearer authentication
+ * To test HTTP bearer authentication
+ *
200 - Successful operation
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testAuthHttpBearer() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testAuthHttpBearerRequestCreation().body(localVarReturnType);
+ }
+
+ /**
+ * To test HTTP bearer authentication
+ * To test HTTP bearer authentication
+ *
200 - Successful operation
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testAuthHttpBearerWithHttpInfo() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testAuthHttpBearerRequestCreation().toEntity(localVarReturnType);
+ }
+
+ /**
+ * To test HTTP bearer authentication
+ * To test HTTP bearer authentication
+ *
200 - Successful operation
+ * @return File
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testBinaryGifRequestCreation() throws RestClientResponseException {
+ Object postBody = null;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "image/gif"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = { };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/binary/gif", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test binary (gif) response body
+ * Test binary (gif) response body
+ *
200 - Successful operation
+ * @return File
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public File testBinaryGif() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBinaryGifRequestCreation().body(localVarReturnType);
+ }
+
+ /**
+ * Test binary (gif) response body
+ * Test binary (gif) response body
+ *
200 - Successful operation
+ * @return ResponseEntity<File>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testBinaryGifWithHttpInfo() throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBinaryGifRequestCreation().toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test binary (gif) response body
+ * Test binary (gif) response body
+ *
200 - Successful operation
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testBinaryGifWithResponseSpec() throws RestClientResponseException {
+ return testBinaryGifRequestCreation();
+ }
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param body The body parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testBodyApplicationOctetstreamBinaryRequestCreation(File body) throws RestClientResponseException {
+ Object postBody = body;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "application/octet-stream"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/body/application/octetstream/binary", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param body The body parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testBodyApplicationOctetstreamBinary(File body) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyApplicationOctetstreamBinaryRequestCreation(body).body(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param body The body parameter
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testBodyApplicationOctetstreamBinaryWithHttpInfo(File body) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyApplicationOctetstreamBinaryRequestCreation(body).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param body The body parameter
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testBodyApplicationOctetstreamBinaryWithResponseSpec(File body) throws RestClientResponseException {
+ return testBodyApplicationOctetstreamBinaryRequestCreation(body);
+ }
+ /**
+ * Test array of binary in multipart mime
+ * Test array of binary in multipart mime
+ *
200 - Successful operation
+ * @param files The files parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testBodyMultipartFormdataArrayOfBinaryRequestCreation(List files) throws RestClientResponseException {
+ Object postBody = null;
+ // verify the required parameter 'files' is set
+ if (files == null) {
+ throw new RestClientResponseException("Missing the required parameter 'files' when calling testBodyMultipartFormdataArrayOfBinary", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null);
+ }
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ if (files != null)
+ formParams.addAll("files", files.stream().map(FileSystemResource::new).collect(Collectors.toList()));
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "multipart/form-data"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/body/application/octetstream/array_of_binary", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test array of binary in multipart mime
+ * Test array of binary in multipart mime
+ *
200 - Successful operation
+ * @param files The files parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testBodyMultipartFormdataArrayOfBinary(List files) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyMultipartFormdataArrayOfBinaryRequestCreation(files).body(localVarReturnType);
+ }
+
+ /**
+ * Test array of binary in multipart mime
+ * Test array of binary in multipart mime
+ *
200 - Successful operation
+ * @param files The files parameter
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testBodyMultipartFormdataArrayOfBinaryWithHttpInfo(List files) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyMultipartFormdataArrayOfBinaryRequestCreation(files).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test array of binary in multipart mime
+ * Test array of binary in multipart mime
+ *
200 - Successful operation
+ * @param files The files parameter
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testBodyMultipartFormdataArrayOfBinaryWithResponseSpec(List files) throws RestClientResponseException {
+ return testBodyMultipartFormdataArrayOfBinaryRequestCreation(files);
+ }
+ /**
+ * Test single binary in multipart mime
+ * Test single binary in multipart mime
+ *
200 - Successful operation
+ * @param myFile The myFile parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testBodyMultipartFormdataSingleBinaryRequestCreation(File myFile) throws RestClientResponseException {
+ Object postBody = null;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ if (myFile != null)
+ formParams.add("my-file", new FileSystemResource(myFile));
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "multipart/form-data"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/body/application/octetstream/single_binary", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test single binary in multipart mime
+ * Test single binary in multipart mime
+ *
200 - Successful operation
+ * @param myFile The myFile parameter
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testBodyMultipartFormdataSingleBinary(File myFile) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyMultipartFormdataSingleBinaryRequestCreation(myFile).body(localVarReturnType);
+ }
+
+ /**
+ * Test single binary in multipart mime
+ * Test single binary in multipart mime
+ *
200 - Successful operation
+ * @param myFile The myFile parameter
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testBodyMultipartFormdataSingleBinaryWithHttpInfo(File myFile) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testBodyMultipartFormdataSingleBinaryRequestCreation(myFile).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test single binary in multipart mime
+ * Test single binary in multipart mime
+ *
200 - Successful operation
+ * @param myFile The myFile parameter
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testBodyMultipartFormdataSingleBinaryWithResponseSpec(File myFile) throws RestClientResponseException {
+ return testBodyMultipartFormdataSingleBinaryRequestCreation(myFile);
+ }
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return Pet
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testEchoBodyAllOfPetRequestCreation(Pet pet) throws RestClientResponseException {
+ Object postBody = pet;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "application/json"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "application/json"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/echo/body/allOf/Pet", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return Pet
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public Pet testEchoBodyAllOfPet(Pet pet) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyAllOfPetRequestCreation(pet).body(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return ResponseEntity<Pet>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testEchoBodyAllOfPetWithHttpInfo(Pet pet) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyAllOfPetRequestCreation(pet).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testEchoBodyAllOfPetWithResponseSpec(Pet pet) throws RestClientResponseException {
+ return testEchoBodyAllOfPetRequestCreation(pet);
+ }
+ /**
+ * Test free form object
+ * Test free form object
+ *
200 - Successful operation
+ * @param body Free form object
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testEchoBodyFreeFormObjectResponseStringRequestCreation(Object body) throws RestClientResponseException {
+ Object postBody = body;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "application/json"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/echo/body/FreeFormObject/response_string", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test free form object
+ * Test free form object
+ *
200 - Successful operation
+ * @param body Free form object
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public String testEchoBodyFreeFormObjectResponseString(Object body) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyFreeFormObjectResponseStringRequestCreation(body).body(localVarReturnType);
+ }
+
+ /**
+ * Test free form object
+ * Test free form object
+ *
200 - Successful operation
+ * @param body Free form object
+ * @return ResponseEntity<String>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testEchoBodyFreeFormObjectResponseStringWithHttpInfo(Object body) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyFreeFormObjectResponseStringRequestCreation(body).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test free form object
+ * Test free form object
+ *
200 - Successful operation
+ * @param body Free form object
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testEchoBodyFreeFormObjectResponseStringWithResponseSpec(Object body) throws RestClientResponseException {
+ return testEchoBodyFreeFormObjectResponseStringRequestCreation(body);
+ }
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return Pet
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testEchoBodyPetRequestCreation(Pet pet) throws RestClientResponseException {
+ Object postBody = pet;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap cookieParams = new LinkedMultiValueMap<>();
+ final MultiValueMap formParams = new LinkedMultiValueMap<>();
+
+ final String[] localVarAccepts = {
+ "application/json"
+ };
+ final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+ final String[] localVarContentTypes = {
+ "application/json"
+ };
+ final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { };
+
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return apiClient.invokeAPI("/echo/body/Pet", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return Pet
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public Pet testEchoBodyPet(Pet pet) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyPetRequestCreation(pet).body(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return ResponseEntity<Pet>
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseEntity testEchoBodyPetWithHttpInfo(Pet pet) throws RestClientResponseException {
+ ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference<>() {};
+ return testEchoBodyPetRequestCreation(pet).toEntity(localVarReturnType);
+ }
+
+ /**
+ * Test body parameter(s)
+ * Test body parameter(s)
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return ResponseSpec
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ public ResponseSpec testEchoBodyPetWithResponseSpec(Pet pet) throws RestClientResponseException {
+ return testEchoBodyPetRequestCreation(pet);
+ }
+ /**
+ * Test empty response body
+ * Test empty response body
+ *
200 - Successful operation
+ * @param pet Pet object that needs to be added to the store
+ * @return String
+ * @throws RestClientResponseException if an error occurs while attempting to invoke the API
+ */
+ private ResponseSpec testEchoBodyPetResponseStringRequestCreation(Pet pet) throws RestClientResponseException {
+ Object postBody = pet;
+ // create path and map variables
+ final Map pathParams = new HashMap<>();
+
+ final MultiValueMap queryParams = new LinkedMultiValueMap<>();
+ final HttpHeaders headerParams = new HttpHeaders();
+ final MultiValueMap