diff --git a/bin/configs/java-okhttp-gson-nextgen.yaml b/bin/configs/java-okhttp-gson-nextgen.yaml
deleted file mode 100644
index 724edc9d9083..000000000000
--- a/bin/configs/java-okhttp-gson-nextgen.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-generatorName: java
-outputDir: samples/client/petstore/java/okhttp-gson-nextgen
-library: okhttp-gson-nextgen
-inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml
-templateDir: modules/openapi-generator/src/main/resources/Java
-additionalProperties:
- artifactId: petstore-okhttp-gson-nextgen
- hideGenerationTimestamp: "true"
diff --git a/bin/configs/java-okhttp-gson.yaml b/bin/configs/java-okhttp-gson.yaml
index c71c509aa28e..88b87d75c4aa 100644
--- a/bin/configs/java-okhttp-gson.yaml
+++ b/bin/configs/java-okhttp-gson.yaml
@@ -1,7 +1,7 @@
generatorName: java
outputDir: samples/client/petstore/java/okhttp-gson
library: okhttp-gson
-inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
+inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: petstore-okhttp-gson
diff --git a/docs/generators/java.md b/docs/generators/java.md
index c33081e2df54..811277beed73 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -51,7 +51,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|invokerPackage|root package for generated code| |org.openapitools.client|
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|
**true** Use Java 8 classes such as Base64 **false** Various third party libraries as needed |true|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|**true** 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|**jersey1** HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead. **jersey2** HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x **feign** HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.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'. **okhttp-gson-nextgen** HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x.'. Better support for oneOf/anyOf with breaking changes. Will replace `okhttp-gson` in the 6.0.0 release. IMPORTANT: this may subject to breaking changes without further notice. **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 **apache-httpclient** HTTP client: Apache httpclient 4.x |okhttp-gson|
+|library|library template (sub-template) to use|**jersey1** HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libraries instead. **jersey2** HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x **feign** HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.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 **apache-httpclient** HTTP client: Apache httpclient 4.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|
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 8476e2d88b7b..b090cbd62253 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
@@ -76,7 +76,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String JERSEY2 = "jersey2";
public static final String NATIVE = "native";
public static final String OKHTTP_GSON = "okhttp-gson";
- public static final String OKHTTP_GSON_NEXTGEN = "okhttp-gson-nextgen";
public static final String RESTEASY = "resteasy";
public static final String RESTTEMPLATE = "resttemplate";
public static final String WEBCLIENT = "webclient";
@@ -165,7 +164,6 @@ public JavaClientCodegen() {
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.");
supportedLibraries.put(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'.");
- supportedLibraries.put(OKHTTP_GSON_NEXTGEN, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x.'. Better support for oneOf/anyOf with breaking changes. Will replace `okhttp-gson` in the 6.0.0 release. IMPORTANT: this may subject to breaking changes without further notice.");
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");
@@ -421,7 +419,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("ParamExpander.mustache", invokerFolder, "ParamExpander.java"));
supportingFiles.add(new SupportingFile("EncodingUtils.mustache", invokerFolder, "EncodingUtils.java"));
supportingFiles.add(new SupportingFile("auth/DefaultApi20Impl.mustache", authFolder, "DefaultApi20Impl.java"));
- } else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary()) || OKHTTP_GSON_NEXTGEN.equals(getLibrary())) {
+ } else if (OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) {
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
@@ -429,7 +427,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java"));
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
supportingFiles.add(new SupportingFile("GzipRequestInterceptor.mustache", invokerFolder, "GzipRequestInterceptor.java"));
- if (OKHTTP_GSON_NEXTGEN.equals(getLibrary())) {
+ if (OKHTTP_GSON.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("AbstractOpenApiSchema.mustache", modelsFolder, "AbstractOpenApiSchema.java"));
}
@@ -589,7 +587,7 @@ public void processOpts() {
// has OAuth defined
if (ProcessUtils.hasOAuthMethods(openAPI)) {
// for okhttp-gson (default), check to see if OAuth is defined and included OAuth-related files accordingly
- if ((OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary())) || OKHTTP_GSON_NEXTGEN.equals(getLibrary())) {
+ if ((OKHTTP_GSON.equals(getLibrary()) || StringUtils.isEmpty(getLibrary()))) {
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
}
@@ -890,7 +888,7 @@ public Map postProcessModels(Map objs) {
CodegenModel cm = (CodegenModel) mo.get("model");
cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList());
- if (JERSEY2.equals(getLibrary()) || NATIVE.equals(getLibrary()) || OKHTTP_GSON_NEXTGEN.equals(getLibrary())) {
+ if (JERSEY2.equals(getLibrary()) || NATIVE.equals(getLibrary()) || OKHTTP_GSON.equals(getLibrary())) {
cm.getVendorExtensions().put("x-implements", new ArrayList());
if (cm.oneOf != null && !cm.oneOf.isEmpty() && cm.oneOf.contains("ModelNull")) {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiCallback.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiCallback.mustache
deleted file mode 100644
index 53b6a7b8e34f..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiCallback.mustache
+++ /dev/null
@@ -1,51 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import java.io.IOException;
-
-import java.util.Map;
-import java.util.List;
-
-/**
- * Callback for asynchronous API call.
- *
- * @param The return type
- */
-public interface ApiCallback {
- /**
- * This is called when the API call fails.
- *
- * @param e The exception causing the failure
- * @param statusCode Status code of the response if available, otherwise it would be 0
- * @param responseHeaders Headers of the response if available, otherwise it would be null
- */
- void onFailure(ApiException e, int statusCode, Map> responseHeaders);
-
- /**
- * This is called when the API call succeeded.
- *
- * @param result The result deserialized from response
- * @param statusCode Status code of the response
- * @param responseHeaders Headers of the response
- */
- void onSuccess(T result, int statusCode, Map> responseHeaders);
-
- /**
- * This is called when the API upload processing.
- *
- * @param bytesWritten bytes Written
- * @param contentLength content length of request body
- * @param done write end
- */
- void onUploadProgress(long bytesWritten, long contentLength, boolean done);
-
- /**
- * This is called when the API download processing.
- *
- * @param bytesRead bytes Read
- * @param contentLength content length of the response
- * @param done Read end
- */
- void onDownloadProgress(long bytesRead, long contentLength, boolean done);
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiClient.mustache
deleted file mode 100644
index ce5e4bf48486..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiClient.mustache
+++ /dev/null
@@ -1,1738 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-{{#dynamicOperations}}
-import io.swagger.v3.oas.models.OpenAPI;
-import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.PathItem;
-import io.swagger.v3.oas.models.parameters.Parameter;
-import io.swagger.v3.oas.models.parameters.Parameter.StyleEnum;
-import io.swagger.v3.parser.OpenAPIV3Parser;
-{{/dynamicOperations}}
-import okhttp3.*;
-import okhttp3.internal.http.HttpMethod;
-import okhttp3.internal.tls.OkHostnameVerifier;
-import okhttp3.logging.HttpLoggingInterceptor;
-import okhttp3.logging.HttpLoggingInterceptor.Level;
-import okio.Buffer;
-import okio.BufferedSink;
-import okio.Okio;
-{{#joda}}
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.format.DateTimeFormatter;
-{{/joda}}
-{{#threetenbp}}
-import org.threeten.bp.LocalDate;
-import org.threeten.bp.OffsetDateTime;
-import org.threeten.bp.format.DateTimeFormatter;
-{{/threetenbp}}
-{{#hasOAuthMethods}}
-import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
-import org.apache.oltu.oauth2.common.message.types.GrantType;
-{{/hasOAuthMethods}}
-
-import javax.net.ssl.*;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Type;
-import java.net.URI;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
-import java.security.SecureRandom;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.text.DateFormat;
-{{#java8}}
-import java.time.LocalDate;
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-{{/java8}}
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import {{invokerPackage}}.auth.Authentication;
-import {{invokerPackage}}.auth.HttpBasicAuth;
-import {{invokerPackage}}.auth.HttpBearerAuth;
-import {{invokerPackage}}.auth.ApiKeyAuth;
-{{#hasOAuthMethods}}
-import {{invokerPackage}}.auth.OAuth;
-import {{invokerPackage}}.auth.RetryingOAuth;
-import {{invokerPackage}}.auth.OAuthFlow;
-{{/hasOAuthMethods}}
-
-/**
- * ApiClient class.
- */
-public class ApiClient {
-
- private String basePath = "{{{basePath}}}";
- private boolean debugging = false;
- private Map defaultHeaderMap = new HashMap();
- private Map defaultCookieMap = new HashMap();
- private String tempFolderPath = null;
-
- private Map authentications;
-
- private DateFormat dateFormat;
- private DateFormat datetimeFormat;
- private boolean lenientDatetimeFormat;
- private int dateLength;
-
- private InputStream sslCaCert;
- private boolean verifyingSsl;
- private KeyManager[] keyManagers;
-
- private OkHttpClient httpClient;
- private JSON json;
-
- private HttpLoggingInterceptor loggingInterceptor;
-
- {{#dynamicOperations}}
- private Map operationLookupMap = new HashMap<>();
-
- {{/dynamicOperations}}
- /**
- * Basic constructor for ApiClient
- */
- public ApiClient() {
- init();
- initHttpClient();
-
- // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
- authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
- authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/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);
- }
-
- /**
- * Basic constructor with custom OkHttpClient
- *
- * @param client a {@link okhttp3.OkHttpClient} object
- */
- public ApiClient(OkHttpClient client) {
- init();
-
- httpClient = client;
-
- // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
- authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
- authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/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);
- }
-
- {{#hasOAuthMethods}}
- {{#oauthMethods}}
- {{#-first}}
- /**
- * Constructor for ApiClient to support access token retry on 401/403 configured with client ID
- *
- * @param clientId client ID
- */
- public ApiClient(String clientId) {
- this(clientId, null, null);
- }
-
- /**
- * Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters
- *
- * @param clientId client ID
- * @param parameters a {@link java.util.Map} of parameters
- */
- public ApiClient(String clientId, Map parameters) {
- this(clientId, null, parameters);
- }
-
- /**
- * Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters
- *
- * @param clientId client ID
- * @param clientSecret client secret
- * @param parameters a {@link java.util.Map} of parameters
- */
- public ApiClient(String clientId, String clientSecret, Map parameters) {
- this(null, clientId, clientSecret, parameters);
- }
-
- /**
- * Constructor for ApiClient to support access token retry on 401/403 configured with base path, client ID, secret, and additional parameters
- *
- * @param basePath base path
- * @param clientId client ID
- * @param clientSecret client secret
- * @param parameters a {@link java.util.Map} of parameters
- */
- public ApiClient(String basePath, String clientId, String clientSecret, Map parameters) {
- init();
- if (basePath != null) {
- this.basePath = basePath;
- }
-
-{{#hasOAuthMethods}}
- String tokenUrl = "{{tokenUrl}}";
- if (!"".equals(tokenUrl) && !URI.create(tokenUrl).isAbsolute()) {
- URI uri = URI.create(getBasePath());
- tokenUrl = uri.getScheme() + ":" +
- (uri.getAuthority() != null ? "//" + uri.getAuthority() : "") +
- tokenUrl;
- if (!URI.create(tokenUrl).isAbsolute()) {
- throw new IllegalArgumentException("OAuth2 token URL must be an absolute URL");
- }
- }
- RetryingOAuth retryingOAuth = new RetryingOAuth(tokenUrl, clientId, OAuthFlow.{{#lambda.uppercase}}{{#lambda.snakecase}}{{flow}}{{/lambda.snakecase}}{{/lambda.uppercase}}, clientSecret, parameters);
- authentications.put(
- "{{name}}",
- retryingOAuth
- );
- initHttpClient(Collections.singletonList(retryingOAuth));
-{{/hasOAuthMethods}}
- // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
- authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
- authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
- authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{/authMethods}}
-
- // Prevent the authentications from being modified.
- authentications = Collections.unmodifiableMap(authentications);
- }
-
- {{/-first}}
- {{/oauthMethods}}
- {{/hasOAuthMethods}}
- private void initHttpClient() {
- initHttpClient(Collections.emptyList());
- }
-
- private void initHttpClient(List interceptors) {
- OkHttpClient.Builder builder = new OkHttpClient.Builder();
- builder.addNetworkInterceptor(getProgressInterceptor());
- for (Interceptor interceptor: interceptors) {
- builder.addInterceptor(interceptor);
- }
- {{#useGzipFeature}}
- // Enable gzip request compression
- builder.addInterceptor(new GzipRequestInterceptor());
- {{/useGzipFeature}}
-
- httpClient = builder.build();
- }
-
- private void init() {
- verifyingSsl = true;
-
- json = new JSON();
-
- // Set default User-Agent.
- setUserAgent("{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}/java{{/httpUserAgent}}");
-
- authentications = new HashMap();
- {{#dynamicOperations}}
-
- OpenAPI openAPI = new OpenAPIV3Parser().read("openapi/openapi.yaml");
- createOperationLookupMap(openAPI);
- {{/dynamicOperations}}
- }
-
- /**
- * Get base path
- *
- * @return Base path
- */
- public String getBasePath() {
- return basePath;
- }
-
- /**
- * Set base path
- *
- * @param basePath Base path of the URL (e.g {{{basePath}}}
- * @return An instance of OkHttpClient
- */
- public ApiClient setBasePath(String basePath) {
- this.basePath = basePath;
- return this;
- }
-
- /**
- * Get HTTP client
- *
- * @return An instance of OkHttpClient
- */
- public OkHttpClient getHttpClient() {
- return httpClient;
- }
-
- /**
- * Set HTTP client, which must never be null.
- *
- * @param newHttpClient An instance of OkHttpClient
- * @return Api Client
- * @throws java.lang.NullPointerException when newHttpClient is null
- */
- public ApiClient setHttpClient(OkHttpClient newHttpClient) {
- this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!");
- return this;
- }
-
- /**
- * Get JSON
- *
- * @return JSON object
- */
- public JSON getJSON() {
- return json;
- }
-
- /**
- * Set JSON
- *
- * @param json JSON object
- * @return Api client
- */
- public ApiClient setJSON(JSON json) {
- this.json = json;
- return this;
- }
-
- /**
- * True if isVerifyingSsl flag is on
- *
- * @return True if isVerifySsl flag is on
- */
- public boolean isVerifyingSsl() {
- return verifyingSsl;
- }
-
- /**
- * Configure whether to verify certificate and hostname when making https requests.
- * Default to true.
- * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks.
- *
- * @param verifyingSsl True to verify TLS/SSL connection
- * @return ApiClient
- */
- public ApiClient setVerifyingSsl(boolean verifyingSsl) {
- this.verifyingSsl = verifyingSsl;
- applySslSettings();
- return this;
- }
-
- /**
- * Get SSL CA cert.
- *
- * @return Input stream to the SSL CA cert
- */
- public InputStream getSslCaCert() {
- return sslCaCert;
- }
-
- /**
- * Configure the CA certificate to be trusted when making https requests.
- * Use null to reset to default.
- *
- * @param sslCaCert input stream for SSL CA cert
- * @return ApiClient
- */
- public ApiClient setSslCaCert(InputStream sslCaCert) {
- this.sslCaCert = sslCaCert;
- applySslSettings();
- return this;
- }
-
- /**
- * Getter for the field keyManagers.
- *
- * @return an array of {@link javax.net.ssl.KeyManager} objects
- */
- public KeyManager[] getKeyManagers() {
- return keyManagers;
- }
-
- /**
- * Configure client keys to use for authorization in an SSL session.
- * Use null to reset to default.
- *
- * @param managers The KeyManagers to use
- * @return ApiClient
- */
- public ApiClient setKeyManagers(KeyManager[] managers) {
- this.keyManagers = managers;
- applySslSettings();
- return this;
- }
-
- /**
- * Getter for the field dateFormat.
- *
- * @return a {@link java.text.DateFormat} object
- */
- public DateFormat getDateFormat() {
- return dateFormat;
- }
-
- /**
- * Setter for the field dateFormat.
- *
- * @param dateFormat a {@link java.text.DateFormat} object
- * @return a {@link org.openapitools.client.ApiClient} object
- */
- public ApiClient setDateFormat(DateFormat dateFormat) {
- this.json.setDateFormat(dateFormat);
- return this;
- }
-
- /**
- * Set SqlDateFormat.
- *
- * @param dateFormat a {@link java.text.DateFormat} object
- * @return a {@link org.openapitools.client.ApiClient} object
- */
- public ApiClient setSqlDateFormat(DateFormat dateFormat) {
- this.json.setSqlDateFormat(dateFormat);
- return this;
- }
-
- {{#joda}}
- public ApiClient setDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setDateTimeFormat(dateFormat);
- return this;
- }
-
- public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
- return this;
- }
-
- {{/joda}}
- {{#jsr310}}
- /**
- * Set OffsetDateTimeFormat.
- *
- * @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
- * @return a {@link org.openapitools.client.ApiClient} object
- */
- public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
- this.json.setOffsetDateTimeFormat(dateFormat);
- return this;
- }
-
- /**
- * Set LocalDateFormat.
- *
- * @param dateFormat a {@link org.threeten.bp.format.DateTimeFormatter} object
- * @return a {@link org.openapitools.client.ApiClient} object
- */
- public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
- this.json.setLocalDateFormat(dateFormat);
- return this;
- }
-
- {{/jsr310}}
- /**
- * Set LenientOnJson.
- *
- * @param lenientOnJson a boolean
- * @return a {@link org.openapitools.client.ApiClient} object
- */
- public ApiClient setLenientOnJson(boolean lenientOnJson) {
- this.json.setLenientOnJson(lenientOnJson);
- return this;
- }
-
- /**
- * Get authentications (key: authentication name, value: authentication).
- *
- * @return Map of authentication objects
- */
- 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);
- }
-
- {{#hasHttpBearerMethods}}
- /**
- * 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!");
- }
- {{/hasHttpBearerMethods}}
-
- /**
- * Helper method to set username for the first HTTP basic authentication.
- *
- * @param username 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 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 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 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!");
- }
-
- /**
- * Helper method to set access token for the first OAuth2 authentication.
- *
- * @param accessToken Access token
- */
- public void setAccessToken(String accessToken) {
- {{#hasOAuthMethods}}
- for (Authentication auth : authentications.values()) {
- if (auth instanceof OAuth) {
- ((OAuth) auth).setAccessToken(accessToken);
- return;
- }
- }
- {{/hasOAuthMethods}}
- throw new RuntimeException("No OAuth2 authentication configured!");
- }
-
- /**
- * Set the User-Agent header's value (by adding to the default header map).
- *
- * @param userAgent HTTP request's user agent
- * @return ApiClient
- */
- public ApiClient setUserAgent(String userAgent) {
- addDefaultHeader("User-Agent", userAgent);
- return this;
- }
-
- /**
- * Add a default header.
- *
- * @param key The header's key
- * @param value The header's value
- * @return ApiClient
- */
- public ApiClient addDefaultHeader(String key, String value) {
- defaultHeaderMap.put(key, value);
- return this;
- }
-
- /**
- * Add a default cookie.
- *
- * @param key The cookie's key
- * @param value The cookie's value
- * @return ApiClient
- */
- public ApiClient addDefaultCookie(String key, String value) {
- defaultCookieMap.put(key, value);
- return this;
- }
-
- /**
- * Check that whether debugging is enabled for this API client.
- *
- * @return True if debugging is enabled, false otherwise.
- */
- public boolean isDebugging() {
- return debugging;
- }
-
- /**
- * Enable/disable debugging for this API client.
- *
- * @param debugging To enable (true) or disable (false) debugging
- * @return ApiClient
- */
- public ApiClient setDebugging(boolean debugging) {
- if (debugging != this.debugging) {
- if (debugging) {
- loggingInterceptor = new HttpLoggingInterceptor();
- loggingInterceptor.setLevel(Level.BODY);
- httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build();
- } else {
- final OkHttpClient.Builder builder = httpClient.newBuilder();
- builder.interceptors().remove(loggingInterceptor);
- httpClient = builder.build();
- loggingInterceptor = null;
- }
- }
- this.debugging = debugging;
- return this;
- }
-
- /**
- * The path of temporary folder used to store downloaded files from endpoints
- * with file response. The default value is null, i.e. using
- * the system's default temporary folder.
- *
- * @see createTempFile
- * @return Temporary folder path
- */
- public String getTempFolderPath() {
- return tempFolderPath;
- }
-
- /**
- * Set the temporary folder path (for downloading files)
- *
- * @param tempFolderPath Temporary folder path
- * @return ApiClient
- */
- public ApiClient setTempFolderPath(String tempFolderPath) {
- this.tempFolderPath = tempFolderPath;
- return this;
- }
-
- /**
- * Get connection timeout (in milliseconds).
- *
- * @return Timeout in milliseconds
- */
- public int getConnectTimeout() {
- return httpClient.connectTimeoutMillis();
- }
-
- /**
- * Sets the connect timeout (in milliseconds).
- * A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link java.lang.Integer#MAX_VALUE}.
- *
- * @param connectionTimeout connection timeout in milliseconds
- * @return Api client
- */
- public ApiClient setConnectTimeout(int connectionTimeout) {
- httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build();
- return this;
- }
-
- /**
- * Get read timeout (in milliseconds).
- *
- * @return Timeout in milliseconds
- */
- public int getReadTimeout() {
- return httpClient.readTimeoutMillis();
- }
-
- /**
- * Sets the read timeout (in milliseconds).
- * A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link java.lang.Integer#MAX_VALUE}.
- *
- * @param readTimeout read timeout in milliseconds
- * @return Api client
- */
- public ApiClient setReadTimeout(int readTimeout) {
- httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build();
- return this;
- }
-
- /**
- * Get write timeout (in milliseconds).
- *
- * @return Timeout in milliseconds
- */
- public int getWriteTimeout() {
- return httpClient.writeTimeoutMillis();
- }
-
- /**
- * Sets the write timeout (in milliseconds).
- * A value of 0 means no timeout, otherwise values must be between 1 and
- * {@link java.lang.Integer#MAX_VALUE}.
- *
- * @param writeTimeout connection timeout in milliseconds
- * @return Api client
- */
- public ApiClient setWriteTimeout(int writeTimeout) {
- httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build();
- return this;
- }
-
- {{#hasOAuthMethods}}
- /**
- * Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one)
- *
- * @return Token request builder
- */
- public TokenRequestBuilder getTokenEndPoint() {
- for (Authentication apiAuth : authentications.values()) {
- if (apiAuth instanceof RetryingOAuth) {
- RetryingOAuth retryingOAuth = (RetryingOAuth) apiAuth;
- return retryingOAuth.getTokenRequestBuilder();
- }
- }
- return null;
- }
- {{/hasOAuthMethods}}
-
- /**
- * Format the given parameter object into string.
- *
- * @param param Parameter
- * @return String representation of the parameter
- */
- public String parameterToString(Object param) {
- if (param == null) {
- return "";
- } else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) {
- //Serialize to json string and remove the " enclosing characters
- String jsonStr = json.serialize(param);
- return jsonStr.substring(1, jsonStr.length() - 1);
- } 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);
- }
- }
-
- /**
- * Formats the specified query parameter to a list containing a single {@code Pair} object.
- *
- * Note that {@code value} must not be a collection.
- *
- * @param name The name of the parameter.
- * @param value The value of the parameter.
- * @return A list containing a single {@code Pair} object.
- */
- public List parameterToPair(String name, Object value) {
- List params = new ArrayList();
-
- // preconditions
- if (name == null || name.isEmpty() || value == null || value instanceof Collection) {
- return params;
- }
-
- params.add(new Pair(name, parameterToString(value)));
- return params;
- }
-
- {{^dynamicOperations}}
- /**
- * Formats the specified collection query parameters to a list of {@code Pair} objects.
- *
- * Note that the values of each of the returned Pair objects are percent-encoded.
- *
- * @param collectionFormat The collection format of the parameter.
- * @param name The name of the parameter.
- * @param value The value of the parameter.
- * @return A list of {@code Pair} objects.
- */
- public List parameterToPairs(String collectionFormat, String name, Collection value) {
- List params = new ArrayList();
-
- // preconditions
- if (name == null || name.isEmpty() || value == null || value.isEmpty()) {
- return params;
- }
-
- // create the params based on the collection format
- if ("multi".equals(collectionFormat)) {
- for (Object item : value) {
- params.add(new Pair(name, escapeString(parameterToString(item))));
- }
- return params;
- }
-
- // collectionFormat is assumed to be "csv" by default
- String delimiter = ",";
-
- // escape all delimiters except commas, which are URI reserved
- // characters
- if ("ssv".equals(collectionFormat)) {
- delimiter = escapeString(" ");
- } else if ("tsv".equals(collectionFormat)) {
- delimiter = escapeString("\t");
- } else if ("pipes".equals(collectionFormat)) {
- delimiter = escapeString("|");
- }
-
- StringBuilder sb = new StringBuilder();
- for (Object item : value) {
- sb.append(delimiter);
- sb.append(escapeString(parameterToString(item)));
- }
-
- params.add(new Pair(name, sb.substring(delimiter.length())));
-
- return params;
- }
- {{/dynamicOperations}}
- {{#dynamicOperations}}
- public List parameterToPairs(Parameter param, Collection value) {
- List params = new ArrayList();
-
- // preconditions
- if (param == null || param.getName() == null || param.getName().isEmpty() || value == null) {
- return params;
- }
-
- // create the params based on the collection format
- if (StyleEnum.FORM.equals(param.getStyle()) && Boolean.TRUE.equals(param.getExplode())) {
- for (Object item : value) {
- params.add(new Pair(param.getName(), escapeString(parameterToString(item))));
- }
- return params;
- }
-
- // collectionFormat is assumed to be "csv" by default
- String delimiter = ",";
-
- // escape all delimiters except commas, which are URI reserved
- // characters
- if (StyleEnum.SPACEDELIMITED.equals(param.getStyle())) {
- delimiter = escapeString(" ");
- } else if (StyleEnum.PIPEDELIMITED.equals(param.getStyle())) {
- delimiter = escapeString("|");
- }
-
- StringBuilder sb = new StringBuilder();
- for (Object item : value) {
- sb.append(delimiter);
- sb.append(escapeString(parameterToString(item)));
- }
-
- params.add(new Pair(param.getName(), sb.substring(delimiter.length())));
-
- return params;
- }
- {{/dynamicOperations}}
-
- /**
- * Formats the specified collection path parameter to a string value.
- *
- * @param collectionFormat The collection format of the parameter.
- * @param value The value of the parameter.
- * @return String representation of the parameter
- */
- public String collectionPathParameterToString(String collectionFormat, Collection value) {
- // create the value based on the collection format
- if ("multi".equals(collectionFormat)) {
- // not valid for path params
- return parameterToString(value);
- }
-
- // collectionFormat is assumed to be "csv" by default
- String delimiter = ",";
-
- if ("ssv".equals(collectionFormat)) {
- delimiter = " ";
- } else if ("tsv".equals(collectionFormat)) {
- delimiter = "\t";
- } else if ("pipes".equals(collectionFormat)) {
- delimiter = "|";
- }
-
- StringBuilder sb = new StringBuilder() ;
- for (Object item : value) {
- sb.append(delimiter);
- sb.append(parameterToString(item));
- }
-
- return sb.substring(delimiter.length());
- }
-
- /**
- * Sanitize filename by removing path.
- * e.g. ../../sun.gif becomes sun.gif
- *
- * @param filename The filename to be sanitized
- * @return The sanitized filename
- */
- public String sanitizeFilename(String filename) {
- return filename.replaceAll(".*[/\\\\]", "");
- }
-
- /**
- * Check if the given MIME is a JSON MIME.
- * JSON MIME examples:
- * application/json
- * application/json; charset=UTF8
- * APPLICATION/JSON
- * application/vnd.company+json
- * "* / *" is also default to JSON
- * @param mime MIME (Multipurpose Internet Mail Extensions)
- * @return True if the given MIME is JSON, false otherwise.
- */
- public boolean isJsonMime(String mime) {
- String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
- return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
- }
-
- /**
- * Select the Accept header's value from the given accepts array:
- * if JSON exists in the given array, use it;
- * otherwise use all of them (joining into a string)
- *
- * @param accepts The accepts array to select from
- * @return The Accept header to use. If the given array is empty,
- * null will be returned (not to set the Accept header explicitly).
- */
- public String selectHeaderAccept(String[] accepts) {
- if (accepts.length == 0) {
- return null;
- }
- for (String accept : accepts) {
- if (isJsonMime(accept)) {
- return accept;
- }
- }
- return StringUtil.join(accepts, ",");
- }
-
- /**
- * Select the Content-Type header's value from the given array:
- * if JSON exists in the given array, use it;
- * otherwise use the first one of the array.
- *
- * @param contentTypes The Content-Type array to select from
- * @return The Content-Type header to use. If the given array is empty,
- * returns null. If it matches "any", JSON will be used.
- */
- public String selectHeaderContentType(String[] contentTypes) {
- if (contentTypes.length == 0) {
- return null;
- }
-
- if (contentTypes[0].equals("*/*")) {
- return "application/json";
- }
-
- for (String contentType : contentTypes) {
- if (isJsonMime(contentType)) {
- return contentType;
- }
- }
-
- return contentTypes[0];
- }
-
- /**
- * Escape the given string to be used as URL query value.
- *
- * @param str String to be escaped
- * @return Escaped string
- */
- public String escapeString(String str) {
- try {
- return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
- } catch (UnsupportedEncodingException e) {
- return str;
- }
- }
-
- /**
- * Deserialize response body to Java object, according to the return type and
- * the Content-Type response header.
- *
- * @param Type
- * @param response HTTP response
- * @param returnType The type of the Java object
- * @return The deserialized Java object
- * @throws org.openapitools.client.ApiException If fail to deserialize response body, i.e. cannot read response body
- * or the Content-Type of the response is not supported.
- */
- @SuppressWarnings("unchecked")
- public T deserialize(Response response, Type returnType) throws ApiException {
- if (response == null || returnType == null) {
- return null;
- }
-
- if ("byte[]".equals(returnType.toString())) {
- // Handle binary response (byte array).
- try {
- return (T) response.body().bytes();
- } catch (IOException e) {
- throw new ApiException(e);
- }
- } else if (returnType.equals(File.class)) {
- // Handle file downloading.
- return (T) downloadFileFromResponse(response);
- }
-
- String respBody;
- try {
- if (response.body() != null)
- respBody = response.body().string();
- else
- respBody = null;
- } catch (IOException e) {
- throw new ApiException(e);
- }
-
- if (respBody == null || "".equals(respBody)) {
- return null;
- }
-
- String contentType = response.headers().get("Content-Type");
- if (contentType == null) {
- // ensuring a default content type
- contentType = "application/json";
- }
- if (isJsonMime(contentType)) {
- return json.deserialize(respBody, returnType);
- } else if (returnType.equals(String.class)) {
- // Expecting string, return the raw response body.
- return (T) respBody;
- } else {
- throw new ApiException(
- "Content type \"" + contentType + "\" is not supported for type: " + returnType,
- response.code(),
- response.headers().toMultimap(),
- respBody);
- }
- }
-
- /**
- * Serialize the given Java object into request body according to the object's
- * class and the request Content-Type.
- *
- * @param obj The Java object
- * @param contentType The request Content-Type
- * @return The serialized request body
- * @throws org.openapitools.client.ApiException If fail to serialize the given object
- */
- public RequestBody serialize(Object obj, String contentType) throws ApiException {
- if (obj instanceof byte[]) {
- // Binary (byte array) body parameter support.
- return RequestBody.create((byte[]) obj, MediaType.parse(contentType));
- } else if (obj instanceof File) {
- // File body parameter support.
- return RequestBody.create((File) obj, MediaType.parse(contentType));
- } else if (isJsonMime(contentType)) {
- String content;
- if (obj != null) {
- content = json.serialize(obj);
- } else {
- content = null;
- }
- return RequestBody.create(content, MediaType.parse(contentType));
- } else {
- throw new ApiException("Content type \"" + contentType + "\" is not supported");
- }
- }
-
- /**
- * Download file from the given response.
- *
- * @param response An instance of the Response object
- * @throws org.openapitools.client.ApiException If fail to read file content from response and write to disk
- * @return Downloaded file
- */
- public File downloadFileFromResponse(Response response) throws ApiException {
- try {
- File file = prepareDownloadFile(response);
- BufferedSink sink = Okio.buffer(Okio.sink(file));
- sink.writeAll(response.body().source());
- sink.close();
- return file;
- } catch (IOException e) {
- throw new ApiException(e);
- }
- }
-
- /**
- * Prepare file for download
- *
- * @param response An instance of the Response object
- * @return Prepared file for the download
- * @throws java.io.IOException If fail to prepare file for download
- */
- public File prepareDownloadFile(Response response) throws IOException {
- String filename = null;
- String contentDisposition = response.header("Content-Disposition");
- if (contentDisposition != null && !"".equals(contentDisposition)) {
- // Get filename from the Content-Disposition header.
- Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
- Matcher matcher = pattern.matcher(contentDisposition);
- if (matcher.find()) {
- filename = sanitizeFilename(matcher.group(1));
- }
- }
-
- String prefix = null;
- String suffix = null;
- if (filename == null) {
- prefix = "download-";
- suffix = "";
- } else {
- int pos = filename.lastIndexOf(".");
- if (pos == -1) {
- prefix = filename + "-";
- } else {
- prefix = filename.substring(0, pos) + "-";
- suffix = filename.substring(pos);
- }
- // Files.createTempFile requires the prefix to be at least three characters long
- if (prefix.length() < 3)
- prefix = "download-";
- }
-
- if (tempFolderPath == null)
- return Files.createTempFile(prefix, suffix).toFile();
- else
- return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile();
- }
-
- /**
- * {@link #execute(Call, Type)}
- *
- * @param Type
- * @param call An instance of the Call object
- * @return ApiResponse<T>
- * @throws org.openapitools.client.ApiException If fail to execute the call
- */
- public ApiResponse execute(Call call) throws ApiException {
- return execute(call, null);
- }
-
- /**
- * Execute HTTP call and deserialize the HTTP response body into the given return type.
- *
- * @param returnType The return type used to deserialize HTTP response body
- * @param The return type corresponding to (same with) returnType
- * @param call Call
- * @return ApiResponse object containing response status, headers and
- * data, which is a Java object deserialized from response body and would be null
- * when returnType is null.
- * @throws org.openapitools.client.ApiException If fail to execute the call
- */
- public ApiResponse execute(Call call, Type returnType) throws ApiException {
- try {
- Response response = call.execute();
- T data = handleResponse(response, returnType);
- return new ApiResponse(response.code(), response.headers().toMultimap(), data);
- } catch (IOException e) {
- throw new ApiException(e);
- }
- }
-
- {{#supportStreaming}}
- /**
- * Execute stream.
- *
- * @param call a {@link okhttp3.Call} object
- * @param returnType a {@link java.lang.reflect.Type} object
- * @return a {@link java.io.InputStream} object
- * @throws org.openapitools.client.ApiException if any.
- */
- public InputStream executeStream(Call call, Type returnType) throws ApiException {
- try {
- Response response = call.execute();
- if (!response.isSuccessful()) {
- throw new ApiException(response.code(), response.message());
- }
- if (response.body() == null) {
- return null;
- }
- return response.body().byteStream();
- } catch (IOException e) {
- throw new ApiException(e);
- }
- }
-
- {{/supportStreaming}}
- /**
- * {@link #executeAsync(Call, Type, ApiCallback)}
- *
- * @param Type
- * @param call An instance of the Call object
- * @param callback ApiCallback<T>
- */
- public void executeAsync(Call call, ApiCallback callback) {
- executeAsync(call, null, callback);
- }
-
- /**
- * Execute HTTP call asynchronously.
- *
- * @param Type
- * @param call The callback to be executed when the API call finishes
- * @param returnType Return type
- * @param callback ApiCallback
- * @see #execute(Call, Type)
- */
- @SuppressWarnings("unchecked")
- public void executeAsync(Call call, final Type returnType, final ApiCallback callback) {
- call.enqueue(new Callback() {
- @Override
- public void onFailure(Call call, IOException e) {
- callback.onFailure(new ApiException(e), 0, null);
- }
-
- @Override
- public void onResponse(Call call, Response response) throws IOException {
- T result;
- try {
- result = (T) handleResponse(response, returnType);
- } catch (ApiException e) {
- callback.onFailure(e, response.code(), response.headers().toMultimap());
- return;
- } catch (Exception e) {
- callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap());
- return;
- }
- callback.onSuccess(result, response.code(), response.headers().toMultimap());
- }
- });
- }
-
- /**
- * Handle the given response, return the deserialized object when the response is successful.
- *
- * @param Type
- * @param response Response
- * @param returnType Return type
- * @return Type
- * @throws org.openapitools.client.ApiException If the response has an unsuccessful status code or
- * fail to deserialize the response body
- */
- public T handleResponse(Response response, Type returnType) throws ApiException {
- if (response.isSuccessful()) {
- if (returnType == null || response.code() == 204) {
- // returning null if the returnType is not defined,
- // or the status code is 204 (No Content)
- if (response.body() != null) {
- try {
- response.body().close();
- } catch (Exception e) {
- throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
- }
- }
- return null;
- } else {
- return deserialize(response, returnType);
- }
- } else {
- String respBody = null;
- if (response.body() != null) {
- try {
- respBody = response.body().string();
- } catch (IOException e) {
- throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap());
- }
- }
- throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody);
- }
- }
-
- /**
- * Build HTTP call with the given options.
- *
- * @param path The sub-path of the HTTP URL
- * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
- * @param queryParams The query parameters
- * @param collectionQueryParams The collection query parameters
- * @param body The request body object
- * @param headerParams The header parameters
- * @param cookieParams The cookie parameters
- * @param formParams The form parameters
- * @param authNames The authentications to apply
- * @param callback Callback for upload/download progress
- * @return The HTTP call
- * @throws org.openapitools.client.ApiException If fail to serialize the request body object
- */
- public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
- Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
-
- return httpClient.newCall(request);
- }
-
- /**
- * Build an HTTP request with the given options.
- *
- * @param path The sub-path of the HTTP URL
- * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
- * @param queryParams The query parameters
- * @param collectionQueryParams The collection query parameters
- * @param body The request body object
- * @param headerParams The header parameters
- * @param cookieParams The cookie parameters
- * @param formParams The form parameters
- * @param authNames The authentications to apply
- * @param callback Callback for upload/download progress
- * @return The HTTP request
- * @throws org.openapitools.client.ApiException If fail to serialize the request body object
- */
- public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException {
- // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams
- List allQueryParams = new ArrayList(queryParams);
- allQueryParams.addAll(collectionQueryParams);
-
- final String url = buildUrl(path, queryParams, collectionQueryParams);
-
- // prepare HTTP request body
- RequestBody reqBody;
- String contentType = headerParams.get("Content-Type");
-
- if (!HttpMethod.permitsRequestBody(method)) {
- reqBody = null;
- } else if ("application/x-www-form-urlencoded".equals(contentType)) {
- reqBody = buildRequestBodyFormEncoding(formParams);
- } else if ("multipart/form-data".equals(contentType)) {
- reqBody = buildRequestBodyMultipart(formParams);
- } else if (body == null) {
- if ("DELETE".equals(method)) {
- // allow calling DELETE without sending a request body
- reqBody = null;
- } else {
- // use an empty request body (for POST, PUT and PATCH)
- reqBody = RequestBody.create("", MediaType.parse(contentType));
- }
- } else {
- reqBody = serialize(body, contentType);
- }
-
- // update parameters with authentication settings
- updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url));
-
- final Request.Builder reqBuilder = new Request.Builder().url(url);
- processHeaderParams(headerParams, reqBuilder);
- processCookieParams(cookieParams, reqBuilder);
-
- // Associate callback with request (if not null) so interceptor can
- // access it when creating ProgressResponseBody
- reqBuilder.tag(callback);
-
- Request request = null;
-
- if (callback != null && reqBody != null) {
- ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback);
- request = reqBuilder.method(method, progressRequestBody).build();
- } else {
- request = reqBuilder.method(method, reqBody).build();
- }
-
- return request;
- }
-
- /**
- * Build full URL by concatenating base path, the given sub path and query parameters.
- *
- * @param path The sub path
- * @param queryParams The query parameters
- * @param collectionQueryParams The collection query parameters
- * @return The full URL
- */
- public String buildUrl(String path, List queryParams, List collectionQueryParams) {
- final StringBuilder url = new StringBuilder();
- url.append(basePath).append(path);
-
- if (queryParams != null && !queryParams.isEmpty()) {
- // support (constant) query string in `path`, e.g. "/posts?draft=1"
- String prefix = path.contains("?") ? "&" : "?";
- for (Pair param : queryParams) {
- if (param.getValue() != null) {
- if (prefix != null) {
- url.append(prefix);
- prefix = null;
- } else {
- url.append("&");
- }
- String value = parameterToString(param.getValue());
- url.append(escapeString(param.getName())).append("=").append(escapeString(value));
- }
- }
- }
-
- if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) {
- String prefix = url.toString().contains("?") ? "&" : "?";
- for (Pair param : collectionQueryParams) {
- if (param.getValue() != null) {
- if (prefix != null) {
- url.append(prefix);
- prefix = null;
- } else {
- url.append("&");
- }
- String value = parameterToString(param.getValue());
- // collection query parameter value already escaped as part of parameterToPairs
- url.append(escapeString(param.getName())).append("=").append(value);
- }
- }
- }
-
- return url.toString();
- }
-
- /**
- * Set header parameters to the request builder, including default headers.
- *
- * @param headerParams Header parameters in the form of Map
- * @param reqBuilder Request.Builder
- */
- public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) {
- for (Entry param : headerParams.entrySet()) {
- reqBuilder.header(param.getKey(), parameterToString(param.getValue()));
- }
- for (Entry header : defaultHeaderMap.entrySet()) {
- if (!headerParams.containsKey(header.getKey())) {
- reqBuilder.header(header.getKey(), parameterToString(header.getValue()));
- }
- }
- }
-
- /**
- * Set cookie parameters to the request builder, including default cookies.
- *
- * @param cookieParams Cookie parameters in the form of Map
- * @param reqBuilder Request.Builder
- */
- public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) {
- for (Entry param : cookieParams.entrySet()) {
- reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
- }
- for (Entry param : defaultCookieMap.entrySet()) {
- if (!cookieParams.containsKey(param.getKey())) {
- reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
- }
- }
- }
-
- /**
- * Update query and header parameters based on authentication settings.
- *
- * @param authNames The authentications to apply
- * @param queryParams List of query parameters
- * @param headerParams Map of header parameters
- * @param cookieParams Map of cookie parameters
- * @param payload HTTP request body
- * @param method HTTP method
- * @param uri URI
- * @throws org.openapitools.client.ApiException If fails to update the parameters
- */
- public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
- Map cookieParams, String payload, String method, URI uri) throws ApiException {
- for (String authName : authNames) {
- Authentication auth = authentications.get(authName);
- if (auth == null) {
- throw new RuntimeException("Authentication undefined: " + authName);
- }
- auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
- }
- }
-
- /**
- * Build a form-encoding request body with the given form parameters.
- *
- * @param formParams Form parameters in the form of Map
- * @return RequestBody
- */
- public RequestBody buildRequestBodyFormEncoding(Map formParams) {
- okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder();
- for (Entry param : formParams.entrySet()) {
- formBuilder.add(param.getKey(), parameterToString(param.getValue()));
- }
- return formBuilder.build();
- }
-
- /**
- * Build a multipart (file uploading) request body with the given form parameters,
- * which could contain text fields and file fields.
- *
- * @param formParams Form parameters in the form of Map
- * @return RequestBody
- */
- public RequestBody buildRequestBodyMultipart(Map formParams) {
- MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
- for (Entry param : formParams.entrySet()) {
- if (param.getValue() instanceof File) {
- File file = (File) param.getValue();
- Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\"");
- MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
- mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType));
- } else {
- Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"");
- mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null));
- }
- }
- return mpBuilder.build();
- }
-
- /**
- * Guess Content-Type header from the given file (defaults to "application/octet-stream").
- *
- * @param file The given file
- * @return The guessed Content-Type
- */
- public String guessContentTypeFromFile(File file) {
- String contentType = URLConnection.guessContentTypeFromName(file.getName());
- if (contentType == null) {
- return "application/octet-stream";
- } else {
- return contentType;
- }
- }
-
- /**
- * Get network interceptor to add it to the httpClient to track download progress for
- * async requests.
- */
- private Interceptor getProgressInterceptor() {
- return new Interceptor() {
- @Override
- public Response intercept(Interceptor.Chain chain) throws IOException {
- final Request request = chain.request();
- final Response originalResponse = chain.proceed(request);
- if (request.tag() instanceof ApiCallback) {
- final ApiCallback callback = (ApiCallback) request.tag();
- return originalResponse.newBuilder()
- .body(new ProgressResponseBody(originalResponse.body(), callback))
- .build();
- }
- return originalResponse;
- }
- };
- }
-
- /**
- * Apply SSL related settings to httpClient according to the current values of
- * verifyingSsl and sslCaCert.
- */
- private void applySslSettings() {
- try {
- TrustManager[] trustManagers;
- HostnameVerifier hostnameVerifier;
- if (!verifyingSsl) {
- trustManagers = new TrustManager[]{
- new X509TrustManager() {
- @Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
- }
-
- @Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
- }
-
- @Override
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return new java.security.cert.X509Certificate[]{};
- }
- }
- };
- hostnameVerifier = new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- };
- } else {
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
-
- if (sslCaCert == null) {
- trustManagerFactory.init((KeyStore) null);
- } else {
- char[] password = null; // Any password will work.
- CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
- Collection extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert);
- if (certificates.isEmpty()) {
- throw new IllegalArgumentException("expected non-empty set of trusted certificates");
- }
- KeyStore caKeyStore = newEmptyKeyStore(password);
- int index = 0;
- for (Certificate certificate : certificates) {
- String certificateAlias = "ca" + Integer.toString(index++);
- caKeyStore.setCertificateEntry(certificateAlias, certificate);
- }
- trustManagerFactory.init(caKeyStore);
- }
- trustManagers = trustManagerFactory.getTrustManagers();
- hostnameVerifier = OkHostnameVerifier.INSTANCE;
- }
-
- SSLContext sslContext = SSLContext.getInstance("TLS");
- sslContext.init(keyManagers, trustManagers, new SecureRandom());
- httpClient = httpClient.newBuilder()
- .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0])
- .hostnameVerifier(hostnameVerifier)
- .build();
- } catch (GeneralSecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException {
- try {
- KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
- keyStore.load(null, password);
- return keyStore;
- } catch (IOException e) {
- throw new AssertionError(e);
- }
- }
- {{#dynamicOperations}}
-
- public ApiClient createOperationLookupMap(OpenAPI openAPI) {
- operationLookupMap = new HashMap<>();
- for (Map.Entry pathItemEntry : openAPI.getPaths().entrySet()) {
- String path = pathItemEntry.getKey();
- PathItem pathItem = pathItemEntry.getValue();
- addOperationLookupEntry(path, "GET", pathItem.getGet());
- addOperationLookupEntry(path, "PUT", pathItem.getPut());
- addOperationLookupEntry(path, "POST", pathItem.getPost());
- addOperationLookupEntry(path, "DELETE", pathItem.getDelete());
- addOperationLookupEntry(path, "OPTIONS", pathItem.getOptions());
- addOperationLookupEntry(path, "HEAD", pathItem.getHead());
- addOperationLookupEntry(path, "PATCH", pathItem.getPatch());
- addOperationLookupEntry(path, "TRACE", pathItem.getTrace());
- }
- return this;
- }
-
- private void addOperationLookupEntry(String path, String method, Operation operation) {
- if ( operation != null && operation.getOperationId() != null) {
- operationLookupMap.put(
- operation.getOperationId(),
- new ApiOperation(path, method, operation));
- }
- }
-
- public Map getOperationLookupMap() {
- return operationLookupMap;
- }
-
- public String fillParametersFromOperation(
- Operation operation,
- Map paramMap,
- String path,
- List queryParams,
- List collectionQueryParams,
- Map headerParams,
- Map cookieParams
- ) {
- for (Map.Entry entry : paramMap.entrySet()) {
- Object value = entry.getValue();
- for (Parameter param : operation.getParameters()) {
- if (entry.getKey().equals(param.getName())) {
- switch (param.getIn()) {
- case "path":
- path = path.replaceAll("\\{" + param.getName() + "\\}", escapeString(value.toString()));
- break;
- case "query":
- if (value instanceof Collection>) {
- collectionQueryParams.addAll(parameterToPairs(param, (Collection) value));
- } else {
- queryParams.addAll(parameterToPair(param.getName(), value));
- }
- break;
- case "header":
- headerParams.put(param.getName(), parameterToString(value));
- break;
- case "cookie":
- cookieParams.put(param.getName(), parameterToString(value));
- break;
- default:
- throw new IllegalStateException("Unexpected param in: " + param.getIn());
- }
-
- }
- }
- }
- return path;
- }
- {{/dynamicOperations}}
-
- /**
- * Convert the HTTP request body to a string.
- *
- * @param request The HTTP request object
- * @return The string representation of the HTTP request body
- * @throws org.openapitools.client.ApiException If fail to serialize the request body object into a string
- */
- private String requestBodyToString(RequestBody requestBody) throws ApiException {
- if (requestBody != null) {
- try {
- final Buffer buffer = new Buffer();
- requestBody.writeTo(buffer);
- return buffer.readUtf8();
- } catch (final IOException e) {
- throw new ApiException(e);
- }
- }
-
- // empty http request body
- return "";
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiResponse.mustache
deleted file mode 100644
index cecbaac1df27..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ApiResponse.mustache
+++ /dev/null
@@ -1,75 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import java.util.List;
-import java.util.Map;
-{{#caseInsensitiveResponseHeaders}}
-import java.util.Map.Entry;
-import java.util.TreeMap;
-{{/caseInsensitiveResponseHeaders}}
-
-/**
- * API response returned by API call.
- */
-public class ApiResponse {
- final private int statusCode;
- final private Map> headers;
- final private T data;
-
- /**
- * Constructor for ApiResponse.
- *
- * @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);
- }
-
- /**
- * Constructor for ApiResponse.
- *
- * @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;
- {{#caseInsensitiveResponseHeaders}}
- Map> responseHeaders = new TreeMap>(String.CASE_INSENSITIVE_ORDER);
- for(Entry> entry : headers.entrySet()){
- responseHeaders.put(entry.getKey().toLowerCase(), entry.getValue());
- }
- {{/caseInsensitiveResponseHeaders}}
- this.headers = {{#caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}};
- this.data = data;
- }
-
- /**
- * Get the status code.
- *
- * @return the status code
- */
- public int getStatusCode() {
- return statusCode;
- }
-
- /**
- * Get the headers.
- *
- * @return a {@link java.util.Map} of headers
- */
- public Map> getHeaders() {
- return headers;
- }
-
- /**
- * Get the data.
- *
- * @return the data
- */
- public T getData() {
- return data;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/GzipRequestInterceptor.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/GzipRequestInterceptor.mustache
deleted file mode 100644
index b633aa8f5864..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/GzipRequestInterceptor.mustache
+++ /dev/null
@@ -1,74 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import okhttp3.*;
-import okio.Buffer;
-import okio.BufferedSink;
-import okio.GzipSink;
-import okio.Okio;
-
-import java.io.IOException;
-
-/**
- * Encodes request bodies using gzip.
- *
- * Taken from https://github.com/square/okhttp/issues/350
- */
-class GzipRequestInterceptor implements Interceptor {
- @Override
- public Response intercept(Chain chain) throws IOException {
- Request originalRequest = chain.request();
- if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
- return chain.proceed(originalRequest);
- }
-
- Request compressedRequest = originalRequest.newBuilder()
- .header("Content-Encoding", "gzip")
- .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))
- .build();
- return chain.proceed(compressedRequest);
- }
-
- private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
- final Buffer buffer = new Buffer();
- requestBody.writeTo(buffer);
- return new RequestBody() {
- @Override
- public MediaType contentType() {
- return requestBody.contentType();
- }
-
- @Override
- public long contentLength() {
- return buffer.size();
- }
-
- @Override
- public void writeTo(BufferedSink sink) throws IOException {
- sink.write(buffer.snapshot());
- }
- };
- }
-
- private RequestBody gzip(final RequestBody body) {
- return new RequestBody() {
- @Override
- public MediaType contentType() {
- return body.contentType();
- }
-
- @Override
- public long contentLength() {
- return -1; // We don't know the compressed length in advance!
- }
-
- @Override
- public void writeTo(BufferedSink sink) throws IOException {
- BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
- body.writeTo(gzipSink);
- gzipSink.close();
- }
- };
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressRequestBody.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressRequestBody.mustache
deleted file mode 100644
index 71e1e2b4cbe8..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressRequestBody.mustache
+++ /dev/null
@@ -1,62 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import okhttp3.MediaType;
-import okhttp3.RequestBody;
-
-import java.io.IOException;
-
-import okio.Buffer;
-import okio.BufferedSink;
-import okio.ForwardingSink;
-import okio.Okio;
-import okio.Sink;
-
-public class ProgressRequestBody extends RequestBody {
-
- private final RequestBody requestBody;
-
- private final ApiCallback callback;
-
- public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) {
- this.requestBody = requestBody;
- this.callback = callback;
- }
-
- @Override
- public MediaType contentType() {
- return requestBody.contentType();
- }
-
- @Override
- public long contentLength() throws IOException {
- return requestBody.contentLength();
- }
-
- @Override
- public void writeTo(BufferedSink sink) throws IOException {
- BufferedSink bufferedSink = Okio.buffer(sink(sink));
- requestBody.writeTo(bufferedSink);
- bufferedSink.flush();
- }
-
- private Sink sink(Sink sink) {
- return new ForwardingSink(sink) {
-
- long bytesWritten = 0L;
- long contentLength = 0L;
-
- @Override
- public void write(Buffer source, long byteCount) throws IOException {
- super.write(source, byteCount);
- if (contentLength == 0) {
- contentLength = contentLength();
- }
-
- bytesWritten += byteCount;
- callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength);
- }
- };
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressResponseBody.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressResponseBody.mustache
deleted file mode 100644
index 45115940b665..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/ProgressResponseBody.mustache
+++ /dev/null
@@ -1,59 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import okhttp3.MediaType;
-import okhttp3.ResponseBody;
-
-import java.io.IOException;
-
-import okio.Buffer;
-import okio.BufferedSource;
-import okio.ForwardingSource;
-import okio.Okio;
-import okio.Source;
-
-public class ProgressResponseBody extends ResponseBody {
-
- private final ResponseBody responseBody;
- private final ApiCallback callback;
- private BufferedSource bufferedSource;
-
- public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) {
- this.responseBody = responseBody;
- this.callback = callback;
- }
-
- @Override
- public MediaType contentType() {
- return responseBody.contentType();
- }
-
- @Override
- public long contentLength() {
- return responseBody.contentLength();
- }
-
- @Override
- public BufferedSource source() {
- if (bufferedSource == null) {
- bufferedSource = Okio.buffer(source(responseBody.source()));
- }
- return bufferedSource;
- }
-
- private Source source(Source source) {
- return new ForwardingSource(source) {
- long totalBytesRead = 0L;
-
- @Override
- public long read(Buffer sink, long byteCount) throws IOException {
- long bytesRead = super.read(sink, byteCount);
- // read() returns the number of bytes read, or -1 if this source is exhausted.
- totalBytesRead += bytesRead != -1 ? bytesRead : 0;
- callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1);
- return bytesRead;
- }
- };
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/README.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/README.mustache
deleted file mode 100644
index a1a142bd488c..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/README.mustache
+++ /dev/null
@@ -1,183 +0,0 @@
-# {{artifactId}}
-
-{{appName}}
-- API version: {{appVersion}}
-{{^hideGenerationTimestamp}}
- - Build date: {{generatedDate}}
-{{/hideGenerationTimestamp}}
-
-{{{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 {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+
-2. Maven (3.8.3+)/Gradle (7.2+)
-
-## 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`
-
-## Getting Started
-
-Please follow the [installation](#installation) instruction and execute the following Java code:
-
-```java
-{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
-// Import classes:
-import {{{invokerPackage}}}.ApiClient;
-import {{{invokerPackage}}}.ApiException;
-import {{{invokerPackage}}}.Configuration;{{#hasAuthMethods}}
-import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}}
-import {{{invokerPackage}}}.models.*;
-import {{{package}}}.{{{classname}}};
-
-public class 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}}
- {{/authMethods}}
- {{/hasAuthMethods}}
-
- {{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
- {{#allParams}}
- {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
- {{/allParams}}
- try {
- {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}{{^vendorExtensions.x-group-parameters}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}
- .{{{paramName}}}({{{paramName}}}){{/optionalParams}}
- .execute();{{/vendorExtensions.x-group-parameters}}{{#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}}** {{path}} | {{summary}}
-{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
-
-## Documentation for Models
-
-{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md)
-{{/model}}{{/models}}
-
-## Documentation for Authorization
-
-{{^authMethods}}All endpoints do not require authorization.
-{{/authMethods}}Authentication schemes defined for the API:
-{{#authMethods}}### {{name}}
-
-{{#isApiKey}}- **Type**: API key
-- **API key parameter name**: {{keyParamName}}
-- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
-{{/isApiKey}}
-{{#isBasic}}- **Type**: HTTP basic authentication
-{{/isBasic}}
-{{#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/okhttp-gson-nextgen/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache
deleted file mode 100644
index 943e6948de76..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api.mustache
+++ /dev/null
@@ -1,520 +0,0 @@
-{{>licenseInfo}}
-
-package {{package}};
-
-import {{invokerPackage}}.ApiCallback;
-import {{invokerPackage}}.ApiClient;
-import {{invokerPackage}}.ApiException;
-{{#dynamicOperations}}
-import {{invokerPackage}}.ApiOperation;
-{{/dynamicOperations}}
-import {{invokerPackage}}.ApiResponse;
-import {{invokerPackage}}.Configuration;
-import {{invokerPackage}}.Pair;
-import {{invokerPackage}}.ProgressRequestBody;
-import {{invokerPackage}}.ProgressResponseBody;
-{{#performBeanValidation}}
-import {{invokerPackage}}.BeanValidationException;
-{{/performBeanValidation}}
-
-import com.google.gson.reflect.TypeToken;
-{{#dynamicOperations}}
-import io.swagger.v3.oas.models.Operation;
-import io.swagger.v3.oas.models.parameters.Parameter;
-{{/dynamicOperations}}
-
-import java.io.IOException;
-
-{{#useBeanValidation}}
-import javax.validation.constraints.*;
-{{/useBeanValidation}}
-{{#performBeanValidation}}
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.ValidatorFactory;
-import javax.validation.executable.ExecutableValidator;
-import java.util.Set;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-{{/performBeanValidation}}
-
-{{#imports}}import {{import}};
-{{/imports}}
-
-import java.lang.reflect.Type;
-{{^fullJavaUtil}}
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-{{#supportStreaming}}
-import java.io.InputStream;
-{{/supportStreaming}}
-{{/fullJavaUtil}}
-import javax.ws.rs.core.GenericType;
-
-{{#operations}}
-public class {{classname}} {
- private ApiClient localVarApiClient;
-
- public {{classname}}() {
- this(Configuration.getDefaultApiClient());
- }
-
- public {{classname}}(ApiClient apiClient) {
- this.localVarApiClient = apiClient;
- }
-
- public ApiClient getApiClient() {
- return localVarApiClient;
- }
-
- public void setApiClient(ApiClient apiClient) {
- this.localVarApiClient = apiClient;
- }
-
- {{#operation}}
- {{^vendorExtensions.x-group-parameters}}/**
- * Build call for {{operationId}}{{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
- * @param _callback Callback for upload/download progress
- * @return Call to execute
- * @throws ApiException If fail to serialize the request body object
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException {
- Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
-
- // create path and map variables
- {{^dynamicOperations}}
- String localVarPath = "{{{path}}}"{{#pathParams}}
- .replaceAll("\\{" + "{{baseName}}" + "\\}", localVarApiClient.escapeString({{#collectionFormat}}localVarApiClient.collectionPathParameterToString("{{{collectionFormat}}}", {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.toString(){{/collectionFormat}})){{/pathParams}};
- {{/dynamicOperations}}
- {{#dynamicOperations}}
- ApiOperation apiOperation = localVarApiClient.getOperationLookupMap().get("{{{operationId}}}");
- if (apiOperation == null) {
- throw new ApiException("Operation not found in OAS");
- }
- Operation operation = apiOperation.getOperation();
- String localVarPath = apiOperation.getPath();
- Map paramMap = new HashMap<>();
- {{#allParams}}
- {{^isFormParam}}
- {{^isBodyParam}}
- paramMap.put("{{baseName}}", {{paramName}});
- {{/isBodyParam}}
- {{/isFormParam}}
- {{/allParams}}
- {{/dynamicOperations}}
-
- {{javaUtilPrefix}}List localVarQueryParams = new {{javaUtilPrefix}}ArrayList();
- {{javaUtilPrefix}}List localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList();
- {{javaUtilPrefix}}Map localVarHeaderParams = new {{javaUtilPrefix}}HashMap();
- {{javaUtilPrefix}}Map localVarCookieParams = new {{javaUtilPrefix}}HashMap();
- {{javaUtilPrefix}}Map localVarFormParams = new {{javaUtilPrefix}}HashMap();
-
- {{#formParams}}
- if ({{paramName}} != null) {
- localVarFormParams.put("{{baseName}}", {{paramName}});
- }
-
- {{/formParams}}
- {{^dynamicOperations}}
- {{#queryParams}}
- if ({{paramName}} != null) {
- {{#collectionFormat}}localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(localVarApiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}}));
- }
-
- {{/queryParams}}
- {{#headerParams}}
- if ({{paramName}} != null) {
- localVarHeaderParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
- }
-
- {{/headerParams}}
- {{#cookieParams}}
- if ({{paramName}} != null) {
- localVarCookieParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
- }
-
- {{/cookieParams}}
- {{/dynamicOperations}}
- {{#dynamicOperations}}
- localVarPath = localVarApiClient.fillParametersFromOperation(operation, paramMap, localVarPath, localVarQueryParams, localVarCollectionQueryParams, localVarHeaderParams, localVarCookieParams);
-
- {{/dynamicOperations}}
- final String[] localVarAccepts = {
- {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}
- };
- final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
- if (localVarAccept != null) {
- localVarHeaderParams.put("Accept", localVarAccept);
- }
-
- final String[] localVarContentTypes = {
- {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}
- };
- final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
- if (localVarContentType != null) {
- localVarHeaderParams.put("Content-Type", localVarContentType);
- }
-
- String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} };
- return localVarApiClient.buildCall(localVarPath, {{^dynamicOperations}}"{{httpMethod}}"{{/dynamicOperations}}{{#dynamicOperations}}apiOperation.getMethod(){{/dynamicOperations}}, localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
- }
-
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- @SuppressWarnings("rawtypes")
- private okhttp3.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException {
- {{^performBeanValidation}}
- {{#allParams}}{{#required}}
- // verify the required parameter '{{paramName}}' is set
- if ({{paramName}} == null) {
- throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)");
- }
- {{/required}}{{/allParams}}
-
- okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- return localVarCall;
-
- {{/performBeanValidation}}
- {{#performBeanValidation}}
- try {
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- ExecutableValidator executableValidator = factory.getValidator().forExecutables();
-
- Object[] parameterValues = { {{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}} };
- Method method = this.getClass().getMethod("{{operationId}}WithHttpInfo"{{#allParams}}, {{#isArray}}java.util.List{{/isArray}}{{#isMap}}java.util.Map{{/isMap}}{{^isArray}}{{^isMap}}{{{dataType}}}{{/isMap}}{{/isArray}}.class{{/allParams}});
- Set> violations = executableValidator.validateParameters(this, method,
- parameterValues);
-
- if (violations.size() == 0) {
- okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- return localVarCall;
-
- } else {
- throw new BeanValidationException((Set) violations);
- }
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- throw new ApiException(e.getMessage());
- } catch (SecurityException e) {
- e.printStackTrace();
- throw new ApiException(e.getMessage());
- }
-
- {{/performBeanValidation}}
- }
-
- {{^vendorExtensions.x-group-parameters}}
- /**
- * {{summary}}
- * {{notes}}{{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
- * @return {{.}}{{/returnType}}
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- {{#vendorExtensions.x-streaming}}
- public {{#returnType}}InputStream {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
- {{#returnType}}InputStream localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
- return localVarResp;{{/returnType}}
- }
- {{/vendorExtensions.x-streaming}}
- {{^vendorExtensions.x-streaming}}
- public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
- {{#returnType}}ApiResponse<{{{.}}}> localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
- return localVarResp.getData();{{/returnType}}
- }
- {{/vendorExtensions.x-streaming}}
- {{/vendorExtensions.x-group-parameters}}
-
- {{^vendorExtensions.x-group-parameters}}/**
- * {{summary}}
- * {{notes}}{{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
- * @return ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-streaming}} InputStream {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
- okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null);
- {{#returnType}}
- try {
- Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
- return localVarApiClient.executeStream(localVarCall, localVarReturnType);
- } catch (ApiException e) {
- e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){}.getType()));
- e.setErrorObjectType(new GenericType<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){});
- throw e;
- }
- {{/returnType}}
- }
- {{/vendorExtensions.x-streaming}}{{^vendorExtensions.x-streaming}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
- okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null);
- {{^returnType}}
- return localVarApiClient.execute(localVarCall);
- {{/returnType}}
- {{#returnType}}
- try {
- Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
- } catch (ApiException e) {
- e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){}.getType()));
- e.setErrorObjectType(new GenericType<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){});
- throw e;
- }
- {{/returnType}}
- }
- {{/vendorExtensions.x-streaming}}
-
- {{^vendorExtensions.x-group-parameters}}/**
- * {{summary}} (asynchronously)
- * {{notes}}{{#allParams}}
- * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
- * @param _callback The callback to be executed when the API call finishes
- * @return The request call
- * @throws ApiException If fail to process the API call, e.g. serializing the request body object
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> _callback) throws ApiException {
-
- okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
- localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);{{/returnType}}{{^returnType}}localVarApiClient.executeAsync(localVarCall, _callback);{{/returnType}}
- return localVarCall;
- }
- {{#vendorExtensions.x-group-parameters}}
-
- public class API{{operationId}}Request {
- {{#requiredParams}}
- private final {{{dataType}}} {{paramName}};
- {{/requiredParams}}
- {{#optionalParams}}
- private {{{dataType}}} {{paramName}};
- {{/optionalParams}}
-
- private API{{operationId}}Request({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) {
- {{#requiredParams}}
- this.{{paramName}} = {{paramName}};
- {{/requiredParams}}
- }
-
- {{#optionalParams}}
- /**
- * Set {{paramName}}
- * @param {{paramName}} {{description}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}})
- * @return API{{operationId}}Request
- */
- public API{{operationId}}Request {{paramName}}({{{dataType}}} {{paramName}}) {
- this.{{paramName}} = {{paramName}};
- return this;
- }
-
- {{/optionalParams}}
- /**
- * Build call for {{operationId}}
- * @param _callback ApiCallback API callback
- * @return Call to execute
- * @throws ApiException If fail to serialize the request body object
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException {
- return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- }
-
- /**
- * Execute {{operationId}} request{{#returnType}}
- * @return {{.}}{{/returnType}}
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public {{{returnType}}}{{^returnType}}void{{/returnType}} execute() throws ApiException {
- {{#returnType}}ApiResponse<{{{.}}}> localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
- return localVarResp.getData();{{/returnType}}
- }
-
- /**
- * Execute {{operationId}} request with HTTP info returned
- * @return ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}>
- * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}> executeWithHttpInfo() throws ApiException {
- return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
- }
-
- /**
- * Execute {{operationId}} request (asynchronously)
- * @param _callback The callback to be executed when the API call finishes
- * @return The request call
- * @throws ApiException If fail to process the API call, e.g. serializing the request body object
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public okhttp3.Call executeAsync(final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> _callback) throws ApiException {
- return {{operationId}}Async({{#allParams}}{{paramName}}, {{/allParams}}_callback);
- }
- }
-
- /**
- * {{summary}}
- * {{notes}}{{#requiredParams}}
- * @param {{paramName}} {{description}} (required){{/requiredParams}}
- * @return API{{operationId}}Request
- {{#responses.0}}
- * @http.response.details
-
- Status Code Description Response Headers
- {{#responses}}
- {{code}} {{message}} {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}}
- {{/responses}}
-
- {{/responses.0}}
- {{#isDeprecated}}
- * @deprecated
- {{/isDeprecated}}
- {{#externalDocs}}
- * {{description}}
- * @see {{summary}} Documentation
- {{/externalDocs}}
- */
- {{#isDeprecated}}
- @Deprecated
- {{/isDeprecated}}
- public API{{operationId}}Request {{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) {
- return new API{{operationId}}Request({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}});
- }
- {{/vendorExtensions.x-group-parameters}}
- {{/operation}}
-}
-{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/apiException.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/apiException.mustache
deleted file mode 100644
index 59da3c51c261..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/apiException.mustache
+++ /dev/null
@@ -1,199 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}};
-
-import java.util.Map;
-import java.util.List;
-{{#caseInsensitiveResponseHeaders}}
-import java.util.Map.Entry;
-import java.util.TreeMap;
-{{/caseInsensitiveResponseHeaders}}
-
-import javax.ws.rs.core.GenericType;
-
-/**
- * ApiException class.
- */
-@SuppressWarnings("serial")
-{{>generatedAnnotation}}
-public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{
- private int code = 0;
- private Map> responseHeaders = null;
- private String responseBody = null;
- private {{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} errorObject = null;
- private GenericType errorObjectType = null;
-
- /**
- * Constructor for ApiException.
- */
- public ApiException() {}
-
- /**
- * Constructor for ApiException.
- *
- * @param throwable a {@link java.lang.Throwable} object
- */
- public ApiException(Throwable throwable) {
- super(throwable);
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param message the error message
- */
- public ApiException(String message) {
- super(message);
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param message the error message
- * @param throwable a {@link java.lang.Throwable} object
- * @param code HTTP status code
- * @param responseHeaders a {@link java.util.Map} of HTTP response headers
- * @param responseBody the response body
- */
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
- super(message, throwable);
- this.code = code;
- {{#caseInsensitiveResponseHeaders}}
- Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER);
- for(Entry> entry : responseHeaders.entrySet()){
- headers.put(entry.getKey().toLowerCase(), entry.getValue());
- }
- {{/caseInsensitiveResponseHeaders}}
- this.responseHeaders = {{#caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}};
- this.responseBody = responseBody;
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param message the error message
- * @param code HTTP status code
- * @param responseHeaders a {@link java.util.Map} of HTTP response headers
- * @param responseBody the response body
- */
- public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
- this(message, (Throwable) null, code, responseHeaders, responseBody);
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param message the error message
- * @param throwable a {@link java.lang.Throwable} object
- * @param code HTTP status code
- * @param responseHeaders a {@link java.util.Map} of HTTP response headers
- */
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
- this(message, throwable, code, responseHeaders, null);
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param code HTTP status code
- * @param responseHeaders a {@link java.util.Map} of HTTP response headers
- * @param responseBody the response body
- */
- public ApiException(int code, Map> responseHeaders, String responseBody) {
- this((String) null, (Throwable) null, code, responseHeaders, responseBody);
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param code HTTP status code
- * @param message a {@link java.lang.String} object
- */
- public ApiException(int code, String message) {
- super(message);
- this.code = code;
- }
-
- /**
- * Constructor for ApiException.
- *
- * @param code HTTP status code
- * @param message the error message
- * @param responseHeaders a {@link java.util.Map} of HTTP response headers
- * @param responseBody the response body
- */
- public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
- this(code, message);
- {{#caseInsensitiveResponseHeaders}}
- Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER);
- for(Entry> entry : responseHeaders.entrySet()){
- headers.put(entry.getKey().toLowerCase(), entry.getValue());
- }
- {{/caseInsensitiveResponseHeaders}}
- this.responseHeaders = {{#caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}};
- this.responseBody = responseBody;
- }
-
- /**
- * Get the HTTP status code.
- *
- * @return HTTP status code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * Get the HTTP response headers.
- *
- * @return A map of list of string
- */
- public Map> getResponseHeaders() {
- return responseHeaders;
- }
-
- /**
- * Get the HTTP response body.
- *
- * @return Response body in the form of string
- */
- public String getResponseBody() {
- return responseBody;
- }
-
- /**
- * Get the error object type.
- *
- * @return Error object type
- */
- public GenericType getErrorObjectType() {
- return errorObjectType;
- }
-
- /**
- * Set the error object type.
- *
- * @param errorObjectType object type
- */
- public void setErrorObjectType(GenericType errorObjectType) {
- this.errorObjectType = errorObjectType;
- }
-
- /**
- * Get the error object.
- *
- * @return Error object
- */
- public {{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} getErrorObject() {
- return errorObject;
- }
-
- /**
- * Get the error object.
- *
- * @param errorObject Error object
- */
- public void setErrorObject({{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} errorObject) {
- this.errorObject = errorObject;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_doc.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_doc.mustache
deleted file mode 100644
index 616ad65a5aca..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_doc.mustache
+++ /dev/null
@@ -1,118 +0,0 @@
-# {{classname}}{{#description}}
-{{.}}{{/description}}
-
-All URIs are relative to *{{basePath}}*
-
-Method | HTTP request | Description
-------------- | ------------- | -------------
-{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}}
-{{/operation}}{{/operations}}
-
-{{#operations}}
-{{#operation}}
-
-# **{{operationId}}**{{^vendorExtensions.x-group-parameters}}
-> {{#returnType}}{{.}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}){{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}
-> {{#returnType}}{{.}} {{/returnType}}{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}.{{paramName}}({{paramName}}){{/optionalParams}}.execute();{{/vendorExtensions.x-group-parameters}}
-
-{{summary}}{{#notes}}
-
-{{.}}{{/notes}}
-
-### Example
-```java
-// Import classes:
-import {{{invokerPackage}}}.ApiClient;
-import {{{invokerPackage}}}.ApiException;
-import {{{invokerPackage}}}.Configuration;{{#hasAuthMethods}}
-import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}}
-import {{{invokerPackage}}}.models.*;
-import {{{package}}}.{{{classname}}};
-
-public class 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}}
- {{/authMethods}}
- {{/hasAuthMethods}}
-
- {{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
- {{#allParams}}
- {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
- {{/allParams}}
- try {
- {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}{{^vendorExtensions.x-group-parameters}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}
- .{{{paramName}}}({{{paramName}}}){{/optionalParams}}
- .execute();{{/vendorExtensions.x-group-parameters}}{{#returnType}}
- System.out.println(result);{{/returnType}}
- } catch (ApiException e) {
- {{=< >=}}
- <#errorObjectSubtype>
- <^-first>} else -first>if (e.getErrorObject() instanceof <&.>) {
- // do something here
- <#-last>
- } else {
- // something else happened
- 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();
- }
- -last>
-
- <={{ }}=>
-
- }
- }
-}
-```
-
-### Parameters
-{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
-Name | Type | Description | Notes
-------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
-{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{^isContainer}}{{#defaultValue}} [default to {{.}}]{{/defaultValue}}{{/isContainer}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}}
-{{/allParams}}
-
-### Return type
-
-{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}}
-
-### Authorization
-
-{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}}
-
-### HTTP request headers
-
- - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
-
-{{#responses.0}}
-### HTTP response details
-| Status code | Description | Response headers |
-|-------------|-------------|------------------|
-{{#responses}}
-**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} {{/headers}}{{^headers.0}} - {{/headers.0}} |
-{{/responses}}
-{{/responses.0}}
-
-{{/operation}}
-{{/operations}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_test.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_test.mustache
deleted file mode 100644
index 98a30a60cd54..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/api_test.mustache
+++ /dev/null
@@ -1,56 +0,0 @@
-{{>licenseInfo}}
-
-package {{package}};
-
-import {{invokerPackage}}.ApiException;
-{{#imports}}import {{import}};
-{{/imports}}
-import org.junit.Test;
-import org.junit.Ignore;
-
-{{^fullJavaUtil}}
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-{{#supportStreaming}}
-import java.io.InputStream;
-{{/supportStreaming}}
-{{/fullJavaUtil}}
-
-/**
- * API tests for {{classname}}
- */
-@Ignore
-public class {{classname}}Test {
-
- private final {{classname}} api = new {{classname}}();
-
- {{#operations}}{{#operation}}
- /**
- * {{summary}}
- *
- * {{notes}}
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void {{operationId}}Test() throws ApiException {
- {{#allParams}}
- {{{dataType}}} {{paramName}} = null;
- {{/allParams}}
- {{#vendorExtensions.x-streaming}}
- InputStream response = api.{{operationId}}{{^vendorExtensions.x-group-parameters}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}
- .{{paramName}}({{paramName}}){{/optionalParams}}
- .execute();{{/vendorExtensions.x-group-parameters}}
- {{/vendorExtensions.x-streaming}}
- {{^vendorExtensions.x-streaming}}
- {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}{{^vendorExtensions.x-group-parameters}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}
- .{{paramName}}({{paramName}}){{/optionalParams}}
- .execute();{{/vendorExtensions.x-group-parameters}}
- {{/vendorExtensions.x-streaming}}
- // TODO: test validations
- }
- {{/operation}}{{/operations}}
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/ApiKeyAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/ApiKeyAuth.mustache
deleted file mode 100644
index a0dda669a899..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/ApiKeyAuth.mustache
+++ /dev/null
@@ -1,69 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.ApiException;
-import {{invokerPackage}}.Pair;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-{{>generatedAnnotation}}
-public class ApiKeyAuth implements Authentication {
- private final String location;
- private final String paramName;
-
- private String apiKey;
- private String apiKeyPrefix;
-
- public ApiKeyAuth(String location, String paramName) {
- this.location = location;
- this.paramName = paramName;
- }
-
- public String getLocation() {
- return location;
- }
-
- public String getParamName() {
- return paramName;
- }
-
- public String getApiKey() {
- return apiKey;
- }
-
- public void setApiKey(String apiKey) {
- this.apiKey = apiKey;
- }
-
- public String getApiKeyPrefix() {
- return apiKeyPrefix;
- }
-
- public void setApiKeyPrefix(String apiKeyPrefix) {
- this.apiKeyPrefix = apiKeyPrefix;
- }
-
- @Override
- public void applyToParams(List queryParams, Map headerParams, Map cookieParams,
- String payload, String method, URI uri) throws ApiException {
- if (apiKey == null) {
- return;
- }
- String value;
- if (apiKeyPrefix != null) {
- value = apiKeyPrefix + " " + apiKey;
- } else {
- value = apiKey;
- }
- if ("query".equals(location)) {
- queryParams.add(new Pair(paramName, value));
- } else if ("header".equals(location)) {
- headerParams.put(paramName, value);
- } else if ("cookie".equals(location)) {
- cookieParams.put(paramName, value);
- }
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/Authentication.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/Authentication.mustache
deleted file mode 100644
index c4ad338c793b..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/Authentication.mustache
+++ /dev/null
@@ -1,25 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.Pair;
-import {{invokerPackage}}.ApiException;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-public interface Authentication {
- /**
- * Apply authentication settings to header and query params.
- *
- * @param queryParams List of query parameters
- * @param headerParams Map of header parameters
- * @param cookieParams Map of cookie parameters
- * @param payload HTTP request body
- * @param method HTTP method
- * @param uri URI
- * @throws ApiException if failed to update the parameters
- */
- void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException;
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBasicAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBasicAuth.mustache
deleted file mode 100644
index 417a89e34ccd..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBasicAuth.mustache
+++ /dev/null
@@ -1,46 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.Pair;
-import {{invokerPackage}}.ApiException;
-
-import okhttp3.Credentials;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-import java.io.UnsupportedEncodingException;
-
-public class HttpBasicAuth implements Authentication {
- private String username;
- private String password;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- @Override
- public void applyToParams(List queryParams, Map headerParams, Map cookieParams,
- String payload, String method, URI uri) throws ApiException {
- if (username == null && password == null) {
- return;
- }
- headerParams.put("Authorization", Credentials.basic(
- username == null ? "" : username,
- password == null ? "" : password));
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBearerAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBearerAuth.mustache
deleted file mode 100644
index c8a9fce29650..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/HttpBearerAuth.mustache
+++ /dev/null
@@ -1,52 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.ApiException;
-import {{invokerPackage}}.Pair;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-{{>generatedAnnotation}}
-public class HttpBearerAuth implements Authentication {
- private final String scheme;
- private String bearerToken;
-
- public HttpBearerAuth(String scheme) {
- this.scheme = scheme;
- }
-
- /**
- * Gets the token, which together with the scheme, will be sent as the value of the Authorization header.
- *
- * @return The bearer token
- */
- public String getBearerToken() {
- return bearerToken;
- }
-
- /**
- * Sets the token, which together with the scheme, will be sent as the value of the Authorization header.
- *
- * @param bearerToken The bearer token to send in the Authorization header
- */
- public void setBearerToken(String bearerToken) {
- this.bearerToken = bearerToken;
- }
-
- @Override
- public void applyToParams(List queryParams, Map headerParams, Map cookieParams,
- String payload, String method, URI uri) throws ApiException {
- if (bearerToken == null) {
- return;
- }
-
- headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken);
- }
-
- private static String upperCaseBearer(String scheme) {
- return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme;
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuth.mustache
deleted file mode 100644
index 34d359857181..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuth.mustache
+++ /dev/null
@@ -1,31 +0,0 @@
-{{>licenseInfo}}
-
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.Pair;
-import {{invokerPackage}}.ApiException;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-{{>generatedAnnotation}}
-public class OAuth implements Authentication {
- private String accessToken;
-
- public String getAccessToken() {
- return accessToken;
- }
-
- public void setAccessToken(String accessToken) {
- this.accessToken = accessToken;
- }
-
- @Override
- public void applyToParams(List queryParams, Map headerParams, Map cookieParams,
- String payload, String method, URI uri) throws ApiException {
- if (accessToken != null) {
- headerParams.put("Authorization", "Bearer " + accessToken);
- }
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuthOkHttpClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuthOkHttpClient.mustache
deleted file mode 100644
index cb0e82505507..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/OAuthOkHttpClient.mustache
+++ /dev/null
@@ -1,70 +0,0 @@
-{{#hasOAuthMethods}}
-package {{invokerPackage}}.auth;
-
-import okhttp3.OkHttpClient;
-import okhttp3.MediaType;
-import okhttp3.Request;
-import okhttp3.RequestBody;
-import okhttp3.Response;
-
-import org.apache.oltu.oauth2.client.HttpClient;
-import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
-import org.apache.oltu.oauth2.client.response.OAuthClientResponse;
-import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory;
-import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
-import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class OAuthOkHttpClient implements HttpClient {
- private OkHttpClient client;
-
- public OAuthOkHttpClient() {
- this.client = new OkHttpClient();
- }
-
- public OAuthOkHttpClient(OkHttpClient client) {
- this.client = client;
- }
-
- @Override
- public T execute(OAuthClientRequest request, Map headers,
- String requestMethod, Class responseClass)
- throws OAuthSystemException, OAuthProblemException {
-
- MediaType mediaType = MediaType.parse("application/json");
- Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());
-
- if(headers != null) {
- for (Entry entry : headers.entrySet()) {
- if (entry.getKey().equalsIgnoreCase("Content-Type")) {
- mediaType = MediaType.parse(entry.getValue());
- } else {
- requestBuilder.addHeader(entry.getKey(), entry.getValue());
- }
- }
- }
-
- RequestBody body = request.getBody() != null ? RequestBody.create(request.getBody(), mediaType) : null;
- requestBuilder.method(requestMethod, body);
-
- try {
- Response response = client.newCall(requestBuilder.build()).execute();
- return OAuthClientResponseFactory.createCustomResponse(
- response.body().string(),
- response.body().contentType().toString(),
- response.code(),
- responseClass);
- } catch (IOException e) {
- throw new OAuthSystemException(e);
- }
- }
-
- @Override
- public void shutdown() {
- // Nothing to do here
- }
-}
-{{/hasOAuthMethods}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/RetryingOAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/RetryingOAuth.mustache
deleted file mode 100644
index 49f3d0ccc30a..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/auth/RetryingOAuth.mustache
+++ /dev/null
@@ -1,213 +0,0 @@
-{{#hasOAuthMethods}}
-package {{invokerPackage}}.auth;
-
-import {{invokerPackage}}.ApiException;
-import {{invokerPackage}}.Pair;
-
-import okhttp3.Interceptor;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.Response;
-
-import org.apache.oltu.oauth2.client.OAuthClient;
-import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
-import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
-import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder;
-import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse;
-import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
-import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
-import org.apache.oltu.oauth2.common.message.types.GrantType;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.util.Map;
-import java.util.List;
-
-public class RetryingOAuth extends OAuth implements Interceptor {
- private OAuthClient oAuthClient;
-
- private TokenRequestBuilder tokenRequestBuilder;
-
- /**
- * @param client An OkHttp client
- * @param tokenRequestBuilder A token request builder
- */
- public RetryingOAuth(OkHttpClient client, TokenRequestBuilder tokenRequestBuilder) {
- this.oAuthClient = new OAuthClient(new OAuthOkHttpClient(client));
- this.tokenRequestBuilder = tokenRequestBuilder;
- }
-
- /**
- * @param tokenRequestBuilder A token request builder
- */
- public RetryingOAuth(TokenRequestBuilder tokenRequestBuilder) {
- this(new OkHttpClient(), tokenRequestBuilder);
- }
-
- /**
- * @param tokenUrl The token URL to be used for this OAuth2 flow.
- * Applicable to the following OAuth2 flows: "password", "clientCredentials" and "authorizationCode".
- * The value must be an absolute URL.
- * @param clientId The OAuth2 client ID for the "clientCredentials" flow.
- * @param flow OAuth flow.
- * @param clientSecret The OAuth2 client secret for the "clientCredentials" flow.
- * @param parameters A map of string.
- */
- public RetryingOAuth(
- String tokenUrl,
- String clientId,
- OAuthFlow flow,
- String clientSecret,
- Map parameters
- ) {
- this(OAuthClientRequest.tokenLocation(tokenUrl)
- .setClientId(clientId)
- .setClientSecret(clientSecret));
- setFlow(flow);
- if (parameters != null) {
- for (String paramName : parameters.keySet()) {
- tokenRequestBuilder.setParameter(paramName, parameters.get(paramName));
- }
- }
- }
-
- /**
- * Set the OAuth flow
- *
- * @param flow The OAuth flow.
- */
- public void setFlow(OAuthFlow flow) {
- switch(flow) {
- case ACCESS_CODE:
- tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE);
- break;
- case IMPLICIT:
- tokenRequestBuilder.setGrantType(GrantType.IMPLICIT);
- break;
- case PASSWORD:
- tokenRequestBuilder.setGrantType(GrantType.PASSWORD);
- break;
- case APPLICATION:
- tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS);
- break;
- default:
- break;
- }
- }
-
- @Override
- public Response intercept(Chain chain) throws IOException {
- return retryingIntercept(chain, true);
- }
-
- private Response retryingIntercept(Chain chain, boolean updateTokenAndRetryOnAuthorizationFailure) throws IOException {
- Request request = chain.request();
-
- // If the request already has an authorization (e.g. Basic auth), proceed with the request as is
- if (request.header("Authorization") != null) {
- return chain.proceed(request);
- }
-
- // Get the token if it has not yet been acquired
- if (getAccessToken() == null) {
- updateAccessToken(null);
- }
-
- OAuthClientRequest oAuthRequest;
- if (getAccessToken() != null) {
- // Build the request
- Request.Builder requestBuilder = request.newBuilder();
-
- String requestAccessToken = getAccessToken();
- try {
- oAuthRequest =
- new OAuthBearerClientRequest(request.url().toString()).
- setAccessToken(requestAccessToken).
- buildHeaderMessage();
- } catch (OAuthSystemException e) {
- throw new IOException(e);
- }
-
- Map headers = oAuthRequest.getHeaders();
- for (String headerName : headers.keySet()) {
- requestBuilder.addHeader(headerName, headers.get(headerName));
- }
- requestBuilder.url(oAuthRequest.getLocationUri());
-
- // Execute the request
- Response response = chain.proceed(requestBuilder.build());
-
- // 401/403 response codes most likely indicate an expired access token, unless it happens two times in a row
- if (
- response != null &&
- ( response.code() == HttpURLConnection.HTTP_UNAUTHORIZED ||
- response.code() == HttpURLConnection.HTTP_FORBIDDEN ) &&
- updateTokenAndRetryOnAuthorizationFailure
- ) {
- try {
- if (updateAccessToken(requestAccessToken)) {
- response.body().close();
- return retryingIntercept(chain, false);
- }
- } catch (Exception e) {
- response.body().close();
- throw e;
- }
- }
- return response;
- }
- else {
- return chain.proceed(chain.request());
- }
- }
-
- /**
- * Returns true if the access token has been updated
- *
- * @param requestAccessToken the request access token
- * @return True if the update is successful
- * @throws java.io.IOException If fail to update the access token
- */
- public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
- if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
- try {
- OAuthJSONAccessTokenResponse accessTokenResponse =
- oAuthClient.accessToken(tokenRequestBuilder.buildBodyMessage());
- if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
- setAccessToken(accessTokenResponse.getAccessToken());
- }
- } catch (OAuthSystemException | OAuthProblemException e) {
- throw new IOException(e);
- }
- }
- return getAccessToken() == null || !getAccessToken().equals(requestAccessToken);
- }
-
- /**
- * Gets the token request builder
- *
- * @return A token request builder
- * @throws java.io.IOException If fail to update the access token
- */
- public TokenRequestBuilder getTokenRequestBuilder() {
- return tokenRequestBuilder;
- }
-
- /**
- * Sets the token request builder
- *
- * @param tokenRequestBuilder Token request builder
- */
- public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) {
- this.tokenRequestBuilder = tokenRequestBuilder;
- }
-
- // Applying authorization to parameters is performed in the retryingIntercept method
- @Override
- public void applyToParams(List queryParams, Map headerParams, Map cookieParams,
- String payload, String method, URI uri) throws ApiException {
- // No implementation necessary
- }
-}
-{{/hasOAuthMethods}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.gradle.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.gradle.mustache
deleted file mode 100644
index c97cb873e97b..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.gradle.mustache
+++ /dev/null
@@ -1,169 +0,0 @@
-apply plugin: 'idea'
-apply plugin: 'eclipse'
-{{#sourceFolder}}
-apply plugin: 'java'
-{{/sourceFolder}}
-apply plugin: 'com.diffplug.spotless'
-
-group = '{{groupId}}'
-version = '{{artifactVersion}}'
-
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:2.3.+'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.17.1'
- }
-}
-
-repositories {
- mavenCentral()
-}
-{{#sourceFolder}}
-sourceSets {
- main.java.srcDirs = ['{{sourceFolder}}']
-}
-
-{{/sourceFolder}}
-if(hasProperty('target') && target == 'android') {
-
- apply plugin: 'com.android.library'
- apply plugin: 'com.github.dcendents.android-maven'
-
- android {
- compileSdkVersion 25
- buildToolsVersion '25.0.2'
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 25
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- // Rename the aar correctly
- libraryVariants.all { variant ->
- variant.outputs.each { output ->
- def outputFile = output.outputFile
- if (outputFile != null && outputFile.name.endsWith('.aar')) {
- def fileName = "${project.name}-${variant.baseName}-${version}.aar"
- output.outputFile = new File(outputFile.parent, fileName)
- }
- }
- }
-
- dependencies {
- provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
- }
- }
-
- afterEvaluate {
- android.libraryVariants.all { variant ->
- def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
- task.description = "Create jar artifact for ${variant.name}"
- task.dependsOn variant.javaCompile
- task.from variant.javaCompile.destinationDir
- task.destinationDir = project.file("${project.buildDir}/outputs/jar")
- task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
- artifacts.add('archives', task);
- }
- }
-
- task sourcesJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier = 'sources'
- }
-
- artifacts {
- archives sourcesJar
- }
-
-} else {
-
- apply plugin: 'java'
- apply plugin: 'maven-publish'
-
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
-
- publishing {
- publications {
- maven(MavenPublication) {
- artifactId = '{{artifactId}}'
- from components.java
- }
- }
- }
-
- task execute(type:JavaExec) {
- main = System.getProperty('mainClass')
- classpath = sourceSets.main.runtimeClasspath
- }
-}
-
-ext {
- jakarta_annotation_version = "1.3.5"
-}
-
-dependencies {
- implementation 'io.swagger:swagger-annotations:1.5.24'
- implementation "com.google.code.findbugs:jsr305:3.0.2"
- implementation 'com.squareup.okhttp3:okhttp:4.9.1'
- implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
- implementation 'com.google.code.gson:gson:2.8.6'
- implementation 'io.gsonfire:gson-fire:1.8.4'
- {{#openApiNullable}}
- implementation 'org.openapitools:jackson-databind-nullable:0.2.1'
- {{/openApiNullable}}
- {{#hasOAuthMethods}}
- implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1'
- {{/hasOAuthMethods}}
- implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
- {{#joda}}
- implementation 'joda-time:joda-time:2.9.9'
- {{/joda}}
- {{#threetenbp}}
- implementation 'org.threeten:threetenbp:1.4.3'
- {{/threetenbp}}
- {{#dynamicOperations}}
- implementation 'io.swagger.parser.v3:swagger-parser-v3:2.0.23'
- {{/dynamicOperations}}
- implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
- testImplementation 'junit:junit:4.13.1'
- testImplementation 'org.mockito:mockito-core:3.11.2'
-}
-
-javadoc {
- options.tags = [ "http.response.details:a:Http Response Details" ]
-}
-
-// Use spotless plugin to automatically format code, remove unused import, etc
-// To apply changes directly to the file, run `gradlew spotlessApply`
-// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
-spotless {
- // comment out below to run spotless as part of the `check` task
- enforceCheck false
-
- format 'misc', {
- // define the files (e.g. '*.gradle', '*.md') to apply `misc` to
- target '.gitignore'
-
- // define the steps to apply to those files
- trimTrailingWhitespace()
- indentWithSpaces() // Takes an integer argument if you don't like 4
- endWithNewline()
- }
- java {
- // don't need to set target, it is inferred from java
-
- // apply a specific flavor of google-java-format
- googleJavaFormat('1.8').aosp().reflowLongStrings()
-
- removeUnusedImports()
- importOrder()
- }
-}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.sbt.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.sbt.mustache
deleted file mode 100644
index 5e0c74c55c05..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/build.sbt.mustache
+++ /dev/null
@@ -1,39 +0,0 @@
-lazy val root = (project in file(".")).
- settings(
- organization := "{{groupId}}",
- name := "{{artifactId}}",
- version := "{{artifactVersion}}",
- scalaVersion := "2.11.4",
- scalacOptions ++= Seq("-feature"),
- javacOptions in compile ++= Seq("-Xlint:deprecation"),
- publishArtifact in (Compile, packageDoc) := false,
- resolvers += Resolver.mavenLocal,
- libraryDependencies ++= Seq(
- "io.swagger" % "swagger-annotations" % "1.5.24",
- "com.squareup.okhttp3" % "okhttp" % "4.9.1",
- "com.squareup.okhttp3" % "logging-interceptor" % "4.9.1",
- "com.google.code.gson" % "gson" % "2.8.6",
- "org.apache.commons" % "commons-lang3" % "3.10",
- {{#openApiNullable}}
- "org.openapitools" % "jackson-databind-nullable" % "0.2.2",
- {{/openApiNullable}}
- {{#hasOAuthMethods}}
- "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1",
- {{/hasOAuthMethods}}
- {{#joda}}
- "joda-time" % "joda-time" % "2.9.9" % "compile",
- {{/joda}}
- {{#threetenbp}}
- "org.threeten" % "threetenbp" % "1.4.3" % "compile",
- {{/threetenbp}}
- {{#dynamicOperations}}
- "io.swagger.parser.v3" % "swagger-parser-v3" "2.0.23" % "compile"
- {{/dynamicOperations}}
- "io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
- "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
- "com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
- "jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
- "junit" % "junit" % "4.13.1" % "test",
- "com.novocode" % "junit-interface" % "0.10" % "test"
- )
- )
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pom.mustache
deleted file mode 100644
index 10dfc15ab7fe..000000000000
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pom.mustache
+++ /dev/null
@@ -1,420 +0,0 @@
-
- 4.0.0
- {{groupId}}
- {{artifactId}}
- jar
- {{artifactId}}
- {{artifactVersion}}
- {{artifactUrl}}
- {{artifactDescription}}
-
- {{scmConnection}}
- {{scmDeveloperConnection}}
- {{scmUrl}}
-
-{{#parentOverridden}}
-
- {{{parentGroupId}}}
- {{{parentArtifactId}}}
- {{{parentVersion}}}
-
-{{/parentOverridden}}
-
-
-
- {{licenseName}}
- {{licenseUrl}}
- repo
-
-
-
-
-
- {{developerName}}
- {{developerEmail}}
- {{developerOrganization}}
- {{developerOrganizationUrl}}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- true
- 128m
- 512m
-
- -Xlint:all
- -J-Xss4m
-
-
-
-
- org.apache.maven.plugins
- maven-enforcer-plugin
- 3.0.0
-
-
- enforce-maven
-
- enforce
-
-
-
-
- 2.2.0
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M5
-
-
-
- loggerPath
- conf/log4j.properties
-
-
- -Xms512m -Xmx1500m
- methods
- 10
-
-
-
- maven-dependency-plugin
-
-
- package
-
- copy-dependencies
-
-
- ${project.build.directory}/lib
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.2.0
-
-
-
- test-jar
-
-
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 3.2.0
-
-
- add_sources
- generate-sources
-
- add-source
-
-
-
- {{{sourceFolder}}}
-
-
-
-
- add_test_sources
- generate-test-sources
-
- add-test-source
-
-
-
- src/test/java
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.3.1
-
-
- attach-javadocs
-
- jar
-
-
-
-
- none
-
-
- http.response.details
- a
- Http Response Details:
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.2.0
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
-
- com.diffplug.spotless
- spotless-maven-plugin
- ${spotless.version}
-
-
-
-
-
-
- .gitignore
-
-
-
-
-
- true
- 4
-
-
-
-
-
-
-
-
-
- 1.8
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
- sign-artifacts
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 3.0.1
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
-
-
-
-
-
-
- io.swagger
- swagger-annotations
- ${swagger-core-version}
-
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
- com.squareup.okhttp3
- okhttp
- ${okhttp-version}
-
-
- com.squareup.okhttp3
- logging-interceptor
- ${okhttp-version}
-
-
- com.google.code.gson
- gson
- ${gson-version}
-
-
- io.gsonfire
- gson-fire
- ${gson-fire-version}
-
- {{#hasOAuthMethods}}
-
- org.apache.oltu.oauth2
- org.apache.oltu.oauth2.client
- 1.0.1
-
- {{/hasOAuthMethods}}
-
- org.apache.commons
- commons-lang3
- ${commons-lang3-version}
-
- {{#joda}}
-
- joda-time
- joda-time
- ${jodatime-version}
-
- {{/joda}}
- {{#threetenbp}}
-
- org.threeten
- threetenbp
- ${threetenbp-version}
-
- {{/threetenbp}}
- {{#dynamicOperations}}
-
- io.swagger.parser.v3
- swagger-parser-v3
- 2.0.28
-
- {{/dynamicOperations}}
- {{#useBeanValidation}}
-
-
- jakarta.validation
- jakarta.validation-api
- ${beanvalidation-version}
- provided
-
- {{/useBeanValidation}}
- {{#performBeanValidation}}
-
-
- org.hibernate
- hibernate-validator
- 5.4.3.Final
-
-
- jakarta.el
- jakarta.el-api
- ${jakarta.el-version}
-
- {{/performBeanValidation}}
- {{#parcelableModel}}
-
-
- com.google.android
- android
- 4.1.1.4
- provided
-
- {{/parcelableModel}}
-
- jakarta.annotation
- jakarta.annotation-api
- ${jakarta-annotation-version}
- provided
-
- {{#openApiNullable}}
-
- org.openapitools
- jackson-databind-nullable
- ${jackson-databind-nullable-version}
-
- {{/openApiNullable}}
-
- javax.ws.rs
- jsr311-api
- 1.1.1
-
-
- javax.ws.rs
- javax.ws.rs-api
- 2.0
-
-
-
- junit
- junit
- ${junit-version}
- test
-
-
- org.mockito
- mockito-core
- 3.12.4
- test
-
-
-
- 1.8
- ${java.version}
- ${java.version}
- 1.8.5
- 1.6.3
- 4.9.2
- 2.8.8
- 3.12.0
- {{#openApiNullable}}
- 0.2.2
- {{/openApiNullable}}
- {{#joda}}
- 2.10.9
- {{/joda}}
- {{#threetenbp}}
- 1.5.0
- {{/threetenbp}}
- 1.3.5
-{{#performBeanValidation}}
- 3.0.3
-{{/performBeanValidation}}
-{{#useBeanValidation}}
- 2.0.2
-{{/useBeanValidation}}
- 4.13.2
- UTF-8
- 2.17.3
-
-
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/AbstractOpenApiSchema.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/AbstractOpenApiSchema.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/AbstractOpenApiSchema.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/AbstractOpenApiSchema.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
index 52fc1c5492d7..82eef936df65 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache
@@ -1303,6 +1303,7 @@ public class ApiClient {
/**
* Build HTTP call with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1325,6 +1326,7 @@ public class ApiClient {
/**
* Build an HTTP request with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1393,6 +1395,7 @@ public class ApiClient {
/**
* Build full URL by concatenating base path, the given sub path and query parameters.
*
+ * @param baseUrl The base URL
* @param path The sub path
* @param queryParams The query parameters
* @param collectionQueryParams The collection query parameters
@@ -1487,6 +1490,7 @@ public class ApiClient {
* @param payload HTTP request body
* @param method HTTP method
* @param uri URI
+ * @throws org.openapitools.client.ApiException If fails to update the parameters
*/
public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
Map cookieParams, String payload, String method, URI uri) throws ApiException {
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/JSON.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/JSON.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/JSON.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/anyof_model.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
index e81f874f1e1b..410639f9a72e 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache
@@ -51,6 +51,7 @@ import java.util.Map;
import java.io.InputStream;
{{/supportStreaming}}
{{/fullJavaUtil}}
+import javax.ws.rs.core.GenericType;
{{#operations}}
public class {{classname}} {
@@ -119,7 +120,6 @@ public class {{classname}} {
{{/isDeprecated}}
public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { {{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}} };
@@ -326,13 +326,32 @@ public class {{classname}} {
{{/isDeprecated}}
public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-streaming}} InputStream {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null);
- {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
- return localVarApiClient.executeStream(localVarCall, localVarReturnType);{{/returnType}}
+ {{#returnType}}
+ try {
+ Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
+ return localVarApiClient.executeStream(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){}.getType()));
+ e.setErrorObjectType(new GenericType<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){});
+ throw e;
+ }
+ {{/returnType}}
}
{{/vendorExtensions.x-streaming}}{{^vendorExtensions.x-streaming}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException {
okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null);
- {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);{{/returnType}}{{^returnType}}return localVarApiClient.execute(localVarCall);{{/returnType}}
+ {{^returnType}}
+ return localVarApiClient.execute(localVarCall);
+ {{/returnType}}
+ {{#returnType}}
+ try {
+ Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){}.getType()));
+ e.setErrorObjectType(new GenericType<{{{errorObjectType}}}{{^errorObjectType}}{{{returnType}}}{{/errorObjectType}}>(){});
+ throw e;
+ }
+ {{/returnType}}
}
{{/vendorExtensions.x-streaming}}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
index 4bec51da938e..59da3c51c261 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/apiException.mustache
@@ -9,6 +9,8 @@ import java.util.Map.Entry;
import java.util.TreeMap;
{{/caseInsensitiveResponseHeaders}}
+import javax.ws.rs.core.GenericType;
+
/**
* ApiException class.
*/
@@ -18,6 +20,8 @@ public class ApiException extends{{#useRuntimeException}} RuntimeException {{/us
private int code = 0;
private Map> responseHeaders = null;
private String responseBody = null;
+ private {{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} errorObject = null;
+ private GenericType errorObjectType = null;
/**
* Constructor for ApiException.
@@ -156,4 +160,40 @@ public class ApiException extends{{#useRuntimeException}} RuntimeException {{/us
public String getResponseBody() {
return responseBody;
}
+
+ /**
+ * Get the error object type.
+ *
+ * @return Error object type
+ */
+ public GenericType getErrorObjectType() {
+ return errorObjectType;
+ }
+
+ /**
+ * Set the error object type.
+ *
+ * @param errorObjectType object type
+ */
+ public void setErrorObjectType(GenericType errorObjectType) {
+ this.errorObjectType = errorObjectType;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @return Error object
+ */
+ public {{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} getErrorObject() {
+ return errorObject;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @param errorObject Error object
+ */
+ public void setErrorObject({{{errorObjectType}}}{{^errorObjectType}}Object{{/errorObjectType}} errorObject) {
+ this.errorObject = errorObject;
+ }
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
index 7b09aa700d61..49f3d0ccc30a 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/auth/RetryingOAuth.mustache
@@ -29,22 +29,31 @@ public class RetryingOAuth extends OAuth implements Interceptor {
private TokenRequestBuilder tokenRequestBuilder;
+ /**
+ * @param client An OkHttp client
+ * @param tokenRequestBuilder A token request builder
+ */
public RetryingOAuth(OkHttpClient client, TokenRequestBuilder tokenRequestBuilder) {
this.oAuthClient = new OAuthClient(new OAuthOkHttpClient(client));
this.tokenRequestBuilder = tokenRequestBuilder;
}
+ /**
+ * @param tokenRequestBuilder A token request builder
+ */
public RetryingOAuth(TokenRequestBuilder tokenRequestBuilder) {
this(new OkHttpClient(), tokenRequestBuilder);
}
/**
- @param tokenUrl The token URL to be used for this OAuth2 flow.
- Applicable to the following OAuth2 flows: "password", "clientCredentials" and "authorizationCode".
- The value must be an absolute URL.
- @param clientId The OAuth2 client ID for the "clientCredentials" flow.
- @param clientSecret The OAuth2 client secret for the "clientCredentials" flow.
- */
+ * @param tokenUrl The token URL to be used for this OAuth2 flow.
+ * Applicable to the following OAuth2 flows: "password", "clientCredentials" and "authorizationCode".
+ * The value must be an absolute URL.
+ * @param clientId The OAuth2 client ID for the "clientCredentials" flow.
+ * @param flow OAuth flow.
+ * @param clientSecret The OAuth2 client secret for the "clientCredentials" flow.
+ * @param parameters A map of string.
+ */
public RetryingOAuth(
String tokenUrl,
String clientId,
@@ -63,6 +72,11 @@ public class RetryingOAuth extends OAuth implements Interceptor {
}
}
+ /**
+ * Set the OAuth flow
+ *
+ * @param flow The OAuth flow.
+ */
public void setFlow(OAuthFlow flow) {
switch(flow) {
case ACCESS_CODE:
@@ -148,8 +162,12 @@ public class RetryingOAuth extends OAuth implements Interceptor {
}
}
- /*
+ /**
* Returns true if the access token has been updated
+ *
+ * @param requestAccessToken the request access token
+ * @return True if the update is successful
+ * @throws java.io.IOException If fail to update the access token
*/
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
@@ -166,10 +184,21 @@ public class RetryingOAuth extends OAuth implements Interceptor {
return getAccessToken() == null || !getAccessToken().equals(requestAccessToken);
}
+ /**
+ * Gets the token request builder
+ *
+ * @return A token request builder
+ * @throws java.io.IOException If fail to update the access token
+ */
public TokenRequestBuilder getTokenRequestBuilder() {
return tokenRequestBuilder;
}
+ /**
+ * Sets the token request builder
+ *
+ * @param tokenRequestBuilder Token request builder
+ */
public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) {
this.tokenRequestBuilder = tokenRequestBuilder;
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/model.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/model.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/model.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/oneof_model.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
similarity index 100%
rename from modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson-nextgen/pojo.mustache
rename to modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
index 94c057b1424a..10dfc15ab7fe 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
@@ -364,6 +364,16 @@
${jackson-databind-nullable-version}
{{/openApiNullable}}
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+ 2.0
+
junit
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
index e5613d745cf9..f112a670c313 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java
@@ -64,7 +64,7 @@ public void testIgnoreFileProcessing() throws IOException {
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 42);
+ Assert.assertEquals(files.size(), 43);
// Check expected generated files
// api sanity check
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
index 47b490e46ef2..bc18eeb917a6 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java
@@ -291,7 +291,7 @@ public void testGeneratePing() throws Exception {
DefaultGenerator generator = new DefaultGenerator();
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 38);
+ Assert.assertEquals(files.size(), 39);
TestUtils.ensureContainsFile(files, output, ".gitignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
@@ -360,7 +360,7 @@ public void testGeneratePingSomeObj() throws Exception {
DefaultGenerator generator = new DefaultGenerator();
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 41);
+ Assert.assertEquals(files.size(), 42);
TestUtils.ensureContainsFile(files, output, ".gitignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator-ignore");
TestUtils.ensureContainsFile(files, output, ".openapi-generator/FILES");
@@ -1005,7 +1005,7 @@ public void testAllowModelWithNoProperties() throws Exception {
DefaultGenerator generator = new DefaultGenerator();
List files = generator.opts(clientOptInput).generate();
- Assert.assertEquals(files.size(), 47);
+ Assert.assertEquals(files.size(), 48);
TestUtils.ensureContainsFile(files, output, "src/main/java/org/openapitools/client/model/RealCommand.java");
TestUtils.ensureContainsFile(files, output, "src/main/java/org/openapitools/client/model/Command.java");
diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml
deleted file mode 100644
index 2ea7d82e8c0b..000000000000
--- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature-okhttp-gson-nextgen.yaml
+++ /dev/null
@@ -1,2184 +0,0 @@
-openapi: 3.0.0
-info:
- description: >-
- This spec is mainly for testing Petstore server and contains fake endpoints,
- models. Please do not use this for any other purpose. Special characters: "
- \
- version: 1.0.0
- title: OpenAPI Petstore
- license:
- name: Apache-2.0
- url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
-tags:
- - name: pet
- description: Everything about your Pets
- - name: store
- description: Access to Petstore orders
- - name: user
- description: Operations about user
-paths:
- /foo:
- get:
- responses:
- default:
- description: response
- content:
- application/json:
- schema:
- type: object
- properties:
- string:
- $ref: '#/components/schemas/Foo'
- /pet:
- servers:
- - url: 'http://petstore.swagger.io/v2'
- - url: 'http://path-server-test.petstore.local/v2'
- post:
- tags:
- - pet
- summary: Add a new pet to the store
- description: ''
- operationId: addPet
- responses:
- '405':
- description: Invalid input
- security:
- - http_signature_test: []
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- requestBody:
- $ref: '#/components/requestBodies/Pet'
- put:
- tags:
- - pet
- summary: Update an existing pet
- description: ''
- operationId: updatePet
- responses:
- '400':
- description: Invalid ID supplied
- '404':
- description: Pet not found
- '405':
- description: Validation exception
- security:
- - http_signature_test: []
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- requestBody:
- $ref: '#/components/requestBodies/Pet'
- /pet/findByStatus:
- get:
- tags:
- - pet
- summary: Finds Pets by status
- description: Multiple status values can be provided with comma separated strings
- operationId: findPetsByStatus
- parameters:
- - name: status
- in: query
- description: Status values that need to be considered for filter
- required: true
- style: form
- explode: false
- deprecated: true
- schema:
- type: array
- items:
- type: string
- enum:
- - available
- - pending
- - sold
- default: available
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/Pet'
- application/json:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/Pet'
- '400':
- description: Invalid status value
- security:
- - http_signature_test: []
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- /pet/findByTags:
- get:
- tags:
- - pet
- summary: Finds Pets by tags
- description: >-
- Multiple tags can be provided with comma separated strings. Use tag1,
- tag2, tag3 for testing.
- operationId: findPetsByTags
- parameters:
- - name: tags
- in: query
- description: Tags to filter by
- required: true
- style: form
- explode: false
- schema:
- type: array
- items:
- type: string
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/Pet'
- application/json:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/Pet'
- '400':
- description: Invalid tag value
- security:
- - http_signature_test: []
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- deprecated: true
- '/pet/{petId}':
- get:
- tags:
- - pet
- summary: Find pet by ID
- description: Returns a single pet
- operationId: getPetById
- parameters:
- - name: petId
- in: path
- description: ID of pet to return
- required: true
- schema:
- type: integer
- format: int64
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- $ref: '#/components/schemas/Pet'
- application/json:
- schema:
- $ref: '#/components/schemas/Pet'
- '400':
- description: Invalid ID supplied
- '404':
- description: Pet not found
- security:
- - api_key: []
- post:
- tags:
- - pet
- summary: Updates a pet in the store with form data
- description: ''
- operationId: updatePetWithForm
- parameters:
- - name: petId
- in: path
- description: ID of pet that needs to be updated
- required: true
- schema:
- type: integer
- format: int64
- responses:
- '405':
- description: Invalid input
- security:
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- requestBody:
- content:
- application/x-www-form-urlencoded:
- schema:
- type: object
- properties:
- name:
- description: Updated name of the pet
- type: string
- status:
- description: Updated status of the pet
- type: string
- delete:
- tags:
- - pet
- summary: Deletes a pet
- description: ''
- operationId: deletePet
- parameters:
- - name: api_key
- in: header
- required: false
- schema:
- type: string
- - name: petId
- in: path
- description: Pet id to delete
- required: true
- schema:
- type: integer
- format: int64
- responses:
- '400':
- description: Invalid pet value
- security:
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- '/pet/{petId}/uploadImage':
- post:
- tags:
- - pet
- summary: uploads an image
- description: ''
- operationId: uploadFile
- parameters:
- - name: petId
- in: path
- description: ID of pet to update
- required: true
- schema:
- type: integer
- format: int64
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ApiResponse'
- security:
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- requestBody:
- content:
- multipart/form-data:
- schema:
- type: object
- properties:
- additionalMetadata:
- description: Additional data to pass to server
- type: string
- file:
- description: file to upload
- type: string
- format: binary
- /store/inventory:
- get:
- tags:
- - store
- summary: Returns pet inventories by status
- description: Returns a map of status codes to quantities
- operationId: getInventory
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- type: object
- additionalProperties:
- type: integer
- format: int32
- security:
- - api_key: []
- /store/order:
- post:
- tags:
- - store
- summary: Place an order for a pet
- description: ''
- operationId: placeOrder
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- $ref: '#/components/schemas/Order'
- application/json:
- schema:
- $ref: '#/components/schemas/Order'
- '400':
- description: Invalid Order
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Order'
- description: order placed for purchasing the pet
- required: true
- '/store/order/{order_id}':
- get:
- tags:
- - store
- summary: Find purchase order by ID
- description: >-
- For valid response try integer IDs with value <= 5 or > 10. Other values
- will generated exceptions
- operationId: getOrderById
- parameters:
- - name: order_id
- in: path
- description: ID of pet that needs to be fetched
- required: true
- schema:
- type: integer
- format: int64
- minimum: 1
- maximum: 5
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- $ref: '#/components/schemas/Order'
- application/json:
- schema:
- $ref: '#/components/schemas/Order'
- '400':
- description: Invalid ID supplied
- '404':
- description: Order not found
- delete:
- tags:
- - store
- summary: Delete purchase order by ID
- description: >-
- For valid response try integer IDs with value < 1000. Anything above
- 1000 or nonintegers will generate API errors
- operationId: deleteOrder
- parameters:
- - name: order_id
- in: path
- description: ID of the order that needs to be deleted
- required: true
- schema:
- type: string
- responses:
- '400':
- description: Invalid ID supplied
- '404':
- description: Order not found
- /user:
- post:
- tags:
- - user
- summary: Create user
- description: This can only be done by the logged in user.
- operationId: createUser
- responses:
- default:
- description: successful operation
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/User'
- description: Created user object
- required: true
- /user/createWithArray:
- post:
- tags:
- - user
- summary: Creates list of users with given input array
- description: ''
- operationId: createUsersWithArrayInput
- responses:
- default:
- description: successful operation
- requestBody:
- $ref: '#/components/requestBodies/UserArray'
- /user/createWithList:
- post:
- tags:
- - user
- summary: Creates list of users with given input array
- description: ''
- operationId: createUsersWithListInput
- responses:
- default:
- description: successful operation
- requestBody:
- $ref: '#/components/requestBodies/UserArray'
- /user/login:
- get:
- tags:
- - user
- summary: Logs user into the system
- description: ''
- operationId: loginUser
- parameters:
- - name: username
- in: query
- description: The user name for login
- required: true
- schema:
- type: string
- - name: password
- in: query
- description: The password for login in clear text
- required: true
- schema:
- type: string
- responses:
- '200':
- description: successful operation
- headers:
- X-Rate-Limit:
- description: calls per hour allowed by the user
- schema:
- type: integer
- format: int32
- X-Expires-After:
- description: date in UTC when token expires
- schema:
- type: string
- format: date-time
- content:
- application/xml:
- schema:
- type: string
- application/json:
- schema:
- type: string
- '400':
- description: Invalid username/password supplied
- /user/logout:
- get:
- tags:
- - user
- summary: Logs out current logged in user session
- description: ''
- operationId: logoutUser
- responses:
- default:
- description: successful operation
- '/user/{username}':
- get:
- tags:
- - user
- summary: Get user by user name
- description: ''
- operationId: getUserByName
- parameters:
- - name: username
- in: path
- description: The name that needs to be fetched. Use user1 for testing.
- required: true
- schema:
- type: string
- responses:
- '200':
- description: successful operation
- content:
- application/xml:
- schema:
- $ref: '#/components/schemas/User'
- application/json:
- schema:
- $ref: '#/components/schemas/User'
- '400':
- description: Invalid username supplied
- '404':
- description: User not found
- put:
- tags:
- - user
- summary: Updated user
- description: This can only be done by the logged in user.
- operationId: updateUser
- parameters:
- - name: username
- in: path
- description: name that need to be deleted
- required: true
- schema:
- type: string
- responses:
- '400':
- description: Invalid user supplied
- '404':
- description: User not found
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/User'
- description: Updated user object
- required: true
- delete:
- tags:
- - user
- summary: Delete user
- description: This can only be done by the logged in user.
- operationId: deleteUser
- parameters:
- - name: username
- in: path
- description: The name that needs to be deleted
- required: true
- schema:
- type: string
- responses:
- '400':
- description: Invalid username supplied
- '404':
- description: User not found
- /fake_classname_test:
- patch:
- tags:
- - 'fake_classname_tags 123#$%^'
- summary: To test class name in snake case
- description: To test class name in snake case
- operationId: testClassname
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Client'
- security:
- - api_key_query: []
- requestBody:
- $ref: '#/components/requestBodies/Client'
- /fake:
- patch:
- tags:
- - fake
- summary: To test "client" model
- description: To test "client" model
- operationId: testClientModel
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Client'
- requestBody:
- $ref: '#/components/requestBodies/Client'
- get:
- tags:
- - fake
- summary: To test enum parameters
- description: To test enum parameters
- operationId: testEnumParameters
- parameters:
- - name: enum_header_string_array
- in: header
- description: Header parameter enum test (string array)
- schema:
- type: array
- items:
- type: string
- default: $
- enum:
- - '>'
- - $
- - name: enum_header_string
- in: header
- description: Header parameter enum test (string)
- schema:
- type: string
- enum:
- - _abc
- - '-efg'
- - (xyz)
- default: '-efg'
- - name: enum_query_string_array
- in: query
- description: Query parameter enum test (string array)
- schema:
- type: array
- items:
- type: string
- default: $
- enum:
- - '>'
- - $
- - name: enum_query_string
- in: query
- description: Query parameter enum test (string)
- schema:
- type: string
- enum:
- - _abc
- - '-efg'
- - (xyz)
- default: '-efg'
- - name: enum_query_integer
- in: query
- description: Query parameter enum test (double)
- schema:
- type: integer
- format: int32
- enum:
- - 1
- - -2
- - name: enum_query_double
- in: query
- description: Query parameter enum test (double)
- schema:
- type: number
- format: double
- enum:
- - 1.1
- - -1.2
- responses:
- '400':
- description: Invalid request
- '404':
- description: Not found
- requestBody:
- content:
- application/x-www-form-urlencoded:
- schema:
- type: object
- properties:
- enum_form_string_array:
- description: Form parameter enum test (string array)
- type: array
- items:
- type: string
- default: $
- enum:
- - '>'
- - $
- enum_form_string:
- description: Form parameter enum test (string)
- type: string
- enum:
- - _abc
- - '-efg'
- - (xyz)
- default: '-efg'
- post:
- tags:
- - fake
- summary: |
- Fake endpoint for testing various parameters
- 假端點
- 偽のエンドポイント
- 가짜 엔드 포인트
- description: |
- Fake endpoint for testing various parameters
- 假端點
- 偽のエンドポイント
- 가짜 엔드 포인트
- operationId: testEndpointParameters
- responses:
- '400':
- description: Invalid username supplied
- '404':
- description: User not found
- security:
- - http_basic_test: []
- requestBody:
- content:
- application/x-www-form-urlencoded:
- schema:
- type: object
- properties:
- integer:
- description: None
- type: integer
- minimum: 10
- maximum: 100
- int32:
- description: None
- type: integer
- format: int32
- minimum: 20
- maximum: 200
- int64:
- description: None
- type: integer
- format: int64
- number:
- description: None
- type: number
- minimum: 32.1
- maximum: 543.2
- float:
- description: None
- type: number
- format: float
- maximum: 987.6
- double:
- description: None
- type: number
- format: double
- minimum: 67.8
- maximum: 123.4
- string:
- description: None
- type: string
- pattern: '/[a-z]/i'
- pattern_without_delimiter:
- description: None
- type: string
- pattern: '^[A-Z].*'
- byte:
- description: None
- type: string
- format: byte
- binary:
- description: None
- type: string
- format: binary
- date:
- description: None
- type: string
- format: date
- dateTime:
- description: None
- type: string
- format: date-time
- default: '2010-02-01T10:20:10.11111+01:00'
- example: '2020-02-02T20:20:20.22222Z'
- password:
- description: None
- type: string
- format: password
- minLength: 10
- maxLength: 64
- callback:
- description: None
- type: string
- required:
- - number
- - double
- - pattern_without_delimiter
- - byte
- delete:
- tags:
- - fake
- security:
- - bearer_test: []
- summary: Fake endpoint to test group parameters (optional)
- description: Fake endpoint to test group parameters (optional)
- operationId: testGroupParameters
- x-group-parameters: true
- parameters:
- - name: required_string_group
- in: query
- description: Required String in group parameters
- required: true
- schema:
- type: integer
- - name: required_boolean_group
- in: header
- description: Required Boolean in group parameters
- required: true
- schema:
- type: boolean
- - name: required_int64_group
- in: query
- description: Required Integer in group parameters
- required: true
- schema:
- type: integer
- format: int64
- - name: string_group
- in: query
- description: String in group parameters
- schema:
- type: integer
- - name: boolean_group
- in: header
- description: Boolean in group parameters
- schema:
- type: boolean
- - name: int64_group
- in: query
- description: Integer in group parameters
- schema:
- type: integer
- format: int64
- responses:
- '400':
- description: Someting wrong
- /fake/outer/number:
- post:
- tags:
- - fake
- description: Test serialization of outer number types
- operationId: fakeOuterNumberSerialize
- responses:
- '200':
- description: Output number
- content:
- '*/*':
- schema:
- $ref: '#/components/schemas/OuterNumber'
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/OuterNumber'
- description: Input number as post body
- /fake/outer/string:
- post:
- tags:
- - fake
- description: Test serialization of outer string types
- operationId: fakeOuterStringSerialize
- responses:
- '200':
- description: Output string
- content:
- '*/*':
- schema:
- $ref: '#/components/schemas/OuterString'
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/OuterString'
- description: Input string as post body
- /fake/outer/boolean:
- post:
- tags:
- - fake
- description: Test serialization of outer boolean types
- operationId: fakeOuterBooleanSerialize
- responses:
- '200':
- description: Output boolean
- content:
- '*/*':
- schema:
- $ref: '#/components/schemas/OuterBoolean'
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/OuterBoolean'
- description: Input boolean as post body
- /fake/outer/composite:
- post:
- tags:
- - fake
- description: Test serialization of object with outer number type
- operationId: fakeOuterCompositeSerialize
- responses:
- '200':
- description: Output composite
- content:
- '*/*':
- schema:
- $ref: '#/components/schemas/OuterComposite'
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/OuterComposite'
- description: Input composite as post body
- /fake/jsonFormData:
- get:
- tags:
- - fake
- summary: test json serialization of form data
- description: ''
- operationId: testJsonFormData
- responses:
- '200':
- description: successful operation
- requestBody:
- content:
- application/x-www-form-urlencoded:
- schema:
- type: object
- properties:
- param:
- description: field1
- type: string
- param2:
- description: field2
- type: string
- required:
- - param
- - param2
- /fake/inline-additionalProperties:
- post:
- tags:
- - fake
- summary: test inline additionalProperties
- description: ''
- operationId: testInlineAdditionalProperties
- responses:
- '200':
- description: successful operation
- requestBody:
- content:
- application/json:
- schema:
- type: object
- additionalProperties:
- type: string
- description: request body
- required: true
- /fake/body-with-query-params:
- put:
- tags:
- - fake
- operationId: testBodyWithQueryParams
- parameters:
- - name: query
- in: query
- required: true
- schema:
- type: string
- responses:
- '200':
- description: Success
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/User'
- required: true
- /another-fake/dummy:
- patch:
- tags:
- - $another-fake?
- summary: To test special tags
- description: To test special tags and operation ID starting with number
- operationId: '123_test_@#$%_special_tags'
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Client'
- requestBody:
- $ref: '#/components/requestBodies/Client'
-# /fake/body-with-file-schema:
-# put:
-# tags:
-# - fake
-# description: >-
-# For this test, the body for this request much reference a schema named
-# `File`.
-# operationId: testBodyWithFileSchema
-# responses:
-# '200':
-# description: Success
-# requestBody:
-# content:
-# application/json:
-# schema:
-# $ref: '#/components/schemas/FileSchemaTestClass'
-# required: true
- /fake/test-query-parameters:
- put:
- tags:
- - fake
- description: To test the collection format in query parameters
- operationId: testQueryParameterCollectionFormat
- parameters:
- - name: pipe
- in: query
- required: true
- schema:
- type: array
- items:
- type: string
- - name: ioutil
- in: query
- required: true
- style: form
- explode: false
- schema:
- type: array
- items:
- type: string
- - name: http
- in: query
- required: true
- style: spaceDelimited
- schema:
- type: array
- items:
- type: string
- - name: url
- in: query
- required: true
- style: form
- explode: false
- schema:
- type: array
- items:
- type: string
- - name: context
- in: query
- required: true
- explode: true
- schema:
- type: array
- items:
- type: string
- responses:
- "200":
- description: Success
- '/fake/{petId}/uploadImageWithRequiredFile':
- post:
- tags:
- - pet
- summary: uploads an image (required)
- description: ''
- operationId: uploadFileWithRequiredFile
- parameters:
- - name: petId
- in: path
- description: ID of pet to update
- required: true
- schema:
- type: integer
- format: int64
- responses:
- '200':
- description: successful operation
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ApiResponse'
- security:
- - petstore_auth:
- - 'write:pets'
- - 'read:pets'
- requestBody:
- content:
- multipart/form-data:
- schema:
- type: object
- properties:
- additionalMetadata:
- description: Additional data to pass to server
- type: string
- requiredFile:
- description: file to upload
- type: string
- format: binary
- required:
- - requiredFile
- /fake/health:
- get:
- tags:
- - fake
- summary: Health check endpoint
- responses:
- 200:
- description: The instance started successfully
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/HealthCheckResult'
- /fake/array-of-enums:
- get:
- tags:
- - fake
- summary: Array of Enums
- operationId: getArrayOfEnums
- responses:
- 200:
- description: Got named array of enums
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ArrayOfEnums'
-servers:
- - url: 'http://{server}.swagger.io:{port}/v2'
- description: petstore server
- variables:
- server:
- enum:
- - 'petstore'
- - 'qa-petstore'
- - 'dev-petstore'
- default: 'petstore'
- port:
- enum:
- - 80
- - 8080
- default: 80
- - url: https://localhost:8080/{version}
- description: The local server
- variables:
- version:
- enum:
- - 'v1'
- - 'v2'
- default: 'v2'
- - url: https://127.0.0.1/no_variable
- description: The local server without variables
-components:
- requestBodies:
- UserArray:
- content:
- application/json:
- schema:
- type: array
- items:
- $ref: '#/components/schemas/User'
- examples:
- simple-list:
- summary: Simple list example
- description: Should not get into code examples
- value:
- - username: foo
- - username: bar
- description: List of user object
- required: true
- Client:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Client'
- description: client model
- required: true
- Pet:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Pet'
- application/xml:
- schema:
- $ref: '#/components/schemas/Pet'
- description: Pet object that needs to be added to the store
- required: true
- securitySchemes:
- petstore_auth:
- type: oauth2
- flows:
- implicit:
- authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
- scopes:
- 'write:pets': modify pets in your account
- 'read:pets': read your pets
- api_key:
- type: apiKey
- name: api_key
- in: header
- api_key_query:
- type: apiKey
- name: api_key_query
- in: query
- http_basic_test:
- type: http
- scheme: basic
- bearer_test:
- type: http
- scheme: bearer
- bearerFormat: JWT
- http_signature_test:
- # Test the 'HTTP signature' security scheme.
- # Each HTTP request is cryptographically signed as specified
- # in https://datatracker.ietf.org/doc/draft-cavage-http-signatures/
- type: http
- scheme: signature
- schemas:
- Foo:
- type: object
- properties:
- bar:
- $ref: '#/components/schemas/Bar'
- Bar:
- type: string
- default: bar
- Order:
- type: object
- properties:
- id:
- type: integer
- format: int64
- petId:
- type: integer
- format: int64
- quantity:
- type: integer
- format: int32
- shipDate:
- type: string
- format: date-time
- example: '2020-02-02T20:20:20.000222Z'
- status:
- type: string
- description: Order Status
- enum:
- - placed
- - approved
- - delivered
- complete:
- type: boolean
- default: false
- xml:
- name: Order
- Category:
- type: object
- required:
- - name
- properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- default: default-name
- xml:
- name: Category
- User:
- type: object
- properties:
- id:
- type: integer
- format: int64
- x-is-unique: true
- username:
- type: string
- firstName:
- type: string
- lastName:
- type: string
- email:
- type: string
- password:
- type: string
- phone:
- type: string
- userStatus:
- type: integer
- format: int32
- description: User Status
- objectWithNoDeclaredProps:
- type: object
- # Note: the 'additionalProperties' keyword is not specified, which is
- # equivalent to allowing undeclared properties of any type.
- description: test code generation for objects
- Value must be a map of strings to values. It cannot be the 'null' value.
- objectWithNoDeclaredPropsNullable:
- type: object
- # Note: the 'additionalProperties' keyword is not specified, which is
- # equivalent to allowing undeclared properties of any type.
- description: test code generation for nullable objects.
- Value must be a map of strings to values or the 'null' value.
- nullable: true
- anyTypeProp:
- description: test code generation for any type
- Here the 'type' attribute is not specified, which means the value can be anything,
- including the null value, string, number, boolean, array or object.
- See https://github.com/OAI/OpenAPI-Specification/issues/1389
- # TODO: this should be supported, currently there are some issues in the code generation.
- #anyTypeExceptNullProp:
- # description: any type except 'null'
- # Here the 'type' attribute is not specified, which means the value can be anything,
- # including the null value, string, number, boolean, array or object.
- # not:
- # type: 'null'
- anyTypePropNullable:
- description: test code generation for any type
- Here the 'type' attribute is not specified, which means the value can be anything,
- including the null value, string, number, boolean, array or object.
- The 'nullable' attribute does not change the allowed values.
- nullable: true
- xml:
- name: User
- Tag:
- type: object
- properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- xml:
- name: Tag
- Pet:
- type: object
- required:
- - name
- - photoUrls
- properties:
- id:
- type: integer
- format: int64
- x-is-unique: true
- category:
- $ref: '#/components/schemas/Category'
- name:
- type: string
- example: doggie
- photoUrls:
- type: array
- xml:
- name: photoUrl
- wrapped: true
- items:
- type: string
- tags:
- type: array
- xml:
- name: tag
- wrapped: true
- items:
- $ref: '#/components/schemas/Tag'
- status:
- type: string
- description: pet status in the store
- enum:
- - available
- - pending
- - sold
- xml:
- name: Pet
- ApiResponse:
- type: object
- properties:
- code:
- type: integer
- format: int32
- type:
- type: string
- message:
- type: string
- Return:
- description: Model for testing reserved words
- properties:
- return:
- type: integer
- format: int32
- xml:
- name: Return
- Name:
- description: Model for testing model name same as property name
- required:
- - name
- properties:
- name:
- type: integer
- format: int32
- snake_case:
- readOnly: true
- type: integer
- format: int32
- property:
- type: string
- 123Number:
- type: integer
- readOnly: true
- xml:
- name: Name
- 200_response:
- description: Model for testing model name starting with number
- properties:
- name:
- type: integer
- format: int32
- class:
- type: string
- xml:
- name: Name
- ClassModel:
- description: Model for testing model with "_class" property
- properties:
- _class:
- type: string
- Dog:
- allOf:
- - $ref: '#/components/schemas/Animal'
- - type: object
- properties:
- breed:
- type: string
- Cat:
- allOf:
- - $ref: '#/components/schemas/Animal'
- - $ref: '#/components/schemas/Address'
- - type: object
- properties:
- declawed:
- type: boolean
- Address:
- type: object
- additionalProperties:
- type: integer
- Animal:
- type: object
- discriminator:
- propertyName: className
- required:
- - className
- properties:
- className:
- type: string
- color:
- type: string
- default: red
- AnimalFarm:
- type: array
- items:
- $ref: '#/components/schemas/Animal'
- format_test:
- type: object
- required:
- - number
- - byte
- - date
- - password
- properties:
- integer:
- type: integer
- maximum: 100
- minimum: 10
- multipleOf: 2
- int32:
- type: integer
- format: int32
- maximum: 200
- minimum: 20
- int64:
- type: integer
- format: int64
- number:
- maximum: 543.2
- minimum: 32.1
- type: number
- multipleOf: 32.5
- float:
- type: number
- format: float
- maximum: 987.6
- minimum: 54.3
- double:
- type: number
- format: double
- maximum: 123.4
- minimum: 67.8
- decimal:
- type: string
- format: number
- string:
- type: string
- pattern: '/[a-z]/i'
- byte:
- type: string
- format: byte
- binary:
- type: string
- format: binary
- date:
- type: string
- format: date
- example: '2020-02-02'
- dateTime:
- type: string
- format: date-time
- example: '2007-12-03T10:15:30+01:00'
- uuid:
- type: string
- format: uuid
- example: 72f98069-206d-4f12-9f12-3d1e525a8e84
- password:
- type: string
- format: password
- maxLength: 64
- minLength: 10
- pattern_with_digits:
- description: A string that is a 10 digit number. Can have leading zeros.
- type: string
- pattern: '^\d{10}$'
- pattern_with_digits_and_delimiter:
- description: A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
- type: string
- pattern: '/^image_\d{1,3}$/i'
- EnumClass:
- type: string
- default: '-efg'
- enum:
- - _abc
- - '-efg'
- - (xyz)
- Enum_Test:
- type: object
- required:
- - enum_string_required
- properties:
- enum_string:
- type: string
- enum:
- - UPPER
- - lower
- - ''
- enum_string_required:
- type: string
- enum:
- - UPPER
- - lower
- - ''
- enum_integer:
- type: integer
- format: int32
- enum:
- - 1
- - -1
- enum_integer_only:
- type: integer
- enum:
- - 2
- - -2
- enum_number:
- type: number
- format: double
- enum:
- - 1.1
- - -1.2
- outerEnum:
- $ref: '#/components/schemas/OuterEnum'
- outerEnumInteger:
- $ref: '#/components/schemas/OuterEnumInteger'
- outerEnumDefaultValue:
- $ref: '#/components/schemas/OuterEnumDefaultValue'
- outerEnumIntegerDefaultValue:
- $ref: '#/components/schemas/OuterEnumIntegerDefaultValue'
- AdditionalPropertiesClass:
- type: object
- properties:
- map_property:
- type: object
- additionalProperties:
- type: string
- map_of_map_property:
- type: object
- additionalProperties:
- type: object
- additionalProperties:
- type: string
- anytype_1: {}
- map_with_undeclared_properties_anytype_1:
- type: object
- map_with_undeclared_properties_anytype_2:
- type: object
- properties: {}
- map_with_undeclared_properties_anytype_3:
- type: object
- additionalProperties: true
- empty_map:
- type: object
- description: an object with no declared properties and no undeclared
- properties, hence it's an empty map.
- additionalProperties: false
- map_with_undeclared_properties_string:
- type: object
- additionalProperties:
- type: string
- MixedPropertiesAndAdditionalPropertiesClass:
- type: object
- properties:
- uuid:
- type: string
- format: uuid
- dateTime:
- type: string
- format: date-time
- map:
- type: object
- additionalProperties:
- $ref: '#/components/schemas/Animal'
- List:
- type: object
- properties:
- 123-list:
- type: string
- Client:
- type: object
- properties:
- client:
- type: string
- ReadOnlyFirst:
- type: object
- properties:
- bar:
- type: string
- readOnly: true
- baz:
- type: string
- hasOnlyReadOnly:
- type: object
- properties:
- bar:
- type: string
- readOnly: true
- foo:
- type: string
- readOnly: true
- Capitalization:
- type: object
- properties:
- smallCamel:
- type: string
- CapitalCamel:
- type: string
- small_Snake:
- type: string
- Capital_Snake:
- type: string
- SCA_ETH_Flow_Points:
- type: string
- ATT_NAME:
- description: |
- Name of the pet
- type: string
- MapTest:
- type: object
- properties:
- map_map_of_string:
- type: object
- additionalProperties:
- type: object
- additionalProperties:
- type: string
- map_of_enum_string:
- type: object
- additionalProperties:
- type: string
- enum:
- - UPPER
- - lower
- direct_map:
- type: object
- additionalProperties:
- type: boolean
- indirect_map:
- $ref: '#/components/schemas/StringBooleanMap'
- ArrayTest:
- type: object
- properties:
- array_of_string:
- type: array
- items:
- type: string
- array_array_of_integer:
- type: array
- items:
- type: array
- items:
- type: integer
- format: int64
- array_array_of_model:
- type: array
- items:
- type: array
- items:
- $ref: '#/components/schemas/ReadOnlyFirst'
- NumberOnly:
- type: object
- properties:
- JustNumber:
- type: number
- ArrayOfNumberOnly:
- type: object
- properties:
- ArrayNumber:
- type: array
- items:
- type: number
- ArrayOfArrayOfNumberOnly:
- type: object
- properties:
- ArrayArrayNumber:
- type: array
- items:
- type: array
- items:
- type: number
- EnumArrays:
- type: object
- properties:
- just_symbol:
- type: string
- enum:
- - '>='
- - $
- array_enum:
- type: array
- items:
- type: string
- enum:
- - fish
- - crab
- OuterEnum:
- nullable: true
- type: string
- enum:
- - placed
- - approved
- - delivered
- OuterEnumInteger:
- type: integer
- enum:
- - 0
- - 1
- - 2
- OuterEnumDefaultValue:
- type: string
- enum:
- - placed
- - approved
- - delivered
- default: placed
- OuterEnumIntegerDefaultValue:
- type: integer
- enum:
- - 0
- - 1
- - 2
- default: 0
- OuterComposite:
- type: object
- properties:
- my_number:
- $ref: '#/components/schemas/OuterNumber'
- my_string:
- $ref: '#/components/schemas/OuterString'
- my_boolean:
- $ref: '#/components/schemas/OuterBoolean'
- OuterNumber:
- type: number
- OuterString:
- type: string
- OuterBoolean:
- type: boolean
- x-codegen-body-parameter-name: boolean_post_body
- StringBooleanMap:
- additionalProperties:
- type: boolean
-# FileSchemaTestClass:
-# type: object
-# properties:
-# file:
-# $ref: '#/components/schemas/File'
-# files:
-# type: array
-# items:
-# $ref: '#/components/schemas/File'
- File:
- type: object
- description: Must be named `File` for test.
- properties:
- sourceURI:
- description: Test capitalization
- type: string
- _special_model.name_:
- properties:
- '$special[property.name]':
- type: integer
- format: int64
- '_special_model.name_':
- type: string
- xml:
- name: '$special[model.name]'
- HealthCheckResult:
- type: object
- properties:
- NullableMessage:
- nullable: true
- type: string
- description: Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
- NullableClass:
- type: object
- properties:
- integer_prop:
- type: integer
- nullable: true
- number_prop:
- type: number
- nullable: true
- boolean_prop:
- type: boolean
- nullable: true
- string_prop:
- type: string
- nullable: true
- date_prop:
- type: string
- format: date
- nullable: true
- datetime_prop:
- type: string
- format: date-time
- nullable: true
- array_nullable_prop:
- type: array
- nullable: true
- items:
- type: object
- array_and_items_nullable_prop:
- type: array
- nullable: true
- items:
- type: object
- nullable: true
- array_items_nullable:
- type: array
- items:
- type: object
- nullable: true
- object_nullable_prop:
- type: object
- nullable: true
- additionalProperties:
- type: object
- object_and_items_nullable_prop:
- type: object
- nullable: true
- additionalProperties:
- type: object
- nullable: true
- object_items_nullable:
- type: object
- additionalProperties:
- type: object
- nullable: true
- additionalProperties:
- type: object
- nullable: true
- fruit:
- properties:
- color:
- type: string
- oneOf:
- - $ref: '#/components/schemas/apple'
- - $ref: '#/components/schemas/banana'
- # Below additionalProperties is set to false to validate the use
- # case when a composed schema has additionalProperties set to false.
- additionalProperties: false
- apple:
- type: object
- properties:
- cultivar:
- type: string
- pattern: ^[a-zA-Z\s]*$
- origin:
- type: string
- pattern: /^[A-Z\s]*$/i
- nullable: true
- banana:
- type: object
- properties:
- lengthCm:
- type: number
- mammal:
- oneOf:
- - $ref: '#/components/schemas/whale'
- - $ref: '#/components/schemas/zebra'
- - $ref: '#/components/schemas/Pig'
- discriminator:
- propertyName: className
- whale:
- type: object
- properties:
- hasBaleen:
- type: boolean
- hasTeeth:
- type: boolean
- className:
- type: string
- required:
- - className
- zebra:
- type: object
- properties:
- type:
- type: string
- enum:
- - plains
- - mountain
- - grevys
- className:
- type: string
- required:
- - className
- additionalProperties: true
- Pig:
- oneOf:
- - $ref: '#/components/schemas/BasquePig'
- - $ref: '#/components/schemas/DanishPig'
- discriminator:
- propertyName: className
- BasquePig:
- type: object
- properties:
- className:
- type: string
- required:
- - className
- DanishPig:
- type: object
- properties:
- className:
- type: string
- required:
- - className
- gmFruit:
- properties:
- color:
- type: string
- anyOf:
- - $ref: '#/components/schemas/apple'
- - $ref: '#/components/schemas/banana'
- additionalProperties: false
- fruitReq:
- oneOf:
- - type: 'null'
- - $ref: '#/components/schemas/appleReq'
- - $ref: '#/components/schemas/bananaReq'
- additionalProperties: false
- appleReq:
- type: object
- properties:
- cultivar:
- type: string
- mealy:
- type: boolean
- required:
- - cultivar
- additionalProperties: false
- bananaReq:
- type: object
- properties:
- lengthCm:
- type: number
- sweet:
- type: boolean
- required:
- - lengthCm
- additionalProperties: false
- # go-experimental is unable to make Triangle and Quadrilateral models
- # correctly https://github.com/OpenAPITools/openapi-generator/issues/6149
- Drawing:
- type: object
- properties:
- mainShape:
- # A property whose value is a 'oneOf' type, and the type is referenced instead
- # of being defined inline. The value cannot be null.
- $ref: '#/components/schemas/Shape'
- shapeOrNull:
- # A property whose value is a 'oneOf' type, and the type is referenced instead
- # of being defined inline. The value may be null because ShapeOrNull has 'null'
- # type as a child schema of 'oneOf'.
- $ref: '#/components/schemas/ShapeOrNull'
- nullableShape:
- # A property whose value is a 'oneOf' type, and the type is referenced instead
- # of being defined inline. The value may be null because NullableShape has the
- # 'nullable: true' attribute. For this specific scenario this is exactly the
- # same thing as 'shapeOrNull'.
- $ref: '#/components/schemas/NullableShape'
- shapes:
- type: array
- items:
- $ref: '#/components/schemas/Shape'
- additionalProperties:
- # Here the additional properties are specified using a referenced schema.
- # This is just to validate the generated code works when using $ref
- # under 'additionalProperties'.
- $ref: '#/components/schemas/fruit'
- Shape:
- oneOf:
- - $ref: '#/components/schemas/Triangle'
- - $ref: '#/components/schemas/Quadrilateral'
- discriminator:
- propertyName: shapeType
- ShapeOrNull:
- description: The value may be a shape or the 'null' value.
- This is introduced in OAS schema >= 3.1.
- oneOf:
- - type: 'null'
- - $ref: '#/components/schemas/Triangle'
- - $ref: '#/components/schemas/Quadrilateral'
- discriminator:
- propertyName: shapeType
- NullableShape:
- description: The value may be a shape or the 'null' value.
- The 'nullable' attribute was introduced in OAS schema >= 3.0
- and has been deprecated in OAS schema >= 3.1.
- oneOf:
- - $ref: '#/components/schemas/Triangle'
- - $ref: '#/components/schemas/Quadrilateral'
- discriminator:
- propertyName: shapeType
- nullable: true
- ShapeInterface:
- properties:
- shapeType:
- type: string
- required:
- - shapeType
- TriangleInterface:
- properties:
- triangleType:
- type: string
- required:
- - triangleType
- Triangle:
- oneOf:
- - $ref: '#/components/schemas/EquilateralTriangle'
- - $ref: '#/components/schemas/IsoscelesTriangle'
- - $ref: '#/components/schemas/ScaleneTriangle'
- discriminator:
- propertyName: triangleType
- # Note: the 'additionalProperties' keyword is not specified, which is
- # equivalent to allowing undeclared properties of any type.
- EquilateralTriangle:
- allOf:
- - $ref: '#/components/schemas/ShapeInterface'
- - $ref: '#/components/schemas/TriangleInterface'
- IsoscelesTriangle:
- allOf:
- - $ref: '#/components/schemas/ShapeInterface'
- - $ref: '#/components/schemas/TriangleInterface'
- additionalProperties: false
- ScaleneTriangle:
- allOf:
- - $ref: '#/components/schemas/ShapeInterface'
- - $ref: '#/components/schemas/TriangleInterface'
- QuadrilateralInterface:
- properties:
- quadrilateralType:
- type: string
- required:
- - quadrilateralType
- Quadrilateral:
- oneOf:
- - $ref: '#/components/schemas/SimpleQuadrilateral'
- - $ref: '#/components/schemas/ComplexQuadrilateral'
- discriminator:
- propertyName: quadrilateralType
- SimpleQuadrilateral:
- allOf:
- - $ref: '#/components/schemas/ShapeInterface'
- - $ref: '#/components/schemas/QuadrilateralInterface'
- ComplexQuadrilateral:
- allOf:
- - $ref: '#/components/schemas/ShapeInterface'
- - $ref: '#/components/schemas/QuadrilateralInterface'
- GrandparentAnimal:
- type: object
- required:
- - pet_type
- properties:
- pet_type:
- type: string
- discriminator:
- propertyName: pet_type
- ParentPet:
- type: object
- allOf:
- - $ref: '#/components/schemas/GrandparentAnimal'
- #ChildCat:
- # allOf:
- # - $ref: '#/components/schemas/ParentPet'
- # - type: object
- # properties:
- # name:
- # type: string
- # pet_type:
- # x-enum-as-string: true
- # type: string
- # enum:
- # - ChildCat
- # default: ChildCat
- ArrayOfEnums:
- type: array
- items:
- $ref: '#/components/schemas/OuterEnum'
- DateTimeTest:
- type: string
- default: '2010-01-01T10:10:10.000111+01:00'
- example: '2010-01-01T10:10:10.000111+01:00'
- format: date-time
- DeprecatedObject:
- type: object
- deprecated: true
- properties:
- name:
- type: string
- ObjectWithDeprecatedFields:
- type: object
- properties:
- uuid:
- type: string
- id:
- type: number
- deprecated: true
- deprecatedRef:
- $ref: '#/components/schemas/DeprecatedObject'
- bars:
- type: array
- deprecated: true
- items:
- $ref: '#/components/schemas/Bar'
- PetWithRequiredTags:
- type: object
- required:
- - name
- - photoUrls
- - tags
- properties:
- id:
- type: integer
- format: int64
- x-is-unique: true
- category:
- $ref: '#/components/schemas/Category'
- name:
- type: string
- example: doggie
- photoUrls:
- type: array
- xml:
- name: photoUrl
- wrapped: true
- items:
- type: string
- tags:
- type: array
- xml:
- name: tag
- wrapped: true
- items:
- $ref: '#/components/schemas/Tag'
- status:
- type: string
- description: pet status in the store
- enum:
- - available
- - pending
- - sold
- xml:
- name: Pet
diff --git a/pom.xml b/pom.xml
index e7a19c49beae..358690a1210b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1346,7 +1346,6 @@
samples/openapi3/client/petstore/java/jersey2-java8
samples/client/others/java/okhttp-gson-streaming
samples/client/petstore/java/okhttp-gson
-
samples/client/petstore/java/retrofit2
samples/client/petstore/java/retrofit2rx2
samples/client/petstore/java/retrofit2rx3
diff --git a/samples/client/others/java/okhttp-gson-streaming/.openapi-generator/FILES b/samples/client/others/java/okhttp-gson-streaming/.openapi-generator/FILES
index 9efd92ad7a1a..77e02d36f052 100644
--- a/samples/client/others/java/okhttp-gson-streaming/.openapi-generator/FILES
+++ b/samples/client/others/java/okhttp-gson-streaming/.openapi-generator/FILES
@@ -33,4 +33,5 @@ src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
src/main/java/org/openapitools/client/auth/Authentication.java
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
+src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
src/main/java/org/openapitools/client/model/SomeObj.java
diff --git a/samples/client/others/java/okhttp-gson-streaming/pom.xml b/samples/client/others/java/okhttp-gson-streaming/pom.xml
index 2b89ca0c1c20..8a1529f3b2b8 100644
--- a/samples/client/others/java/okhttp-gson-streaming/pom.xml
+++ b/samples/client/others/java/okhttp-gson-streaming/pom.xml
@@ -301,6 +301,16 @@
jackson-databind-nullable
${jackson-databind-nullable-version}
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+ 2.0
+
junit
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
index f2fca9d7ea3b..840cac41bd29 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java
@@ -1091,6 +1091,7 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept
/**
* Build HTTP call with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1113,6 +1114,7 @@ public Call buildCall(String baseUrl, String path, String method, List que
/**
* Build an HTTP request with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1181,6 +1183,7 @@ public Request buildRequest(String baseUrl, String path, String method, List cookieParams, Request.Builde
* @param payload HTTP request body
* @param method HTTP method
* @param uri URI
+ * @throws org.openapitools.client.ApiException If fails to update the parameters
*/
public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
Map cookieParams, String payload, String method, URI uri) throws ApiException {
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
index 46e3601c1343..afa977ee2585 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiException.java
@@ -16,6 +16,8 @@
import java.util.Map;
import java.util.List;
+import javax.ws.rs.core.GenericType;
+
/**
* ApiException class.
*/
@@ -25,6 +27,8 @@ public class ApiException extends Exception {
private int code = 0;
private Map> responseHeaders = null;
private String responseBody = null;
+ private Object errorObject = null;
+ private GenericType errorObjectType = null;
/**
* Constructor for ApiException.
@@ -151,4 +155,40 @@ public Map> getResponseHeaders() {
public String getResponseBody() {
return responseBody;
}
+
+ /**
+ * Get the error object type.
+ *
+ * @return Error object type
+ */
+ public GenericType getErrorObjectType() {
+ return errorObjectType;
+ }
+
+ /**
+ * Set the error object type.
+ *
+ * @param errorObjectType object type
+ */
+ public void setErrorObjectType(GenericType errorObjectType) {
+ this.errorObjectType = errorObjectType;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @return Error object
+ */
+ public Object getErrorObject() {
+ return errorObject;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @param errorObject Error object
+ */
+ public void setErrorObject(Object errorObject) {
+ this.errorObject = errorObject;
+ }
}
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/JSON.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/JSON.java
index 4c7ae244a335..33256f94541c 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/JSON.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/JSON.java
@@ -27,7 +27,6 @@
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
-import org.openapitools.client.model.*;
import okio.ByteString;
import java.io.IOException;
@@ -41,14 +40,20 @@
import java.util.Map;
import java.util.HashMap;
+/*
+ * A JSON utility class
+ *
+ * NOTE: in the future, this class may be converted to static, which may break
+ * backward-compatibility
+ */
public class JSON {
- private Gson gson;
- private boolean isLenientOnJson = false;
- private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
- private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
- private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
- private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
- private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
+ private static Gson gson;
+ private static boolean isLenientOnJson = false;
+ private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
+ private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
+ private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
+ private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
+ private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
@@ -81,13 +86,14 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
return clazz;
}
- public JSON() {
+ {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayAdapter)
+ .registerTypeAdapterFactory(new org.openapitools.client.model.SomeObj.CustomTypeAdapterFactory())
.create();
}
@@ -96,7 +102,7 @@ public JSON() {
*
* @return Gson
*/
- public Gson getGson() {
+ public static Gson getGson() {
return gson;
}
@@ -104,23 +110,13 @@ public Gson getGson() {
* Set Gson.
*
* @param gson Gson
- * @return JSON
*/
- public JSON setGson(Gson gson) {
- this.gson = gson;
- return this;
+ public static void setGson(Gson gson) {
+ JSON.gson = gson;
}
- /**
- * Configure the parser to be liberal in what it accepts.
- *
- * @param lenientOnJson Set it to true to ignore some syntax errors
- * @return JSON
- * @see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
- */
- public JSON setLenientOnJson(boolean lenientOnJson) {
+ public static void setLenientOnJson(boolean lenientOnJson) {
isLenientOnJson = lenientOnJson;
- return this;
}
/**
@@ -129,7 +125,7 @@ public JSON setLenientOnJson(boolean lenientOnJson) {
* @param obj Object
* @return String representation of the JSON
*/
- public String serialize(Object obj) {
+ public static String serialize(Object obj) {
return gson.toJson(obj);
}
@@ -142,11 +138,11 @@ public String serialize(Object obj) {
* @return The deserialized Java object
*/
@SuppressWarnings("unchecked")
- public T deserialize(String body, Type returnType) {
+ public static T deserialize(String body, Type returnType) {
try {
if (isLenientOnJson) {
JsonReader jsonReader = new JsonReader(new StringReader(body));
- // see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
+ // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
jsonReader.setLenient(true);
return gson.fromJson(jsonReader, returnType);
} else {
@@ -166,7 +162,7 @@ public T deserialize(String body, Type returnType) {
/**
* Gson TypeAdapter for Byte Array type
*/
- public class ByteArrayAdapter extends TypeAdapter {
+ public static class ByteArrayAdapter extends TypeAdapter {
@Override
public void write(JsonWriter out, byte[] value) throws IOException {
@@ -238,7 +234,7 @@ public OffsetDateTime read(JsonReader in) throws IOException {
/**
* Gson TypeAdapter for JSR310 LocalDate type
*/
- public class LocalDateTypeAdapter extends TypeAdapter {
+ public static class LocalDateTypeAdapter extends TypeAdapter {
private DateTimeFormatter formatter;
@@ -276,14 +272,12 @@ public LocalDate read(JsonReader in) throws IOException {
}
}
- public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
+ public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
offsetDateTimeTypeAdapter.setFormat(dateFormat);
- return this;
}
- public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
+ public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
localDateTypeAdapter.setFormat(dateFormat);
- return this;
}
/**
@@ -397,14 +391,11 @@ public Date read(JsonReader in) throws IOException {
}
}
- public JSON setDateFormat(DateFormat dateFormat) {
+ public static void setDateFormat(DateFormat dateFormat) {
dateTypeAdapter.setFormat(dateFormat);
- return this;
}
- public JSON setSqlDateFormat(DateFormat dateFormat) {
+ public static void setSqlDateFormat(DateFormat dateFormat) {
sqlDateTypeAdapter.setFormat(dateFormat);
- return this;
}
-
}
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
index dc64eace5442..31835e16e011 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/api/PingApi.java
@@ -35,6 +35,7 @@
import java.util.List;
import java.util.Map;
import java.io.InputStream;
+import javax.ws.rs.core.GenericType;
public class PingApi {
private ApiClient localVarApiClient;
@@ -87,7 +88,6 @@ public void setCustomBaseUrl(String customBaseUrl) {
*/
public okhttp3.Call postPingCall(SomeObj someObj, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -171,8 +171,14 @@ public InputStream postPing(SomeObj someObj) throws ApiException {
*/
public InputStream postPingWithHttpInfo(SomeObj someObj) throws ApiException {
okhttp3.Call localVarCall = postPingValidateBeforeCall(someObj, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.executeStream(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.executeStream(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
new file mode 100644
index 000000000000..e16bfc964dd0
--- /dev/null
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
@@ -0,0 +1,149 @@
+/*
+ * ping some object
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ *
+ * The version of the OpenAPI document: 1.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.model;
+
+import org.openapitools.client.ApiException;
+import java.util.Objects;
+import java.lang.reflect.Type;
+import java.util.Map;
+import javax.ws.rs.core.GenericType;
+
+//import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
+ */
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public abstract class AbstractOpenApiSchema {
+
+ // store the actual instance of the schema/object
+ private Object instance;
+
+ // is nullable
+ private Boolean isNullable;
+
+ // schema type (e.g. oneOf, anyOf)
+ private final String schemaType;
+
+ public AbstractOpenApiSchema(String schemaType, Boolean isNullable) {
+ this.schemaType = schemaType;
+ this.isNullable = isNullable;
+ }
+
+ /**
+ * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
+ *
+ * @return an instance of the actual schema/object
+ */
+ public abstract Map getSchemas();
+
+ /**
+ * Get the actual instance
+ *
+ * @return an instance of the actual schema/object
+ */
+ //@JsonValue
+ public Object getActualInstance() {return instance;}
+
+ /**
+ * Set the actual instance
+ *
+ * @param instance the actual instance of the schema/object
+ */
+ public void setActualInstance(Object instance) {this.instance = instance;}
+
+ /**
+ * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well
+ *
+ * @return an instance of the actual schema/object
+ */
+ public Object getActualInstanceRecursively() {
+ return getActualInstanceRecursively(this);
+ }
+
+ private Object getActualInstanceRecursively(AbstractOpenApiSchema object) {
+ if (object.getActualInstance() == null) {
+ return null;
+ } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) {
+ return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance());
+ } else {
+ return object.getActualInstance();
+ }
+ }
+
+ /**
+ * Get the schema type (e.g. anyOf, oneOf)
+ *
+ * @return the schema type
+ */
+ public String getSchemaType() {
+ return schemaType;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ").append(getClass()).append(" {\n");
+ sb.append(" instance: ").append(toIndentedString(instance)).append("\n");
+ sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n");
+ sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ AbstractOpenApiSchema a = (AbstractOpenApiSchema) o;
+ return Objects.equals(this.instance, a.instance) &&
+ Objects.equals(this.isNullable, a.isNullable) &&
+ Objects.equals(this.schemaType, a.schemaType);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(instance, isNullable, schemaType);
+ }
+
+ /**
+ * Is nullable
+ *
+ * @return true if it's nullable
+ */
+ public Boolean isNullable() {
+ if (Boolean.TRUE.equals(isNullable)) {
+ return Boolean.TRUE;
+ } else {
+ return Boolean.FALSE;
+ }
+ }
+
+
+
+}
diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
index 99455e9f948a..a8b42537e4d8 100644
--- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
+++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java
@@ -24,6 +24,25 @@
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.TypeAdapterFactory;
+import com.google.gson.reflect.TypeToken;
+
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.openapitools.client.JSON;
+
/**
* SomeObj
*/
@@ -257,5 +276,93 @@ private String toIndentedString(Object o) {
return o.toString().replace("\n", "\n ");
}
+
+ public static HashSet openapiFields;
+ public static HashSet openapiRequiredFields;
+
+ static {
+ // a set of all properties/fields (JSON key names)
+ openapiFields = new HashSet();
+ openapiFields.add("$_type");
+ openapiFields.add("id");
+ openapiFields.add("name");
+ openapiFields.add("active");
+ openapiFields.add("type");
+
+ // a set of required properties/fields (JSON key names)
+ openapiRequiredFields = new HashSet();
+ }
+
+ /**
+ * Validates the JSON Object and throws an exception if issues found
+ *
+ * @param jsonObj JSON Object
+ * @throws IOException if the JSON Object is invalid with respect to SomeObj
+ */
+ public static void validateJsonObject(JsonObject jsonObj) throws IOException {
+ if (jsonObj == null) {
+ if (SomeObj.openapiRequiredFields.isEmpty()) {
+ return;
+ } else { // has reuqired fields
+ throw new IllegalArgumentException(String.format("The required field(s) %s in SomeObj is not found in the empty JSON string", SomeObj.openapiRequiredFields.toString()));
+ }
+ }
+ Set> entries = jsonObj.entrySet();
+ // check to see if the JSON string contains additional fields
+ for (Entry entry : entries) {
+ if (!SomeObj.openapiFields.contains(entry.getKey())) {
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SomeObj` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ }
+ }
+ }
+
+ public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public TypeAdapter create(Gson gson, TypeToken type) {
+ if (!SomeObj.class.isAssignableFrom(type.getRawType())) {
+ return null; // this class only serializes 'SomeObj' and its subtypes
+ }
+ final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
+ final TypeAdapter thisAdapter
+ = gson.getDelegateAdapter(this, TypeToken.get(SomeObj.class));
+
+ return (TypeAdapter) new TypeAdapter() {
+ @Override
+ public void write(JsonWriter out, SomeObj value) throws IOException {
+ JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
+ elementAdapter.write(out, obj);
+ }
+
+ @Override
+ public SomeObj read(JsonReader in) throws IOException {
+ JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
+ validateJsonObject(jsonObj);
+ return thisAdapter.fromJsonTree(jsonObj);
+ }
+
+ }.nullSafe();
+ }
+ }
+
+ /**
+ * Create an instance of SomeObj given an JSON string
+ *
+ * @param jsonString JSON string
+ * @return An instance of SomeObj
+ * @throws IOException if the JSON string is invalid with respect to SomeObj
+ */
+ public static SomeObj fromJson(String jsonString) throws IOException {
+ return JSON.getGson().fromJson(jsonString, SomeObj.class);
+ }
+
+ /**
+ * Convert an instance of SomeObj to an JSON string
+ *
+ * @return JSON string
+ */
+ public String toJson() {
+ return JSON.getGson().toJson(this);
+ }
}
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/.openapi-generator/FILES b/samples/client/petstore/java/okhttp-gson-dynamicOperations/.openapi-generator/FILES
index f8e8f2d5a9e8..f21fe42c6bcf 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/.openapi-generator/FILES
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/.openapi-generator/FILES
@@ -94,6 +94,7 @@ src/main/java/org/openapitools/client/auth/OAuth.java
src/main/java/org/openapitools/client/auth/OAuthFlow.java
src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java
src/main/java/org/openapitools/client/auth/RetryingOAuth.java
+src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml b/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml
index 9e8777894cea..3e85ce99567e 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/pom.xml
@@ -311,6 +311,16 @@
jackson-databind-nullable
${jackson-databind-nullable-version}
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+
+
+ javax.ws.rs
+ javax.ws.rs-api
+ 2.0
+
junit
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java
index 7707d1a586d5..95e5f6a6caa2 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java
@@ -1169,6 +1169,7 @@ public T handleResponse(Response response, Type returnType) throws ApiExcept
/**
* Build HTTP call with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1191,6 +1192,7 @@ public Call buildCall(String baseUrl, String path, String method, List que
/**
* Build an HTTP request with the given options.
*
+ * @param baseUrl The base URL
* @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
* @param queryParams The query parameters
@@ -1259,6 +1261,7 @@ public Request buildRequest(String baseUrl, String path, String method, List cookieParams, Request.Builde
* @param payload HTTP request body
* @param method HTTP method
* @param uri URI
+ * @throws org.openapitools.client.ApiException If fails to update the parameters
*/
public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams,
Map cookieParams, String payload, String method, URI uri) throws ApiException {
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiException.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiException.java
index 5851f0405ade..60e4f9a5e7e6 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiException.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiException.java
@@ -16,6 +16,8 @@
import java.util.Map;
import java.util.List;
+import javax.ws.rs.core.GenericType;
+
/**
* ApiException class.
*/
@@ -25,6 +27,8 @@ public class ApiException extends Exception {
private int code = 0;
private Map> responseHeaders = null;
private String responseBody = null;
+ private Object errorObject = null;
+ private GenericType errorObjectType = null;
/**
* Constructor for ApiException.
@@ -151,4 +155,40 @@ public Map> getResponseHeaders() {
public String getResponseBody() {
return responseBody;
}
+
+ /**
+ * Get the error object type.
+ *
+ * @return Error object type
+ */
+ public GenericType getErrorObjectType() {
+ return errorObjectType;
+ }
+
+ /**
+ * Set the error object type.
+ *
+ * @param errorObjectType object type
+ */
+ public void setErrorObjectType(GenericType errorObjectType) {
+ this.errorObjectType = errorObjectType;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @return Error object
+ */
+ public Object getErrorObject() {
+ return errorObject;
+ }
+
+ /**
+ * Get the error object.
+ *
+ * @param errorObject Error object
+ */
+ public void setErrorObject(Object errorObject) {
+ this.errorObject = errorObject;
+ }
}
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/JSON.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/JSON.java
index 274416e5dedc..c2502541ff1d 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/JSON.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/JSON.java
@@ -27,7 +27,6 @@
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;
-import org.openapitools.client.model.*;
import okio.ByteString;
import java.io.IOException;
@@ -41,54 +40,60 @@
import java.util.Map;
import java.util.HashMap;
+/*
+ * A JSON utility class
+ *
+ * NOTE: in the future, this class may be converted to static, which may break
+ * backward-compatibility
+ */
public class JSON {
- private Gson gson;
- private boolean isLenientOnJson = false;
- private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
- private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
- private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
- private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
- private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
+ private static Gson gson;
+ private static boolean isLenientOnJson = false;
+ private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
+ private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
+ private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
+ private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
+ private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
@SuppressWarnings("unchecked")
public static GsonBuilder createGson() {
GsonFireBuilder fireBuilder = new GsonFireBuilder()
- .registerTypeSelector(Animal.class, new TypeSelector() {
+ .registerTypeSelector(org.openapitools.client.model.Animal.class, new TypeSelector() {
@Override
- public Class extends Animal> getClassForElement(JsonElement readElement) {
+ public Class extends org.openapitools.client.model.Animal> getClassForElement(JsonElement readElement) {
Map classByDiscriminatorValue = new HashMap();
- classByDiscriminatorValue.put("BigCat", BigCat.class);
- classByDiscriminatorValue.put("Cat", Cat.class);
- classByDiscriminatorValue.put("Dog", Dog.class);
- classByDiscriminatorValue.put("Animal", Animal.class);
+ classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
+ classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class);
+ classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class);
+ classByDiscriminatorValue.put("Animal", org.openapitools.client.model.Animal.class);
return getClassByDiscriminator(classByDiscriminatorValue,
getDiscriminatorValue(readElement, "className"));
}
})
- .registerTypeSelector(BigCat.class, new TypeSelector() {
+ .registerTypeSelector(org.openapitools.client.model.BigCat.class, new TypeSelector() {
@Override
- public Class extends BigCat> getClassForElement(JsonElement readElement) {
+ public Class extends org.openapitools.client.model.BigCat> getClassForElement(JsonElement readElement) {
Map classByDiscriminatorValue = new HashMap();
- classByDiscriminatorValue.put("BigCat", BigCat.class);
+ classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
return getClassByDiscriminator(classByDiscriminatorValue,
getDiscriminatorValue(readElement, "className"));
}
})
- .registerTypeSelector(Cat.class, new TypeSelector() {
+ .registerTypeSelector(org.openapitools.client.model.Cat.class, new TypeSelector() {
@Override
- public Class extends Cat> getClassForElement(JsonElement readElement) {
+ public Class extends org.openapitools.client.model.Cat> getClassForElement(JsonElement readElement) {
Map classByDiscriminatorValue = new HashMap();
- classByDiscriminatorValue.put("BigCat", BigCat.class);
- classByDiscriminatorValue.put("Cat", Cat.class);
+ classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
+ classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class);
return getClassByDiscriminator(classByDiscriminatorValue,
getDiscriminatorValue(readElement, "className"));
}
})
- .registerTypeSelector(Dog.class, new TypeSelector() {
+ .registerTypeSelector(org.openapitools.client.model.Dog.class, new TypeSelector() {
@Override
- public Class extends Dog> getClassForElement(JsonElement readElement) {
+ public Class extends org.openapitools.client.model.Dog> getClassForElement(JsonElement readElement) {
Map classByDiscriminatorValue = new HashMap();
- classByDiscriminatorValue.put("Dog", Dog.class);
+ classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class);
return getClassByDiscriminator(classByDiscriminatorValue,
getDiscriminatorValue(readElement, "className"));
}
@@ -121,13 +126,57 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
return clazz;
}
- public JSON() {
+ {
gson = createGson()
.registerTypeAdapter(Date.class, dateTypeAdapter)
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
.registerTypeAdapter(byte[].class, byteArrayAdapter)
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesAnyType.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesArray.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesBoolean.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesClass.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesInteger.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesNumber.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesObject.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesString.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ArrayOfArrayOfNumberOnly.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ArrayOfNumberOnly.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ArrayTest.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.BigCat.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.BigCatAllOf.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Capitalization.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.CatAllOf.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ClassModel.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Client.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Dog.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.DogAllOf.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.EnumArrays.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.EnumTest.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.FileSchemaTestClass.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.FormatTest.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.HasOnlyReadOnly.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.MapTest.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.MixedPropertiesAndAdditionalPropertiesClass.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Model200Response.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ModelApiResponse.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ModelFile.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ModelList.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ModelReturn.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Name.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.NumberOnly.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Order.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.OuterComposite.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.ReadOnlyFirst.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.SpecialModelName.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.TypeHolderDefault.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.TypeHolderExample.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.User.CustomTypeAdapterFactory())
+ .registerTypeAdapterFactory(new org.openapitools.client.model.XmlItem.CustomTypeAdapterFactory())
.create();
}
@@ -136,7 +185,7 @@ public JSON() {
*
* @return Gson
*/
- public Gson getGson() {
+ public static Gson getGson() {
return gson;
}
@@ -144,23 +193,13 @@ public Gson getGson() {
* Set Gson.
*
* @param gson Gson
- * @return JSON
*/
- public JSON setGson(Gson gson) {
- this.gson = gson;
- return this;
+ public static void setGson(Gson gson) {
+ JSON.gson = gson;
}
- /**
- * Configure the parser to be liberal in what it accepts.
- *
- * @param lenientOnJson Set it to true to ignore some syntax errors
- * @return JSON
- * @see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
- */
- public JSON setLenientOnJson(boolean lenientOnJson) {
+ public static void setLenientOnJson(boolean lenientOnJson) {
isLenientOnJson = lenientOnJson;
- return this;
}
/**
@@ -169,7 +208,7 @@ public JSON setLenientOnJson(boolean lenientOnJson) {
* @param obj Object
* @return String representation of the JSON
*/
- public String serialize(Object obj) {
+ public static String serialize(Object obj) {
return gson.toJson(obj);
}
@@ -182,11 +221,11 @@ public String serialize(Object obj) {
* @return The deserialized Java object
*/
@SuppressWarnings("unchecked")
- public T deserialize(String body, Type returnType) {
+ public static T deserialize(String body, Type returnType) {
try {
if (isLenientOnJson) {
JsonReader jsonReader = new JsonReader(new StringReader(body));
- // see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
+ // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
jsonReader.setLenient(true);
return gson.fromJson(jsonReader, returnType);
} else {
@@ -206,7 +245,7 @@ public T deserialize(String body, Type returnType) {
/**
* Gson TypeAdapter for Byte Array type
*/
- public class ByteArrayAdapter extends TypeAdapter {
+ public static class ByteArrayAdapter extends TypeAdapter {
@Override
public void write(JsonWriter out, byte[] value) throws IOException {
@@ -278,7 +317,7 @@ public OffsetDateTime read(JsonReader in) throws IOException {
/**
* Gson TypeAdapter for JSR310 LocalDate type
*/
- public class LocalDateTypeAdapter extends TypeAdapter {
+ public static class LocalDateTypeAdapter extends TypeAdapter {
private DateTimeFormatter formatter;
@@ -316,14 +355,12 @@ public LocalDate read(JsonReader in) throws IOException {
}
}
- public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
+ public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
offsetDateTimeTypeAdapter.setFormat(dateFormat);
- return this;
}
- public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
+ public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
localDateTypeAdapter.setFormat(dateFormat);
- return this;
}
/**
@@ -437,14 +474,11 @@ public Date read(JsonReader in) throws IOException {
}
}
- public JSON setDateFormat(DateFormat dateFormat) {
+ public static void setDateFormat(DateFormat dateFormat) {
dateTypeAdapter.setFormat(dateFormat);
- return this;
}
- public JSON setSqlDateFormat(DateFormat dateFormat) {
+ public static void setSqlDateFormat(DateFormat dateFormat) {
sqlDateTypeAdapter.setFormat(dateFormat);
- return this;
}
-
}
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
index 5f6571f9e7d8..f364de8ca6fd 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/AnotherFakeApi.java
@@ -37,6 +37,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.GenericType;
public class AnotherFakeApi {
private ApiClient localVarApiClient;
@@ -89,7 +90,6 @@ public void setCustomBaseUrl(String customBaseUrl) {
*/
public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -186,8 +186,14 @@ public Client call123testSpecialTags(Client body) throws ApiException {
*/
public ApiResponse call123testSpecialTagsWithHttpInfo(Client body) throws ApiException {
okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java
index c55d1e12c08a..781eb83cd822 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeApi.java
@@ -45,6 +45,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.GenericType;
public class FakeApi {
private ApiClient localVarApiClient;
@@ -97,7 +98,6 @@ public void setCustomBaseUrl(String customBaseUrl) {
*/
public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -228,7 +228,6 @@ public okhttp3.Call createXmlItemAsync(XmlItem xmlItem, final ApiCallback
*/
public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -320,8 +319,14 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws ApiException {
*/
public ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws ApiException {
okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -358,7 +363,6 @@ public okhttp3.Call fakeOuterBooleanSerializeAsync(Boolean body, final ApiCallba
*/
public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -450,8 +454,14 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Ap
*/
public ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws ApiException {
okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -488,7 +498,6 @@ public okhttp3.Call fakeOuterCompositeSerializeAsync(OuterComposite body, final
*/
public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -580,8 +589,14 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws ApiException
*/
public ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws ApiException {
okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -618,7 +633,6 @@ public okhttp3.Call fakeOuterNumberSerializeAsync(BigDecimal body, final ApiCall
*/
public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -710,8 +724,14 @@ public String fakeOuterStringSerialize(String body) throws ApiException {
*/
public ApiResponse fakeOuterStringSerializeWithHttpInfo(String body) throws ApiException {
okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -748,7 +768,6 @@ public okhttp3.Call fakeOuterStringSerializeAsync(String body, final ApiCallback
*/
public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -880,7 +899,6 @@ public okhttp3.Call testBodyWithFileSchemaAsync(FileSchemaTestClass body, final
*/
public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1020,7 +1038,6 @@ public okhttp3.Call testBodyWithQueryParamsAsync(String query, User body, final
*/
public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1117,8 +1134,14 @@ public Client testClientModel(Client body) throws ApiException {
*/
public ApiResponse testClientModelWithHttpInfo(Client body) throws ApiException {
okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -1169,7 +1192,6 @@ public okhttp3.Call testClientModelAsync(Client body, final ApiCallback
*/
public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, File binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1421,7 +1443,6 @@ public okhttp3.Call testEndpointParametersAsync(BigDecimal number, Double _doubl
*/
public okhttp3.Call testEnumParametersCall(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1573,7 +1594,6 @@ public okhttp3.Call testEnumParametersAsync(List enumHeaderStringArray,
}
private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1800,7 +1820,6 @@ public APItestGroupParametersRequest testGroupParameters(Integer requiredStringG
*/
public okhttp3.Call testInlineAdditionalPropertiesCall(Map param, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1932,7 +1951,6 @@ public okhttp3.Call testInlineAdditionalPropertiesAsync(Map para
*/
public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -2083,7 +2101,6 @@ public okhttp3.Call testJsonFormDataAsync(String param, String param2, final Api
*/
public okhttp3.Call testQueryParameterCollectionFormatCall(List pipe, List ioutil, List http, List url, List context, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
index c508d0d8bb6b..0a4db0f802cc 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
@@ -37,6 +37,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.GenericType;
public class FakeClassnameTags123Api {
private ApiClient localVarApiClient;
@@ -89,7 +90,6 @@ public void setCustomBaseUrl(String customBaseUrl) {
*/
public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -186,8 +186,14 @@ public Client testClassname(Client body) throws ApiException {
*/
public ApiResponse testClassnameWithHttpInfo(Client body) throws ApiException {
okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java
index f41e1b5ebe7e..ed5ccbc7127a 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/api/PetApi.java
@@ -40,6 +40,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.GenericType;
public class PetApi {
private ApiClient localVarApiClient;
@@ -93,7 +94,6 @@ public void setCustomBaseUrl(String customBaseUrl) {
*/
public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -229,7 +229,6 @@ public okhttp3.Call addPetAsync(Pet body, final ApiCallback _callback) thr
*/
public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -369,7 +368,6 @@ public okhttp3.Call deletePetAsync(Long petId, String apiKey, final ApiCallback<
*/
public okhttp3.Call findPetsByStatusCall(List status, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -469,8 +467,14 @@ public List findPetsByStatus(List status) throws ApiException {
*/
public ApiResponse> findPetsByStatusWithHttpInfo(List status) throws ApiException {
okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null);
- Type localVarReturnType = new TypeToken>(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken>(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken>(){}.getType()));
+ e.setErrorObjectType(new GenericType>(){});
+ throw e;
+ }
}
/**
@@ -511,7 +515,6 @@ public okhttp3.Call findPetsByStatusAsync(List status, final ApiCallback
@Deprecated
public okhttp3.Call findPetsByTagsCall(Set tags, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -616,8 +619,14 @@ public Set findPetsByTags(Set tags) throws ApiException {
@Deprecated
public ApiResponse> findPetsByTagsWithHttpInfo(Set tags) throws ApiException {
okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null);
- Type localVarReturnType = new TypeToken>(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken>(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken>(){}.getType()));
+ e.setErrorObjectType(new GenericType>(){});
+ throw e;
+ }
}
/**
@@ -659,7 +668,6 @@ public okhttp3.Call findPetsByTagsAsync(Set tags, final ApiCallback getPetByIdWithHttpInfo(Long petId) throws ApiException {
okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null);
- Type localVarReturnType = new TypeToken(){}.getType();
- return localVarApiClient.execute(localVarCall, localVarReturnType);
+ try {
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ } catch (ApiException e) {
+ e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken(){}.getType()));
+ e.setErrorObjectType(new GenericType(){});
+ throw e;
+ }
}
/**
@@ -804,7 +818,6 @@ public okhttp3.Call getPetByIdAsync(Long petId, final ApiCallback _callback
*/
public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -946,7 +959,6 @@ public okhttp3.Call updatePetAsync(Pet body, final ApiCallback _callback)
*/
public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1094,7 +1106,6 @@ public okhttp3.Call updatePetWithFormAsync(Long petId, String name, String statu
*/
public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException {
String basePath = null;
-
// Operation Servers
String[] localBasePaths = new String[] { };
@@ -1204,8 +1215,14 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File _
*/
public ApiResponse uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException {
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, null);
- Type localVarReturnType = new TypeToken